1. 01 4月, 2017 1 次提交
  2. 16 1月, 2015 1 次提交
  3. 14 1月, 2015 1 次提交
  4. 26 11月, 2014 1 次提交
  5. 16 10月, 2014 1 次提交
  6. 15 10月, 2014 1 次提交
    • J
      checkout: report upstream correctly even with loosely defined branch.*.merge · 05e73682
      Junio C Hamano 提交于
      When checking out a branch that is set to build on top of another
      branch (often, a remote-tracking branch), "git checkout" reports how
      your work relates to the other branch, e.g.
      
          Your branch is behind 'origin/master', and can be fast-forwarded.
      
      Back when this feature was introduced, this was only done for
      branches that build on remote-tracking branches, but 5e6e2b48 (Make
      local branches behave like remote branches when --tracked,
      2009-04-01) added support to give the same report for branches that
      build on other local branches (i.e. branches whose branch.*.remote
      variables are set to '.').  Unlike the support for the branches
      building on remote-tracking branches, however, this did not take
      into account the fact that branch.*.merge configuration is allowed
      to record a shortened branch name.
      
      When branch.*.merge is set to 'master' (not 'refs/heads/master'),
      i.e. "my branch builds on the local 'master' branch", this caused
      "git checkout" to report:
      
          Your branch is based on 'master', but the upstream is gone.
      
      The upstream is our repository and is definitely not gone, so this
      output is nonsense.
      
      The fix is fairly obvious; just like the branch name is DWIMed when
      "git pull" merges from the 'master' branch without complaint on such
      a branch, the name of the branch the current branch builds upon
      needs to be DWIMed the same way.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      05e73682
  7. 23 9月, 2014 1 次提交
  8. 13 8月, 2014 1 次提交
  9. 11 8月, 2014 1 次提交
  10. 31 7月, 2014 1 次提交
    • P
      use a hashmap to make remotes faster · d0da003d
      Patrick Reynolds 提交于
      Remotes are stored as an array, so looking one up or adding one without
      duplication is an O(n) operation.  Reading an entire config file full of
      remotes is O(n^2) in the number of remotes.  For a repository with tens of
      thousands of remotes, the running time can hit multiple minutes.
      
      Hash tables are way faster.  So we add a hashmap from remote name to
      struct remote and use it for all lookups.  The time to add a new remote to
      a repo that already has 50,000 remotes drops from ~2 minutes to < 1
      second.
      
      We retain the old array of remotes so iterators proceed in config-file
      order.
      Signed-off-by: NPatrick Reynolds <patrick.reynolds@github.com>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d0da003d
  11. 21 6月, 2014 1 次提交
    • J
      use skip_prefix to avoid repeating strings · 95b567c7
      Jeff King 提交于
      It's a common idiom to match a prefix and then skip past it
      with strlen, like:
      
        if (starts_with(foo, "bar"))
      	  foo += strlen("bar");
      
      This avoids magic numbers, but means we have to repeat the
      string (and there is no compiler check that we didn't make a
      typo in one of the strings).
      
      We can use skip_prefix to handle this case without repeating
      ourselves.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      95b567c7
  12. 20 6月, 2014 1 次提交
    • J
      use xstrfmt in favor of manual size calculations · fa3f60b7
      Jeff King 提交于
      In many parts of the code, we do an ugly and error-prone
      malloc like:
      
        const char *fmt = "something %s";
        buf = xmalloc(strlen(foo) + 10 + 1);
        sprintf(buf, fmt, foo);
      
      This makes the code brittle, and if we ever get the
      allocation wrong, is a potential heap overflow. Let's
      instead favor xstrfmt, which handles the allocation
      automatically, and makes the code shorter and more readable.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fa3f60b7
  13. 10 6月, 2014 1 次提交
  14. 28 5月, 2014 1 次提交
  15. 01 4月, 2014 1 次提交
  16. 27 3月, 2014 1 次提交
  17. 06 3月, 2014 3 次提交
    • J
      push: detect local refspec errors early · ba928c13
      Jeff King 提交于
      When pushing, we do not even look at our push refspecs until
      after we have made contact with the remote receive-pack and
      gotten its list of refs. This means that we may go to some
      work, including asking the user to log in, before realizing
      we have simple errors like "git push origin matser".
      
      We cannot catch all refspec problems, since fully evaluating
      the refspecs requires knowing what the remote side has. But
      we can do a quick sanity check of the local side and catch a
      few simple error cases.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ba928c13
    • J
      match_explicit_lhs: allow a "verify only" mode · 471fd3fe
      Jeff King 提交于
      The match_explicit_lhs function has all of the logic
      necessary to verify the refspecs without actually doing any
      work. This patch lets callers pass a NULL "match" pointer to
      indicate they want a "verify only" operation.
      
      For the most part, we just need to avoid writing to the NULL
      pointer. However, we also have to refactor the
      try_explicit_object_name sub-function; it indicates success by
      allocating and returning a new ref. Instead, we give it an
      "out" parameter for the match and return a numeric status.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      471fd3fe
    • J
      match_explicit: hoist refspec lhs checks into their own function · f7ade3d3
      Jeff King 提交于
      In preparation for being able to check the left-hand side of
      our push refspecs separately, this pulls the examination of
      them out into its own function. There should be no behavior
      change.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f7ade3d3
  18. 25 2月, 2014 1 次提交
    • J
      remote: handle pushremote config in any order · 98b406f3
      Jeff King 提交于
      The remote we push can be defined either by
      remote.pushdefault or by branch.*.pushremote for the current
      branch. The order in which they appear in the config file
      should not matter to precedence (which should be to prefer
      the branch-specific config).
      
      The current code parses the config linearly and uses a
      single string to store both values, overwriting any
      previous value. Thus, config like:
      
        [branch "master"]
        pushremote = foo
        [remote]
        pushdefault = bar
      
      erroneously ends up pushing to "bar" from the master branch.
      
      We can fix this by storing both values and resolving the
      correct value after all config is read.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      98b406f3
  19. 15 1月, 2014 1 次提交
  20. 06 12月, 2013 1 次提交
    • C
      replace {pre,suf}fixcmp() with {starts,ends}_with() · 59556548
      Christian Couder 提交于
      Leaving only the function definitions and declarations so that any
      new topic in flight can still make use of the old functions, replace
      existing uses of the prefixcmp() and suffixcmp() with new API
      functions.
      
      The change can be recreated by mechanically applying this:
      
          $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
            grep -v strbuf\\.c |
            xargs perl -pi -e '
              s|!prefixcmp\(|starts_with\(|g;
              s|prefixcmp\(|!starts_with\(|g;
              s|!suffixcmp\(|ends_with\(|g;
              s|suffixcmp\(|!ends_with\(|g;
            '
      
      on the result of preparatory changes in this series.
      Signed-off-by: NChristian Couder <chriscool@tuxfamily.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      59556548
  21. 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
  22. 31 10月, 2013 8 次提交
  23. 16 10月, 2013 1 次提交
    • J
      remote: do not copy "origin" string literal · 11a6ba1c
      Jeff King 提交于
      Our default_remote_name starts at "origin", but may be
      overridden by the config file. In the former case, we
      allocate a new string, but in the latter case, we point to
      the remote name in an existing "struct branch".
      
      This gives the variable inconsistent free() semantics (we
      are sometimes responsible for freeing the string and
      sometimes pointing to somebody else's storage), and causes a
      small leak when the allocated string is overridden by
      config.
      
      We can fix both by simply dropping the extra copy and
      pointing to the string literal.
      Noticed-by: NFelipe Contreras <felipe.contreras@gmail.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      11a6ba1c
  24. 27 8月, 2013 2 次提交
    • J
      status: always show tracking branch even no change · f223459b
      Jiang Xin 提交于
      In order to see what the current branch is tracking, one way is using
      "git branch -v -v", but branches other than the current are also
      reported. Another way is using "git status", such as:
      
          $ git status
          # On branch master
          # Your branch is ahead of 'origin/master' by 1 commit.
          ...
      
      But this will not work if there is no change between the current
      branch and its upstream. Always report upstream tracking info
      even if there is no difference, so that "git status" is consistent
      for checking tracking info for current branch. E.g.
      
          $ git status
          # On branch feature1
          # Your branch is up-to-date with 'github/feature1'.
          ...
      
          $ git status -bs
          ## feature1...github/feature1
          ...
      
          $ git checkout feature1
          Already on 'feature1'
          Your branch is up-to-date with 'github/feature1'.
          ...
      
      Also add some test cases in t6040.
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f223459b
    • J
      branch: report invalid tracking branch as gone · f2e08739
      Jiang Xin 提交于
      Command "git branch -vv" will report tracking branches, but invalid
      tracking branches are also reported. This is because the function
      stat_tracking_info() can not distinguish invalid tracking branch
      from other cases which it would not like to report, such as
      there is no upstream settings at all, or nothing is changed between
      one branch and its upstream.
      
      Junio suggested missing upstream should be reported [1] like:
      
          $ git branch -v -v
            master    e67ac84 initial
          * topic     3fc0f2a [topicbase: gone] topic
      
          $ git status
          # On branch topic
          # Your branch is based on 'topicbase', but the upstream is gone.
          #   (use "git branch --unset-upstream" to fixup)
          ...
      
          $ git status -b -s
          ## topic...topicbase [gone]
          ...
      
      In order to do like that, we need to distinguish these three cases
      (i.e. no tracking, with configured but no longer valid tracking, and
      with tracking) in function stat_tracking_info(). So the refactored
      function stat_tracking_info() has three return values: -1 (with "gone"
      base), 0 (no base), and 1 (with base).
      
      If the caller does not like to report tracking info when nothing
      changed between the branch and its upstream, simply checks if
      num_theirs and num_ours are both 0.
      
      [1]: http://thread.gmane.org/gmane.comp.version-control.git/231830/focus=232288Suggested-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f2e08739
  25. 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
  26. 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
  27. 09 7月, 2013 2 次提交
    • 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
    • B
      remote.c: avoid O(m*n) behavior in match_push_refs · f1bd15ab
      Brandon Casey 提交于
      When pushing using a matching refspec or a pattern refspec, each ref
      in the local repository must be paired with a ref advertised by the
      remote server.  This is accomplished by using the refspec to transform
      the name of the local ref into the name it should have in the remote
      repository, and then performing a linear search through the list of
      remote refs to see if the remote ref was advertised by the remote
      system.
      
      Each of these lookups has O(n) complexity and makes match_push_refs()
      be an O(m*n) operation, where m is the number of local refs and n is
      the number of remote refs.  If there are many refs 100,000+, then this
      ref matching can take a significant amount of time.  Let's prepare an
      index of the remote refs to allow searching in O(log n) time and
      reduce the complexity of match_push_refs() to O(m log n).
      
      We prepare the index lazily so that it is only created when necessary.
      So, there should be no impact when _not_ using a matching or pattern
      refspec, i.e. when pushing using only explicit refspecs.
      
      Dry-run push of a repository with 121,913 local and remote refs:
      
              before     after
      real    1m40.582s  0m0.804s
      user    1m39.914s  0m0.515s
      sys     0m0.125s   0m0.106s
      
      The creation of the index has overhead.  So, if there are very few
      local refs, then it could take longer to create the index than it
      would have taken to just perform n linear lookups into the remote
      ref space.  Using the index should provide some improvement when
      the number of local refs is roughly greater than the log of the
      number of remote refs (i.e. m >= log n).  The pathological case is
      when there is a single local ref and very many remote refs.
      
      Dry-run push of a repository with 121,913 remote refs and a single
      local ref:
      
              before    after
      real    0m0.525s  0m0.566s
      user    0m0.243s  0m0.279s
      sys     0m0.075s  0m0.099s
      
      Using an index takes 41 ms longer, or roughly 7.8% longer.
      
      Jeff King measured a no-op push of a single ref into a remote repo
      with 370,000 refs:
      
              before    after
      real    0m1.087s  0m1.156s
      user    0m1.344s  0m1.412s
      sys     0m0.288s  0m0.284s
      
      Using an index takes 69 ms longer, or roughly 6.3% longer.
      
      None of the measurements above required transferring any objects to
      the remote repository.  If the push required transferring objects and
      updating the refs in the remote repository, the impact of preparing
      the search index would be even smaller.
      
      A similar operation is performed in the reverse direction when pruning
      using a matching or pattern refspec.  Let's avoid O(m*n) behavior in
      the same way by lazily preparing an index on the local refs.
      Signed-off-by: NBrandon Casey <drafnel@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f1bd15ab