1. 29 5月, 2009 1 次提交
  2. 25 5月, 2009 1 次提交
  3. 20 5月, 2009 1 次提交
    • J
      for-each-ref: fix segfault in copy_email · e64c1b00
      Jeff King 提交于
      You can trigger a segfault in git.git by doing:
      
        git for-each-ref --format='%(taggeremail)' refs/tags/v0.99
      
      The v0.99 tag is special in that it contains no "tagger"
      header.
      
      The bug is obvious in copy_email, which carefully checks to
      make sure the result of a strchr is non-NULL, but only after
      already having used it to perform other work. The fix is to
      move the check up.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e64c1b00
  4. 14 4月, 2009 2 次提交
  5. 08 4月, 2009 4 次提交
    • J
      make get_short_ref a public function · 7c2b3029
      Jeff King 提交于
      Often we want to shorten a full ref name to something "prettier"
      to show a user. For example, "refs/heads/master" is often shown
      simply as "master", or "refs/remotes/origin/master" is shown as
      "origin/master".
      
      Many places in the code use a very simple formula: skip common
      prefixes like refs/heads, refs/remotes, etc. This is codified in
      the prettify_ref function.
      
      for-each-ref has a more correct (but more expensive) approach:
      consider the ref lookup rules, and try shortening as much as
      possible while remaining unambiguous.
      
      This patch makes the latter strategy globally available as
      shorten_unambiguous_ref.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7c2b3029
    • J
      for-each-ref: add "upstream" format field · 8cae19d9
      Jeff King 提交于
      The logic for determining the upstream ref of a branch is
      somewhat complex to perform in a shell script. This patch
      provides a plumbing mechanism for scripts to access the C
      logic used internally by git-status, git-branch, etc.
      
      For example:
      
        $ git for-each-ref \
             --format='%(refname:short) %(upstream:short)' \
             refs/heads/
        master origin/master
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8cae19d9
    • J
      for-each-ref: refactor refname handling · 8db9a4b8
      Jeff King 提交于
      This code handles some special magic like *-deref and the
      :short formatting specifier. The next patch will add another
      field which outputs a ref and wants to use the same code.
      
      This patch splits the "which ref are we outputting" from the
      actual formatting. There should be no behavioral change.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8db9a4b8
    • J
      for-each-ref: refactor get_short_ref function · 3d4ecc0e
      Jeff King 提交于
      This function took a "refinfo" object which is unnecessarily
      restrictive; it only ever looked at the refname field. This
      patch refactors it to take just the ref name as a string.
      
      While we're touching the relevant lines, let's give it
      consistent memory semantics. Previously, some code paths
      would return an allocated string and some would return the
      original string; now it will always return a malloc'd
      string.
      
      This doesn't actually fix a bug or a leak, because
      for-each-ref doesn't clean up its memory, but it makes the
      function a lot less surprising for reuse (which will
      happen in a later patch).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3d4ecc0e
  6. 15 3月, 2009 1 次提交
    • B
      Remove unused assignments · 8e76bf3f
      Benjamin Kramer 提交于
      These variables were always overwritten or the assigned
      value was unused:
      
        builtin-diff-tree.c::cmd_diff_tree(): nr_sha1
        builtin-for-each-ref.c::opt_parse_sort(): sort_tail
        builtin-mailinfo.c::decode_header_bq(): in
        builtin-shortlog.c::insert_one_record(): len
        connect.c::git_connect(): path
        imap-send.c::v_issue_imap_cmd(): n
        pretty.c::pp_user_info(): filler
        remote::parse_refspec_internal(): llen
      Signed-off-by: NBenjamin Kramer <benny.kra@googlemail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8e76bf3f
  7. 27 10月, 2008 1 次提交
  8. 29 9月, 2008 1 次提交
  9. 25 9月, 2008 1 次提交
  10. 06 9月, 2008 1 次提交
    • B
      for-each-ref: `:short` format for `refname` · 7d66f21a
      Bert Wesarg 提交于
      Tries to shorten the refname to a non-ambiguous name.
      
      Szeder Gábor noticed that the git bash completion takes a
      tremendous amount of time to strip leading components from
      heads and tags refs (i.e. refs/heads, refs/tags, ...). He
      proposed a new atom called 'refbasename' which removes at
      most two leading components from the ref name.
      
      I myself, proposed a more dynamic solution, which strips off
      common leading components with the matched pattern.
      
      But the current bash solution and both proposals suffer from
      one mayor problem: ambiguous refs.
      
      A ref is ambiguous, if it resolves to more than one full refs.
      I.e. given the refs refs/heads/xyzzy and refs/tags/xyzzy. The
      (short) ref xyzzy can point to both refs.
      
      ( Note: Its irrelevant whether the referenced objects are the
        same or not. )
      
      This proposal solves this by checking for ambiguity of the
      shorten ref name.
      
      The shortening is done with the same rules for resolving refs
      but in the reverse order. The short name is checked if it
      resolves to a different ref.
      
      To continue the above example, the output would be like this:
      
      heads/xyzzy
      xyzzy
      
      So, if you want just tags, xyzzy is not ambiguous, because it
      will resolve to a tag. If you need the heads you get a also
      a non-ambiguous short form of the ref.
      
      To integrate this new format into the bash completion to get
      only non-ambiguous refs is beyond the scope of this patch.
      Signed-off-by: NBert Wesarg <bert.wesarg@googlemail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7d66f21a
  11. 29 8月, 2008 1 次提交
  12. 21 8月, 2008 1 次提交
  13. 24 7月, 2008 1 次提交
  14. 14 7月, 2008 1 次提交
    • S
      Make usage strings dash-less · 1b1dd23f
      Stephan Beyer 提交于
      When you misuse a git command, you are shown the usage string.
      But this is currently shown in the dashed form.  So if you just
      copy what you see, it will not work, when the dashed form
      is no longer supported.
      
      This patch makes git commands show the dash-less version.
      
      For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh
      generates a dash-less usage string now.
      Signed-off-by: NStephan Beyer <s-beyer@gmx.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1b1dd23f
  15. 26 6月, 2008 1 次提交
  16. 25 2月, 2008 1 次提交
  17. 06 12月, 2007 1 次提交
  18. 12 11月, 2007 2 次提交
  19. 11 11月, 2007 1 次提交
  20. 30 10月, 2007 1 次提交
  21. 03 10月, 2007 2 次提交
  22. 30 9月, 2007 2 次提交
    • A
      Make for-each-ref's grab_date() support per-atom formatting · d392e712
      Andy Parkins 提交于
      grab_date() gets an extra parameter - atomname; this extra parameter is
      checked to see if it has a ":<format>" extra component in it, and if so
      that "<format>" string is passed to parse_date_format() to produce an
      enum date_mode value which is then further passed to show_date().
      
      In short it allows the user of git-for-each-ref to do things like this:
      
       $ git-for-each-ref --format='%(taggerdate:default)' refs/tags/v1.5.2
       Sun May 20 00:30:42 2007 -0700
       $ git-for-each-ref --format='%(taggerdate:relative)' refs/tags/v1.5.2
       4 months ago
       $ git-for-each-ref --format='%(taggerdate:short)' refs/tags/v1.5.2
       2007-05-20
       $ git-for-each-ref --format='%(taggerdate:local)' refs/tags/v1.5.2
       Sun May 20 08:30:42 2007
       $ git-for-each-ref --format='%(taggerdate:iso8601)' refs/tags/v1.5.2
       2007-05-20 00:30:42 -0700
       $ git-for-each-ref --format='%(taggerdate:rfc2822)' refs/tags/v1.5.2
       Sun, 20 May 2007 00:30:42 -0700
      
      The default, when no ":<format>" is specified is ":default", leaving the
      existing behaviour unchanged.
      Signed-off-by: NAndy Parkins <andyparkins@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d392e712
    • A
      Make for-each-ref allow atom names like "<name>:<something>" · b64265ca
      Andy Parkins 提交于
      In anticipation of supplying a per-field date format specifier, this
      patch makes parse_atom() in builtin-for-each-ref.c allow atoms that have
      a valid atom name (as determined by the valid_atom[] table) followed by
      a colon, followed by an arbitrary string.
      
      The arbitrary string is where the format for the atom will be specified.
      
      Note, if different formats are specified for the same atom, multiple
      entries will be made in the used_atoms table to allow them to be
      distinguished by the grab_XXXX() functions.
      Signed-off-by: NAndy Parkins <andyparkins@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b64265ca
  23. 19 9月, 2007 2 次提交
  24. 15 7月, 2007 1 次提交
  25. 08 3月, 2007 1 次提交
    • S
      General const correctness fixes · 3a55602e
      Shawn O. Pearce 提交于
      We shouldn't attempt to assign constant strings into char*, as the
      string is not writable at runtime.  Likewise we should always be
      treating unsigned values as unsigned values, not as signed values.
      
      Most of these are very straightforward.  The only exception is the
      (unnecessary) xstrdup/free in builtin-branch.c for the detached
      head case.  Since this is a user-level interactive type program
      and that particular code path is executed no more than once, I feel
      that the extra xstrdup call is well worth the easy elimination of
      this warning.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      3a55602e
  26. 27 2月, 2007 2 次提交
  27. 21 2月, 2007 1 次提交
    • J
      Mechanical conversion to use prefixcmp() · cc44c765
      Junio C Hamano 提交于
      This mechanically converts strncmp() to use prefixcmp(), but only when
      the parameters match specific patterns, so that they can be verified
      easily.  Leftover from this will be fixed in a separate step, including
      idiotic conversions like
      
          if (!strncmp("foo", arg, 3))
      
        =>
      
          if (!(-prefixcmp(arg, "foo")))
      
      This was done by using this script in px.perl
      
         #!/usr/bin/perl -i.bak -p
         if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) {
                 s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|;
         }
         if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) {
                 s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|;
         }
      
      and running:
      
         $ git grep -l strncmp -- '*.c' | xargs perl px.perl
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cc44c765
  28. 04 2月, 2007 1 次提交
  29. 29 1月, 2007 1 次提交
  30. 21 12月, 2006 1 次提交
    • J
      simplify inclusion of system header files. · 85023577
      Junio C Hamano 提交于
      This is a mechanical clean-up of the way *.c files include
      system header files.
      
       (1) sources under compat/, platform sha-1 implementations, and
           xdelta code are exempt from the following rules;
      
       (2) the first #include must be "git-compat-util.h" or one of
           our own header file that includes it first (e.g. config.h,
           builtin.h, pkt-line.h);
      
       (3) system headers that are included in "git-compat-util.h"
           need not be included in individual C source files.
      
       (4) "git-compat-util.h" does not have to include subsystem
           specific header files (e.g. expat.h).
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      85023577
  31. 19 11月, 2006 1 次提交