1. 04 8月, 2015 2 次提交
  2. 16 6月, 2015 8 次提交
  3. 26 5月, 2015 2 次提交
  4. 23 5月, 2015 3 次提交
    • J
      for-each-ref: accept "%(push)" format · 29bc8850
      Jeff King 提交于
      Just as we have "%(upstream)" to report the "@{upstream}"
      for each ref, this patch adds "%(push)" to match "@{push}".
      It supports the same tracking format modifiers as upstream
      (because you may want to know, for example, which branches
      have commits to push).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      29bc8850
    • J
      for-each-ref: use skip_prefix instead of starts_with · 3dbe9db0
      Jeff King 提交于
      This saves us having to maintain a magic number to skip past
      the matched prefix.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3dbe9db0
    • J
      remote.c: return upstream name from stat_tracking_info · 979cb245
      Jeff King 提交于
      After calling stat_tracking_info, callers often want to
      print the name of the upstream branch (in addition to the
      tracking count). To do this, they have to access
      branch->merge->dst[0] themselves. This is not wrong, as the
      return value from stat_tracking_info tells us whether we
      have an upstream branch or not. But it is a bit leaky, as we
      make an assumption about how it calculated the upstream
      name.
      
      Instead, let's add an out-parameter that lets the caller
      know the upstream name we found.
      
      As a bonus, we can get rid of the unusual tri-state return
      from the function. We no longer need to use it to
      differentiate between "no tracking config" and "tracking ref
      does not exist" (since you can check the upstream_name for
      that), so we can just use the usual 0/-1 convention for
      success/error.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      979cb245
  5. 22 5月, 2015 2 次提交
    • J
      remote.c: report specific errors from branch_get_upstream · 3a429d0a
      Jeff King 提交于
      When the previous commit introduced the branch_get_upstream
      helper, there was one call-site that could not be converted:
      the one in sha1_name.c, which gives detailed error messages
      for each possible failure.
      
      Let's teach the helper to optionally report these specific
      errors. This lets us convert another callsite, and means we
      can use the helper in other locations that want to give the
      same error messages.
      
      The logic and error messages come straight from sha1_name.c,
      with the exception that we start each error with a lowercase
      letter, as is our usual style (note that a few tests need
      updated as a result).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3a429d0a
    • J
      remote.c: introduce branch_get_upstream helper · a9f9f8cc
      Jeff King 提交于
      All of the information needed to find the @{upstream} of a
      branch is included in the branch struct, but callers have to
      navigate a series of possible-NULL values to get there.
      Let's wrap that logic up in an easy-to-read helper.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a9f9f8cc
  6. 23 2月, 2015 1 次提交
  7. 15 1月, 2015 1 次提交
  8. 13 1月, 2015 1 次提交
    • R
      for-each-ref: always check stat_tracking_info()'s return value · b6160d95
      Raphael Kubo da Costa 提交于
      The code handling %(upstream:track) and %(upstream:trackshort)
      assumed that it always had a valid branch that had been sanitized
      earlier in populate_value(), and thus did not check the return value
      of the call to stat_tracking_info().
      
      While there is indeed some sanitization code that basically
      corresponds to stat_tracking_info() returning 0 (no base branch
      set), the function can also return -1 when the base branch did exist
      but has since then been deleted.
      
      In this case, num_ours and num_theirs had undefined values and a
      call to `git for-each-ref --format="%(upstream:track)"` could print
      spurious values such as
      
        [behind -111794512]
        [ahead 38881640, behind 5103867]
      
      even for repositories with one single commit.
      
      Verify stat_tracking_info()'s return value and do not print anything
      if it returns -1. This behavior also matches the documentation ("has
      no effect if the ref does not have tracking information associated
      with it").
      Helped-by: NEric Sunshine <sunshine@sunshineco.com>
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NRaphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b6160d95
  9. 01 12月, 2014 1 次提交
  10. 16 10月, 2014 2 次提交
  11. 15 10月, 2014 1 次提交
    • J
      color_parse: do not mention variable name in error message · f6c5a296
      Jeff King 提交于
      Originally the color-parsing function was used only for
      config variables. It made sense to pass the variable name so
      that the die() message could be something like:
      
        $ git -c color.branch.plain=bogus branch
        fatal: bad color value 'bogus' for variable 'color.branch.plain'
      
      These days we call it in other contexts, and the resulting
      error messages are a little confusing:
      
        $ git log --pretty='%C(bogus)'
        fatal: bad color value 'bogus' for variable '--pretty format'
      
        $ git config --get-color foo.bar bogus
        fatal: bad color value 'bogus' for variable 'command line'
      
      This patch teaches color_parse to complain only about the
      value, and then return an error code. Config callers can
      then propagate that up to the config parser, which mentions
      the variable name. Other callers can provide a custom
      message. After this patch these three cases now look like:
      
        $ git -c color.branch.plain=bogus branch
        error: invalid color value: bogus
        fatal: unable to parse 'color.branch.plain' from command-line config
      
        $ git log --pretty='%C(bogus)'
        error: invalid color value: bogus
        fatal: unable to parse --pretty format
      
        $ git config --get-color foo.bar bogus
        error: invalid color value: bogus
        fatal: unable to parse default color value
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f6c5a296
  12. 19 9月, 2014 1 次提交
  13. 04 9月, 2014 1 次提交
  14. 18 7月, 2014 1 次提交
  15. 10 6月, 2014 1 次提交
  16. 21 2月, 2014 1 次提交
  17. 31 12月, 2013 1 次提交
  18. 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
  19. 20 11月, 2013 3 次提交
  20. 19 11月, 2013 1 次提交
  21. 31 10月, 2013 1 次提交
    • J
      for-each-ref: avoid loading objects to print %(objectname) · b74cf648
      Jeff King 提交于
      If you ask for-each-ref to print each ref and its object,
      like:
      
        git for-each-ref --format='%(objectname) %(refname)'
      
      this should involve little more work than looking at the ref
      files (and packed-refs) themselves. However, for-each-ref
      will actually load each object from disk just to print its
      sha1. For most repositories, this isn't a big deal, but it
      can be noticeable if you have a large number of refs to
      print. Here are best-of-five timings for the command above
      on a repo with ~10K refs:
      
        [before]
        real    0m0.112s
        user    0m0.092s
        sys     0m0.016s
      
        [after]
        real    0m0.014s
        user    0m0.012s
        sys     0m0.000s
      
      This patch checks for %(objectname) and %(objectname:short)
      before we actually parse the object (and the rest of the
      code is smart enough to avoid parsing if we have filled all
      of our placeholders).
      
      Note that we can't simply move the objectname parsing code
      into the early loop. If the "deref" form %(*objectname) is
      used, then we do need to parse the object in order to peel
      the tag. So instead of moving the code, we factor it out
      into a separate function that can be called for both cases.
      
      While we're at it, we add some basic tests for the
      dereferenced placeholders, which were not tested at all
      before. This helps ensure we didn't regress that case.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b74cf648
  22. 30 7月, 2013 1 次提交
  23. 22 8月, 2012 1 次提交
  24. 21 8月, 2012 1 次提交
  25. 14 12月, 2011 1 次提交