1. 05 12月, 2013 1 次提交
    • J
      push: use remote.$name.push as a refmap · ca02465b
      Junio C Hamano 提交于
      Since f2690487 (fetch: opportunistically update tracking refs,
      2013-05-11), we stopped taking a non-storing refspec given on the
      command line of "git fetch" literally, and instead started mapping
      it via remote.$name.fetch refspecs.  This allows
      
          $ git fetch origin master
      
      from the 'origin' repository, which is configured with
      
          [remote "origin"]
              fetch = +refs/heads/*:refs/remotes/origin/*
      
      to update refs/remotes/origin/master with the result, as if the
      command line were
      
          $ git fetch origin +master:refs/remotes/origin/master
      
      to reduce surprises and improve usability.  Before that change, a
      refspec on the command line without a colon was only to fetch the
      history and leave the result in FETCH_HEAD, without updating the
      remote-tracking branches.
      
      When you are simulating a fetch from you by your mothership with a
      push by you into your mothership, instead of having:
      
          [remote "satellite"]
              fetch = +refs/heads/*:refs/remotes/satellite/*
      
      on the mothership repository and running:
      
          mothership$ git fetch satellite
      
      you would have:
      
          [remote "mothership"]
              push = +refs/heads/*:refs/remotes/satellite/*
      
      on your satellite machine, and run:
      
          satellite$ git push mothership
      
      Because we so far did not make the corresponding change to the push
      side, this command:
      
          satellite$ git push mothership master
      
      does _not_ allow you on the satellite to only push 'master' out but
      still to the usual destination (i.e. refs/remotes/satellite/master).
      
      Implement the logic to map an unqualified refspec given on the
      command line via the remote.$name.push refspec.  This will bring a
      bit more symmetry between "fetch" and "push".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ca02465b
  2. 23 7月, 2013 3 次提交
    • J
      push --force-with-lease: tie it all together · 631b5ef2
      Junio C Hamano 提交于
      This teaches the deepest part of the callchain for "git push" (and
      "git send-pack") to enforce "the old value of the ref must be this,
      otherwise fail this push" (aka "compare-and-swap" / "--lockref").
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      631b5ef2
    • J
      push --force-with-lease: implement logic to populate old_sha1_expect[] · 91048a95
      Junio C Hamano 提交于
      This plugs the push_cas_option data collected by the command line
      option parser to the transport system with a new function
      apply_push_cas(), which is called after match_push_refs() has
      already been called.
      
      At this point, we know which remote we are talking to, and what
      remote refs we are going to update, so we can fill in the details
      that may have been missing from the command line, such as
      
       (1) what abbreviated refname the user gave us matches the actual
           refname at the remote; and
      
       (2) which remote-tracking branch in our local repository to read
           the value of the object to expect at the remote.
      
      to populate the old_sha1_expect[] field of each of the remote ref.
      As stated in the documentation, the use of remote-tracking branch
      as the default is a tentative one, and we may come up with a better
      logic as we gain experience.
      
      Still nobody uses this information, which is the topic of the next
      patch.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      91048a95
    • J
      remote.c: add command line option parser for "--force-with-lease" · 28f5d176
      Junio C Hamano 提交于
      Update "git push" and "git send-pack" to parse this commnd line
      option.
      
      The intended sematics is:
      
       * "--force-with-lease" alone, without specifying the details, will
         protect _all_ remote refs that are going to be updated by
         requiring their current value to be the same as some reasonable
         default, unless otherwise specified;
      
       * "--force-with-lease=refname", without specifying the expected
         value, will protect that refname, if it is going to be updated,
         by requiring its current value to be the same as some reasonable
         default.
      
       * "--force-with-lease=refname:value" will protect that refname, if
         it is going to be updated, by requiring its current value to be
         the same as the specified value; and
      
       * "--no-force-with-lease" will cancel all the previous --force-with-lease on the
         command line.
      
      For now, "some reasonable default" is tentatively defined as "the
      value of the remote-tracking branch we have for the ref of the
      remote being updated", and it is an error if we do not have such a
      remote-tracking branch.  But this is known to be fragile, its use is
      not yet recommended, and hopefully we will find more reasonable
      default as we gain experience with this feature.  The manual marks
      the feature as experimental unless the expected value is specified
      explicitly for this reason.
      
      Because the command line options are parsed _before_ we know which
      remote we are pushing to, there needs further processing to the
      parsed data after we instantiate the transport object to:
      
       * expand "refname" given by the user to a full refname to be
         matched with the list of "struct ref" used in match_push_refs()
         and set_ref_status_for_push(); and
      
       * learning the actual local ref that is the remote-tracking branch
         for the specified remote ref.
      
      Further, some processing need to be deferred until we find the set
      of remote refs and match_push_refs() returns in order to find the
      ones that need to be checked after explicit ones have been processed
      for "--force-with-lease" (no specific details).
      
      These post-processing will be the topic of the next patch.
      
      This option was originally called "cas" (for "compare and swap"),
      the name which nobody liked because it was too technical.  The
      second attempt called it "lockref" (because it is conceptually like
      pushing after taking a lock) but the word "lock" was hated because
      it implied that it may reject push by others, which is not the way
      this option works.  This round calls it "force-with-lease".  You
      assume you took the lease on the ref when you fetched to decide what
      the rebased history should be, and you can push back only if the
      lease has not been broken.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28f5d176
  3. 19 7月, 2013 1 次提交
    • M
      fetch: make --prune configurable · 737c5a9c
      Michael Schubert 提交于
      Without "git fetch --prune", remote-tracking branches for a branch
      the other side already has removed will stay forever.  Some people
      want to always run "git fetch --prune".
      
      To accommodate users who want to either prune always or when fetching
      from a particular remote, add two new configuration variables
      "fetch.prune" and "remote.<name>.prune":
      
       - "fetch.prune" allows to enable prune for all fetch operations.
      
       - "remote.<name>.prune" allows to change the behaviour per remote.
      
      The latter will naturally override the former, and the --[no-]prune
      option from the command line will override the configured default.
      
      Since --prune is a potentially destructive operation (Git doesn't
      keep reflogs for deleted references yet), we don't want to prune
      without users consent, so this configuration will not be on by
      default.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NMichael Schubert <mschub@elegosoft.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      737c5a9c
  4. 09 7月, 2013 1 次提交
    • J
      cache.h: move remote/connect API out of it · 47a59185
      Junio C Hamano 提交于
      The definition of "struct ref" in "cache.h", a header file so
      central to the system, always confused me.  This structure is not
      about the local ref used by sha1-name API to name local objects.
      
      It is what refspecs are expanded into, after finding out what refs
      the other side has, to define what refs are updated after object
      transfer succeeds to what values.  It belongs to "remote.h" together
      with "struct refspec".
      
      While we are at it, also move the types and functions related to the
      Git transport connection to a new header file connect.h
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      47a59185
  5. 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
  6. 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
  7. 08 2月, 2013 1 次提交
  8. 23 5月, 2012 1 次提交
  9. 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
  10. 16 10月, 2011 1 次提交
    • C
      fetch: honor the user-provided refspecs when pruning refs · ed43de6e
      Carlos Martín Nieto 提交于
      If the user gave us refspecs on the command line, we should use those
      when deciding whether to prune a ref instead of relying on the
      refspecs in the config.
      
      Previously, running
      
          git fetch --prune origin refs/heads/master:refs/remotes/origin/master
      
      would delete every other ref under the origin namespace because we
      were using the refspec to filter the available refs but using the
      configured refspec to figure out if a ref had been deleted on the
      remote. This is clearly the wrong thing to do.
      
      Change prune_refs and get_stale_heads to simply accept a list of
      references and a list of refspecs. The caller of either function needs
      to decide what refspecs should be used to decide whether a ref is
      stale.
      Signed-off-by: NCarlos Martín Nieto <cmn@elego.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ed43de6e
  11. 13 9月, 2011 1 次提交
  12. 08 6月, 2011 1 次提交
  13. 01 6月, 2010 1 次提交
    • G
      enums: omit trailing comma for portability · 4b05548f
      Gary V. Vaughan 提交于
      Without this patch at least IBM VisualAge C 5.0 (I have 5.0.2) on AIX
      5.1 fails to compile git.
      
      enum style is inconsistent already, with some enums declared on one
      line, some over 3 lines with the enum values all on the middle line,
      sometimes with 1 enum value per line... and independently of that the
      trailing comma is sometimes present and other times absent, often
      mixing with/without trailing comma styles in a single file, and
      sometimes in consecutive enum declarations.
      
      Clearly, omitting the comma is the more portable style, and this patch
      changes all enum declarations to use the portable omitted dangling
      comma style consistently.
      Signed-off-by: NGary V. Vaughan <gary@thewrittenword.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4b05548f
  14. 10 1月, 2010 1 次提交
    • T
      refactor ref status logic for pushing · 20e8b465
      Tay Ray Chuan 提交于
      Move the logic that detects up-to-date and non-fast-forward refs to a
      new function in remote.[ch], set_ref_status_for_push().
      
      Make transport_push() invoke set_ref_status_for_push() before invoking
      the push_refs() implementation. (As a side-effect, the push_refs()
      implementation in transport-helper.c now knows of non-fast-forward
      pushes.)
      
      Removed logic for detecting up-to-date refs from the push_refs()
      implementation in transport-helper.c, as transport_push() has already
      done so for it.
      
      Make cmd_send_pack() invoke set_ref_status_for_push() before invoking
      send_pack(), as transport_push() can't do it for send_pack() here.
      
      Mark the test on the return status of non-fast-forward push to fail.
      Git now exits with success, as transport.c::transport_push() does not
      check for refs with status REF_STATUS_REJECT_NONFASTFORWARD nor does it
      indicate rejected pushes with its return value.
      
      Mark the test for ref status to succeed. As mentioned earlier, refs
      might be marked as non-fast-forwards, triggering the push status
      printing mechanism in transport.c.
      Signed-off-by: NTay Ray Chuan <rctay89@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      20e8b465
  15. 18 11月, 2009 2 次提交
  16. 10 11月, 2009 1 次提交
  17. 10 6月, 2009 1 次提交
  18. 02 6月, 2009 1 次提交
  19. 08 4月, 2009 1 次提交
  20. 28 2月, 2009 1 次提交
    • J
      remote: let guess_remote_head() optionally return all matches · 4229f1fa
      Jay Soffian 提交于
      Determining HEAD is ambiguous since it is done by comparing SHA1s.
      
      In the case of multiple matches we return refs/heads/master if it
      matches, else we return the first match we encounter. builtin-remote
      needs all matches returned to it, so add a flag for it to request such.
      
      To be simple and consistent, the return value is now a copy (including
      peer_ref) of the matching refs.
      
      Originally contributed by Jeff King along with the prior commit as a
      single patch.
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4229f1fa
  21. 26 2月, 2009 4 次提交
    • J
      remote: simplify guess_remote_head() · 6cb4e6cc
      Jay Soffian 提交于
      This function had complications which made it hard to extend.
      
      - It used to do two things: find the HEAD ref, and then find a
        matching ref, optionally returning the former via assignment to a
        passed-in pointer. Since finding HEAD is a one-liner, just have a
        caller do it themselves and pass it as an argument.
      
      - It used to manually search through the ref list for
        refs/heads/master; this can be a one-line call to
        find_ref_by_name.
      
      Originally contributed by Jeff King along with the next commit as a
      single patch.
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6cb4e6cc
    • J
      move locate_head() to remote.c · 8ef51733
      Jay Soffian 提交于
      Move locate_head() to remote.c and rename it to guess_remote_head() to
      more accurately reflect what it does. This is in preparation for being
      able to call it from builtin-remote.c
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8ef51733
    • J
      move duplicated ref_newer() to remote.c · ec8452d5
      Jay Soffian 提交于
      ref_newer() appears to have been copied from builtin-send-pack.c to
      http-push.c via cut and paste. This patch moves the function and its
      helper unmark_and_free() to remote.c. There was a slight difference
      between the two implementations, one used TMP_MARK for the mark, the
      other used 1. Per Jeff King, I went with TMP_MARK as more correct.
      
      This is in preparation for being able to call it from builtin-remote.c
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ec8452d5
    • J
      move duplicated get_local_heads() to remote.c · 454e2025
      Jay Soffian 提交于
      get_local_heads() appears to have been copied from builtin-send-pack.c
      to http-push.c via cut and paste. This patch moves the function and its
      helper one_local_ref() to remote.c.
      
      The two copies of one_local_ref() were not identical. I used the more
      recent version from builtin-send-pack.c after confirming with Jeff King
      that it was an oversight that commit 30affa1e did not update both
      copies.
      
      This is in preparation for being able to call it from builtin-remote.c
      Signed-off-by: NJay Soffian <jaysoffian@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      454e2025
  22. 12 11月, 2008 1 次提交
  23. 18 10月, 2008 1 次提交
  24. 25 9月, 2008 1 次提交
  25. 22 8月, 2008 1 次提交
  26. 03 7月, 2008 1 次提交
    • J
      Refactor "tracking statistics" code used by "git checkout" · 6d21bf96
      Junio C Hamano 提交于
      People seem to like "Your branch is ahead by N commit" report made by
      "git checkout", but the interface into the statistics function was a bit
      clunky.  This splits the function into three parts:
      
       * The core "commit counting" function that takes "struct branch" and
         returns number of commits to show if we are ahead, behind or forked;
      
       * Convenience "stat formating" function that takes "struct branch" and
         formats the report into a given strbuf, using the above function;
      
       * "checkout" specific function that takes "branch_info" (type that is
         internal to checkout implementation), calls the above function and
         print the formatted result.
      
      in the hope that the former two can be more easily reusable.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6d21bf96
  27. 12 5月, 2008 1 次提交
  28. 05 5月, 2008 2 次提交
  29. 27 4月, 2008 1 次提交
  30. 21 4月, 2008 1 次提交
    • P
      Add a remote.*.mirror configuration option · 84bb2dfd
      Paolo Bonzini 提交于
      This patch adds a remote.*.mirror configuration option that,
      when set, automatically puts git-push in --mirror mode for that
      remote.
      
      Furthermore, the option is set automatically by `git remote
      add --mirror'.
      
      The code in remote.c to parse remote.*.skipdefaultupdate
      had a subtle problem: a comment in the code indicated that
      special care was needed for boolean options, but this care was
      not used in parsing the option.  Since I was touching related
      code, I did this fix too.
      
      [jc: and I further fixed up the "ignore boolean" code.]
      Signed-off-by: NPaolo Bonzini <bonzini@gnu.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      84bb2dfd
  31. 19 4月, 2008 1 次提交
  32. 26 3月, 2008 1 次提交
    • D
      Tighten refspec processing · c091b3d4
      Daniel Barkalow 提交于
      This changes the pattern matching code to not store the required final
      / before the *, and then to require each side to be a valid ref (or
      empty). In particular, any refspec that looks like it should be a
      pattern but doesn't quite meet the requirements will be found to be
      invalid as a fallback non-pattern.
      
      This was cherry picked from commit ef00d150 (Tighten refspec processing,
      2008-03-17), and two fix-up commits 46220ca1 (remote.c: Fix overtight
      refspec validation, 2008-03-20) and 7d19da46 (refspec: allow colon-less
      wildcard "refs/category/*", 2008-03-25) squashed in.
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c091b3d4
  33. 23 3月, 2008 1 次提交
    • J
      remote.c: Fix overtight refspec validation · 46220ca1
      Junio C Hamano 提交于
      We tightened the refspec validation code in an earlier commit ef00d150
      (Tighten refspec processing, 2008-03-17) per my suggestion, but the
      suggestion was misguided to begin with and it broke this usage:
      
          $ git push origin HEAD~12:master
      
      The syntax of push refspecs and fetch refspecs are similar in that they
      are both colon separated LHS and RHS (possibly prefixed with a + to
      force), but the similarity ends there.  For example, LHS in a push refspec
      can be anything that evaluates to a valid object name at runtime (except
      when colon and RHS is missing, or it is a glob), while it must be a
      valid-looking refname in a fetch refspec.  To validate them correctly, the
      caller needs to be able to say which kind of refspecs they are.  It is
      unreasonable to keep a single interface that cannot tell which kind it is
      dealing with, and ask it to behave sensibly.
      
      This commit separates the parsing of the two into different functions, and
      clarifies the code to implement the parsing proper (i.e. splitting into
      two parts, making sure both sides are wildcard or neither side is).
      
      This happens to also allow pushing a commit named with the esoteric "look
      for that string" syntax:
      
          $ git push ../test.git ':/remote.c: Fix overtight refspec:master'
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      46220ca1