1. 09 7月, 2013 1 次提交
  2. 30 5月, 2013 3 次提交
    • R
      push: make push.default = current use resolved HEAD · 0f075b22
      Ramkumar Ramachandra 提交于
      With this change, the output of the push (with push.default set to
      current) changes subtly from:
      
        $ git push
        ...
         * [new branch]      HEAD -> push-current-head
      
      to:
      
        $ git push
        ...
         * [new branch]      push-current-head -> push-current-head
      
      This patch was written with a different motivation. There is a problem
      unique to push.default = current:
      
        # on branch push-current-head
        $ git push
        # on another terminal
        $ git checkout master
        # return to the first terminal
        # the push tried to push master!
      
      This happens because the 'git checkout' on the second terminal races
      with the 'git push' on the first terminal.  Although this patch does not
      solve the core problem (there is still no guarantee that 'git push' on
      the first terminal will resolve HEAD before 'git checkout' changes HEAD
      on the second), it works in practice.
      Signed-off-by: NRamkumar Ramachandra <artagnon@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0f075b22
    • R
      push: fail early with detached HEAD and current · 7b2ecd81
      Ramkumar Ramachandra 提交于
      Setting push.default to current adds the refspec "HEAD" for the
      transport layer to handle.  If "HEAD" doesn't resolve to a branch (and
      since no refspec rhs is specified), the push fails after some time with
      a cryptic error message:
      
        $ git push
        error: unable to push to unqualified destination: HEAD
        The destination refspec neither matches an existing ref on the remote nor
        begins with refs/, and we are unable to guess a prefix based on the source ref.
        error: failed to push some refs to 'git@github.com:artagnon/git'
      
      Fail early with a nicer error message:
      
        $ git push
        fatal: You are not currently on a branch.
        To push the history leading to the current (detached HEAD)
        state now, use
      
          git push ram HEAD:<name-of-remote-branch>
      
      Just like in the upstream and simple cases.
      Signed-off-by: NRamkumar Ramachandra <artagnon@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7b2ecd81
    • R
      push: factor out the detached HEAD error message · 35ee69c0
      Ramkumar Ramachandra 提交于
      With push.default set to upstream or simple, and a detached HEAD, git
      push prints the following error:
      
        $ git push
        fatal: You are not currently on a branch.
        To push the history leading to the current (detached HEAD)
        state now, use
      
          git push ram HEAD:<name-of-remote-branch>
      
      This error is not unique to upstream or simple: current cannot push with
      a detached HEAD either.  So, factor out the error string in preparation
      for using it in current.
      Signed-off-by: NRamkumar Ramachandra <artagnon@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      35ee69c0
  3. 03 4月, 2013 1 次提交
    • R
      remote.c: introduce a way to have different remotes for fetch/push · f24f715e
      Ramkumar Ramachandra 提交于
      Currently, do_push() in push.c calls remote_get(), which gets the
      configured remote for fetching and pushing.  Replace this call with a
      call to pushremote_get() instead, a new function that will return the
      remote configured specifically for pushing.  This function tries to
      work with the string pushremote_name, before falling back to the
      codepath of remote_get().  This patch has no visible impact, but
      serves to enable future patches to introduce configuration variables
      to set pushremote_name.  For example, you can now do the following in
      handle_config():
      
          if (!strcmp(key, "remote.pushdefault"))
             git_config_string(&pushremote_name, key, value);
      
      Then, pushes will automatically go to the remote specified by
      remote.pushdefault.
      Signed-off-by: NRamkumar Ramachandra <artagnon@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f24f715e
  4. 06 3月, 2013 1 次提交
    • J
      push: --follow-tags · c2aba155
      Junio C Hamano 提交于
      The new option "--follow-tags" tells "git push" to push annotated
      tags that are missing from the other side and that can be reached by
      the history that is otherwise pushed out.
      
      For example, if you are using the "simple", "current", or "upstream"
      push, you would ordinarily push the history leading to the commit at
      your current HEAD and nothing else.  With this option, you would
      also push all annotated tags that can be reached from that commit to
      the other side.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c2aba155
  5. 25 1月, 2013 2 次提交
    • J
      push: finishing touches to explain REJECT_ALREADY_EXISTS better · b4cf8db2
      Junio C Hamano 提交于
      Now that "already exists" errors are given only when a push tries to
      update an existing ref in refs/tags/ hierarchy, we can say "the
      tag", instead of "the destination reference", and that is far easier
      to understand.
      
      Pointed out by Chris Rorvick.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b4cf8db2
    • J
      push: introduce REJECT_FETCH_FIRST and REJECT_NEEDS_FORCE · 75e5c0dc
      Junio C Hamano 提交于
      When we push to update an existing ref, if:
      
       * the object at the tip of the remote is not a commit; or
       * the object we are pushing is not a commit,
      
      it won't be correct to suggest to fetch, integrate and push again,
      as the old and new objects will not "merge".  We should explain that
      the push must be forced when there is a non-committish object is
      involved in such a case.
      
      If we do not have the current object at the tip of the remote, we do
      not even know that object, when fetched, is something that can be
      merged.  In such a case, suggesting to pull first just like
      non-fast-forward case may not be technically correct, but in
      practice, most such failures are seen when you try to push your work
      to a branch without knowing that somebody else already pushed to
      update the same branch since you forked, so "pull first" would work
      as a suggestion most of the time.  And if the object at the tip is
      not a commit, "pull first" will fail, without making any permanent
      damage.  As a side effect, it also makes the error message the user
      will get during the next "push" attempt easier to understand, now
      the user is aware that a non-commit object is involved.
      
      In these cases, the current code already rejects such a push on the
      client end, but we used the same error and advice messages as the
      ones used when rejecting a non-fast-forward push, i.e. pull from
      there and integrate before pushing again.
      
      Introduce new rejection reasons and reword the messages
      appropriately.
      
      [jc: with help by Peff on message details]
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      75e5c0dc
  6. 19 1月, 2013 1 次提交
    • A
      push: Add support for pre-push hooks · ec55559f
      Aaron Schrab 提交于
      Add support for a pre-push hook which can be used to determine if the
      set of refs to be pushed is suitable for the target repository.  The
      hook is run with two arguments specifying the name and location of the
      destination repository.
      
      Information about what is to be pushed is provided by sending lines of
      the following form to the hook's standard input:
      
        <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
      
      If the hook exits with a non-zero status, the push will be aborted.
      
      This will allow the script to determine if the push is acceptable based
      on the target repository and branch(es), the commits which are to be
      pushed, and even the source branches in some cases.
      Signed-off-by: NAaron Schrab <aaron@schrab.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ec55559f
  7. 04 12月, 2012 2 次提交
  8. 02 12月, 2012 3 次提交
  9. 23 8月, 2012 1 次提交
  10. 21 8月, 2012 1 次提交
  11. 25 6月, 2012 1 次提交
  12. 25 4月, 2012 1 次提交
    • M
      push: introduce new push.default mode "simple" · b55e6775
      Matthieu Moy 提交于
      When calling "git push" without argument, we want to allow Git to do
      something simple to explain and safe. push.default=matching is unsafe
      when used to push to shared repositories, and hard to explain to
      beginners in some contexts. It is debatable whether 'upstream' or
      'current' is the safest or the easiest to explain, so introduce a new
      mode called 'simple' that is the intersection of them: push to the
      upstream branch, but only if it has the same name remotely. If not, give
      an error that suggests the right command to push explicitely to
      'upstream' or 'current'.
      
      A question is whether to allow pushing when no upstream is configured. An
      argument in favor of allowing the push is that it makes the new mode work
      in more cases. On the other hand, refusing to push when no upstream is
      configured encourages the user to set the upstream, which will be
      beneficial on the next pull. Lacking better argument, we chose to deny
      the push, because it will be easier to change in the future if someone
      shows us wrong.
      Original-patch-by: NJeff King <peff@peff.net>
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b55e6775
  13. 06 4月, 2012 1 次提交
    • J
      push: error out when the "upstream" semantics does not make sense · 135dadef
      Junio C Hamano 提交于
      The user can say "git push" without specifying any refspec.  When using
      the "upstream" semantics via the push.default configuration, the user
      wants to update the "upstream" branch of the current branch, which is the
      branch at a remote repository the current branch is set to integrate with,
      with this command.
      
      However, there are cases that such a "git push" that uses the "upstream"
      semantics does not make sense:
      
       - The current branch does not have branch.$name.remote configured.  By
         definition, "git push" that does not name where to push to will not
         know where to push to.  The user may explicitly say "git push $there",
         but again, by definition, no branch at repository $there is set to
         integrate with the current branch in this case and we wouldn't know
         which remote branch to update.
      
       - The current branch does have branch.$name.remote configured, but it
         does not specify branch.$name.merge that names what branch at the
         remote this branch integrates with. "git push" knows where to push in
         this case (or the user may explicitly say "git push $remote" to tell us
         where to push), but we do not know which remote branch to update.
      
       - The current branch does have its remote and upstream branch configured,
         but the user said "git push $there", where $there is not the remote
         named by "branch.$name.remote".  By definition, no branch at repository
         $there is set to integrate with the current branch in this case, and
         this push is not meant to update any branch at the remote repository
         $there.
      
      The first two cases were already checked correctly, but the third case was
      not checked and we ended up updating the branch named branch.$name.merge
      at repository $there, which was totally bogus.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      135dadef
  14. 31 3月, 2012 1 次提交
  15. 20 3月, 2012 1 次提交
    • C
      push: Provide situational hints for non-fast-forward errors · f25950f3
      Christopher Tiwald 提交于
      Pushing a non-fast-forward update to a remote repository will result in
      an error, but the hint text doesn't provide the correct resolution in
      every case. Give better resolution advice in three push scenarios:
      
      1) If you push your current branch and it triggers a non-fast-forward
      error, you should merge remote changes with 'git pull' before pushing
      again.
      
      2) If you push to a shared repository others push to, and your local
      tracking branches are not kept up to date, the 'matching refs' default
      will generate non-fast-forward errors on outdated branches. If this is
      your workflow, the 'matching refs' default is not for you. Consider
      setting the 'push.default' configuration variable to 'current' or
      'upstream' to ensure only your current branch is pushed.
      
      3) If you explicitly specify a ref that is not your current branch or
      push matching branches with ':', you will generate a non-fast-forward
      error if any pushed branch tip is out of date. You should checkout the
      offending branch and merge remote changes before pushing again.
      
      Teach transport.c to recognize these scenarios and configure push.c
      to hint for them. If 'git push's default behavior changes or we
      discover more scenarios, extension is easy. Standardize on the
      advice API and add three new advice variables, 'pushNonFFCurrent',
      'pushNonFFDefault', and 'pushNonFFMatching'. Setting any of these
      to 'false' will disable their affiliated advice. Setting
      'pushNonFastForward' to false will disable all three, thus preserving the
      config option for users who already set it, but guaranteeing new
      users won't disable push advice accidentally.
      Based-on-patch-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NChristopher Tiwald <christiwald@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f25950f3
  16. 23 2月, 2012 1 次提交
    • F
      push: add '--prune' option · 6ddba5e2
      Felipe Contreras 提交于
      When pushing groups of refs to a remote, there is no simple way to remove
      old refs that still exist at the remote that is no longer updated from us.
      This will allow us to remove such refs from the remote.
      
      With this change, running this command
      
       $ git push --prune remote refs/heads/*:refs/remotes/laptop/*
      
      removes refs/remotes/laptop/foo from the remote if we do not have branch
      "foo" locally anymore.
      Signed-off-by: NFelipe Contreras <felipe.contreras@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6ddba5e2
  17. 14 2月, 2012 1 次提交
  18. 25 1月, 2012 1 次提交
    • N
      clone: fix up delay cloning conditions · 90498161
      Nguyễn Thái Ngọc Duy 提交于
      6f48d39f (clone: delay cloning until after remote HEAD checking -
      2012-01-16) allows us to perform some checks on remote refs before the
      actual cloning happens. But not all transport types support
      this. Remote helper with "import" capability will not return complete
      ref information until fetch is performed and therefore the clone cannot
      be delayed.
      
      foreign_vcs field in struct remote was used to detect this kind of transport
      and save the result. This is a mistake because foreign_vcs is designed
      to override url-based transport detection. As a result, if the same
      "struct transport *" object is used on many different urls and one of
      them attached remote transport, the following urls will be mistakenly
      attached to the same transport. This fault is worked around by dad0b3d8
      (push: do not let configured foreign-vcs permanently clobbered -
      2012-01-23)
      
      To fix this, detect incomplete refs from transport_get_remote_refs()
      by SHA-1. Incomplete ones must have null SHA-1 (*). Then revert
      changes related to foreign_cvs field in 6f48d39f and dad0b3d8.
      
      A good thing from this change is that cloning smart http transport can
      also be delayed. Earlier it falls into the same category "remote
      transport, no delay".
      
      (*) Theoretically if one of the remote refs happens to have null SHA-1,
      it will trigger false alarm and the clone will not be delayed. But
      that chance may be too small for us to pay attention to.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      90498161
  19. 24 1月, 2012 1 次提交
    • J
      push: do not let configured foreign-vcs permanently clobbered · dad0b3d8
      Junio C Hamano 提交于
      Recently, 6f48d39f (clone: delay cloning until after remote HEAD checking,
      2012-01-16) tried to record if a remote helper needs to be called after
      parsing the remote when transport_get() is called, by overwriting the
      field meant to store the configured remote helper name in the remote
      structure.
      
      This is OK when a remote represents a single remote repository, but fails
      miserably when pushing to locations with multiple URLs, like this:
      
          $ cat .git/config
          [remote "origin"]
              url = https://code.google.com/p/git-htmldocs/
              url = github.com:gitster/git-htmldocs.git
              push = refs/heads/master:refs/heads/master
          $ git push
      
      The second url that is supposed to use the git-over-ssh transport
      mistakenly use https:// and fails with:
      
          error: Couldn't resolve host 'github.com:gitster' while accessing
          github.com:gitster/git-htmldocs.git/info/refs
          fatal: HTTP request failed
      
      The right solution would probably be to dedicate a separate field to store
      the detected external helper to be used, which is valid only during a
      single use of transport until it is disconnected, instead of overwriting
      foreign_vcs field, but in the meantime, this band-aid should suffice.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dad0b3d8
  20. 21 8月, 2011 1 次提交
  21. 10 3月, 2011 2 次提交
  22. 09 3月, 2011 1 次提交
    • J
      add packet tracing debug code · bbc30f99
      Jeff King 提交于
      This shows a trace of all packets coming in or out of a given
      program. This can help with debugging object negotiation or
      other protocol issues.
      
      To keep the code changes simple, we operate at the lowest
      level, meaning we don't necessarily understand what's in the
      packets. The one exception is a packet starting with "PACK",
      which causes us to skip that packet and turn off tracing
      (since the gigantic pack data will not be interesting to
      read, at least not in the trace format).
      
      We show both written and read packets. In the local case,
      this may mean you will see packets twice (written by the
      sender and read by the receiver). However, for cases where
      the other end is remote, this allows you to see the full
      conversation.
      
      Packet tracing can be enabled with GIT_TRACE_PACKET=<foo>,
      where <foo> takes the same arguments as GIT_TRACE.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bbc30f99
  23. 03 3月, 2011 2 次提交
  24. 17 2月, 2011 1 次提交
    • J
      push.default: Rename 'tracking' to 'upstream' · 53c40311
      Johan Herland 提交于
      Users are sometimes confused with two different types of "tracking" behavior
      in Git: "remote-tracking" branches (e.g. refs/remotes/*/*) versus the
      merge/rebase relationship between a local branch and its @{upstream}
      (controlled by branch.foo.remote and branch.foo.merge config settings).
      
      When the push.default is set to 'tracking', it specifies that a branch should
      be pushed to its @{upstream} branch. In other words, setting push.default to
      'tracking' applies only to the latter of the above two types of "tracking"
      behavior.
      
      In order to make this more understandable to the user, we rename the
      push.default == 'tracking' option to push.default == 'upstream'.
      
      push.default == 'tracking' is left as a deprecated synonym for 'upstream'.
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      53c40311
  25. 13 8月, 2010 1 次提交
  26. 03 8月, 2010 1 次提交
  27. 23 2月, 2010 1 次提交
    • L
      Move 'builtin-*' into a 'builtin/' subdirectory · 81b50f3c
      Linus Torvalds 提交于
      This shrinks the top-level directory a bit, and makes it much more
      pleasant to use auto-completion on the thing. Instead of
      
      	[torvalds@nehalem git]$ em buil<tab>
      	Display all 180 possibilities? (y or n)
      	[torvalds@nehalem git]$ em builtin-sh
      	builtin-shortlog.c     builtin-show-branch.c  builtin-show-ref.c
      	builtin-shortlog.o     builtin-show-branch.o  builtin-show-ref.o
      	[torvalds@nehalem git]$ em builtin-shor<tab>
      	builtin-shortlog.c  builtin-shortlog.o
      	[torvalds@nehalem git]$ em builtin-shortlog.c
      
      you get
      
      	[torvalds@nehalem git]$ em buil<tab>		[type]
      	builtin/   builtin.h
      	[torvalds@nehalem git]$ em builtin		[auto-completes to]
      	[torvalds@nehalem git]$ em builtin/sh<tab>	[type]
      	shortlog.c     shortlog.o     show-branch.c  show-branch.o  show-ref.c     show-ref.o
      	[torvalds@nehalem git]$ em builtin/sho		[auto-completes to]
      	[torvalds@nehalem git]$ em builtin/shor<tab>	[type]
      	shortlog.c  shortlog.o
      	[torvalds@nehalem git]$ em builtin/shortlog.c
      
      which doesn't seem all that different, but not having that annoying
      break in "Display all 180 possibilities?" is quite a relief.
      
      NOTE! If you do this in a clean tree (no object files etc), or using an
      editor that has auto-completion rules that ignores '*.o' files, you
      won't see that annoying 'Display all 180 possibilities?' message - it
      will just show the choices instead.  I think bash has some cut-off
      around 100 choices or something.
      
      So the reason I see this is that I'm using an odd editory, and thus
      don't have the rules to cut down on auto-completion.  But you can
      simulate that by using 'ls' instead, or something similar.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      81b50f3c
  28. 30 1月, 2010 1 次提交
  29. 17 1月, 2010 1 次提交
  30. 12 1月, 2010 1 次提交
  31. 31 12月, 2009 1 次提交
  32. 04 12月, 2009 1 次提交