1. 20 10月, 2009 1 次提交
    • T
      Refactor pretty_print_commit arguments into a struct · dd2e794a
      Thomas Rast 提交于
      pretty_print_commit() has a bunch of rarely-used arguments, and
      introducing more of them requires yet another update of all the call
      sites.  Refactor most of them into a struct to make future extensions
      easier.
      
      The ones that stay "plain" arguments were chosen on the grounds that
      all callers put real arguments there, whereas some callers have 0/NULL
      for all arguments that were factored into the struct.
      
      We declare the struct 'const' to ensure none of the callers are bitten
      by the changed (no longer call-by-value) semantics.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dd2e794a
  2. 05 10月, 2009 1 次提交
    • J
      show-branch: fix segfault when showbranch.default exists · 3af1cae4
      Junio C Hamano 提交于
      When running "git show-branch" without any parameter in a repository that
      has showbranch.default defined, we used to rely on the fact that our
      handcrafted option parsing loop never looked at av[0].
      
      The array of default strings had the first real command line argument in
      default_arg[0], but the option parser wanted to look at the array starting
      at av[1], so we assigned the address of -1th element to av to force the
      loop start working from default_arg[0].
      
      This no longer worked since 57343652 (show-branch: migrate to parse-options
      API, 2009-05-21), as parse_options_start() saved the incoming &av[0] in
      its ctx->out and later in parse_options_end() it did memmove to ctx->out
      (with ctx->cpidx == 0), overwriting the memory before default_arg[] array.
      
      I am not sure if this is a bug in parse_options(), or a bug in the caller,
      and tonight I do not have enough concentration to figure out which.  In
      any case, this patch works the issue around.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3af1cae4
  3. 06 8月, 2009 2 次提交
  4. 09 6月, 2009 1 次提交
  5. 25 5月, 2009 1 次提交
  6. 23 5月, 2009 1 次提交
  7. 18 5月, 2009 1 次提交
  8. 23 4月, 2009 1 次提交
  9. 24 3月, 2009 1 次提交
  10. 13 10月, 2008 1 次提交
  11. 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
  12. 27 5月, 2008 1 次提交
  13. 15 5月, 2008 1 次提交
  14. 12 2月, 2008 1 次提交
  15. 08 11月, 2007 1 次提交
    • J
      format-patch -s: add MIME encoding header if signer's name requires so · acef41c9
      Junio C Hamano 提交于
      When the body of the commit log message contains a non-ASCII character,
      format-patch correctly emitted the encoding header to mark the resulting
      message as such.  However, if the original message was fully ASCII, the
      command line switch "-s" was given to add a new sign-off, and
      the signer's name was not ASCII only, the resulting message would have
      contained non-ASCII character but was not marked as such.
      
      This was cherry-picked from the fix in 'master'
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      acef41c9
  16. 02 11月, 2007 1 次提交
    • J
      format-patch -s: add MIME encoding header if signer's name requires so · 4593fb84
      Junio C Hamano 提交于
      When the body of the commit log message contains a non-ASCII character,
      format-patch correctly emitted the encoding header to mark the resulting
      message as such.  However, if the original message was fully ASCII, the
      command line switch "-s" was given to add a new sign-off, and
      the signer's name was not ASCII only, the resulting message would have
      contained non-ASCII character but was not marked as such.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4593fb84
  17. 11 9月, 2007 1 次提交
  18. 13 6月, 2007 1 次提交
    • J
      Lift 16kB limit of log message output · 80583c0e
      Junio C Hamano 提交于
      Traditionally we had 16kB limit when formatting log messages for
      output, because it was easier to arrange for the caller to have
      a reasonably big buffer and pass it down without ever worrying
      about reallocating.
      
      This changes the calling convention of pretty_print_commit() to
      lift this limit.  Instead of the buffer and remaining length, it
      now takes a pointer to the pointer that points at the allocated
      buffer, and another pointer to the location that stores the
      allocated length, and reallocates the buffer as necessary.
      
      To support the user format, the error return of interpolate()
      needed to be changed.  It used to return a bool telling "Ok the
      result fits", or "Sorry, I had to truncate it".  Now it returns
      0 on success, and returns the size of the buffer it wants in
      order to fit the whole result.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      80583c0e
  19. 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
  20. 21 2月, 2007 3 次提交
    • J
      prefixcmp(): fix-up leftover strncmp(). · 1968d77d
      Junio C Hamano 提交于
      There were instances of strncmp() that were formatted improperly
      (e.g. whitespace around parameter before closing parenthesis)
      that caused the earlier mechanical conversion step to miss
      them.  This step cleans them up.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      1968d77d
    • J
      prefixcmp(): fix-up mechanical conversion. · 599065a3
      Junio C Hamano 提交于
      Previous step converted use of strncmp() with literal string
      mechanically even when the result is only used as a boolean:
      
          if (!strncmp("foo", arg, 3)) ==> if (!(-prefixcmp(arg, "foo")))
      
      This step manually cleans them up to read:
      
          if (!prefixcmp(arg, "foo"))
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      599065a3
    • 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
  21. 04 2月, 2007 1 次提交
  22. 26 1月, 2007 1 次提交
  23. 25 1月, 2007 1 次提交
  24. 21 1月, 2007 1 次提交
  25. 20 1月, 2007 2 次提交
    • J
      show-branch --reflog: tighten input validation. · b15af079
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      b15af079
    • J
      show-branch --reflog: show the reflog message at the top. · 76a44c5c
      Junio C Hamano 提交于
      This changes the output so the list at the top shows the reflog
      message, along with their relative timestamps.
      
      You can use --reflog=<n> to show <n> most recent log entries, or
      use --reflog=<n>,<b> to show <n> entries going back from the
      entry <b>.  <b> can be either a number (so --reflog=4,20 shows 4
      records starting from @{20}) or a timestamp (e.g. --reflog='4,1 day').
      
      Here is a sample output (with --list option):
      
        $ git show-branch --reflog=10 --list jc/show-reflog
          [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
          [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
          [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog: sho
          [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog: sho
          [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_ref_a
          [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read_ref_a
          [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend read_ref_a
          [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow retrievi
          [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
          [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --reflog: use
      
      This shows what I did more cleanly:
      
        $ git show-branch --reflog=10 jc/show-reflog
        ! [jc/show-reflog@{0}] (3 minutes ago) commit (amend): show-branch --ref
         ! [jc/show-reflog@{1}] (5 minutes ago) reset HEAD^
          ! [jc/show-reflog@{2}] (14 minutes ago) commit: show-branch --reflog:
           ! [jc/show-reflog@{3}] (14 minutes ago) commit: show-branch --reflog:
            ! [jc/show-reflog@{4}] (18 minutes ago) commit (amend): Extend read_
             ! [jc/show-reflog@{5}] (18 minutes ago) commit (amend): Extend read
              ! [jc/show-reflog@{6}] (18 minutes ago) commit (amend): Extend rea
               ! [jc/show-reflog@{7}] (18 minutes ago) am: read_ref_at(): allow
                ! [jc/show-reflog@{8}] (18 minutes ago) reset --hard HEAD~4
                 ! [jc/show-reflog@{9}] (61 minutes ago) commit: show-branch --r
        ----------
        +          [jc/show-reflog@{0}] show-branch --reflog: show the reflog
          +        [jc/show-reflog@{2}] show-branch --reflog: show the reflog
         +++       [jc/show-reflog@{1}] show-branch --reflog: show the reflog
        +++++      [jc/show-reflog@{4}] Extend read_ref_at() to be usable fro
             +     [jc/show-reflog@{5}] Extend read_ref_at() to be usable fro
              +    [jc/show-reflog@{6}] Extend read_ref_at() to be usable fro
               +   [jc/show-reflog@{7}] read_ref_at(): allow retrieving the r
                 + [jc/show-reflog@{9}] show-branch --reflog: use updated rea
                 + [jc/show-reflog@{9}^] read_ref_at(): allow reporting the c
                 + [jc/show-reflog@{9}~2] show-branch --reflog: show the refl
                 + [jc/show-reflog@{9}~3] read_ref_at(): allow retrieving the
        ++++++++++ [jc/show-reflog@{8}] dwim_ref(): Separate name-to-ref DWIM
      
      At @{9}, I had a commit to complete 5 patch series, but I wanted
      to consolidate two commits that enhances read_ref_at() into one
      (they were @{9}^ and @{9}~3), and another two that touch show-branch
      into one (@{9} and @{9}~2).
      
      I first saved them with "format-patch -4", and then did a reset
      at @{8}.  At @{7}, I applied one of them with "am", and then
      used "git-apply" on the other one, and amended the commit at
      @{6} (so @{6} and @{7} has the same parent).  I did not like the
      log message, so I amended again at @{5}.
      
      Then I cherry-picked @{9}~2 to create @{3} (the log message
      shows that it needs to learn to set GIT_REFLOG_ACTION -- it uses
      "git-commit" and the log entry is attributed for it).  Another
      cherry-pick built @{2} out of @{9}, but what I wanted to do was
      to squash these two into one, so I did a "reset HEAD^" at @{1}
      and then made the final commit by amending what was at the top.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      76a44c5c
  26. 23 12月, 2006 1 次提交
  27. 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
  28. 18 12月, 2006 1 次提交
  29. 22 9月, 2006 1 次提交
  30. 21 9月, 2006 2 次提交
    • J
      Tell between packed, unpacked and symbolic refs. · 8da19775
      Junio C Hamano 提交于
      This adds a "int *flag" parameter to resolve_ref() and makes
      for_each_ref() family to call callback function with an extra
      "int flag" parameter.  They are used to give two bits of
      information (REF_ISSYMREF and REF_ISPACKED) about the ref.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      8da19775
    • J
      Add callback data to for_each_ref() family. · cb5d709f
      Junio C Hamano 提交于
      This is a long overdue fix to the API for for_each_ref() family
      of functions.  It allows the callers to specify a callback data
      pointer, so that the caller does not have to use static
      variables to communicate with the callback funciton.
      
      The updated for_each_ref() family takes a function of type
      
      	int (*fn)(const char *, const unsigned char *, void *)
      
      and a void pointer as parameters, and calls the function with
      the name of the ref and its SHA-1 with the caller-supplied void
      pointer as parameters.
      
      The commit updates two callers, builtin-name-rev.c and
      builtin-pack-refs.c as an example.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cb5d709f
  31. 18 9月, 2006 1 次提交
    • L
      Make ref resolution saner · ed378ec7
      Linus Torvalds 提交于
      The old code used to totally mix up the notion of a ref-name and the path
      that that ref was associated with.  That was not only horribly ugly (a
      number of users got the path, and then wanted to try to turn it back into
      a ref-name again), but it fundamnetally doesn't work at all once we do any
      setup where a ref doesn't have a 1:1 relationship with a particular
      pathname.
      
      This fixes things up so that we use the ref-name throughout, and only
      turn it into a pathname once we actually look it up in the filesystem.
      That makes a lot of things much clearer and more straightforward.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ed378ec7
  32. 02 9月, 2006 1 次提交
    • S
      Replace uses of strdup with xstrdup. · 9befac47
      Shawn Pearce 提交于
      Like xmalloc and xrealloc xstrdup dies with a useful message if
      the native strdup() implementation returns NULL rather than a
      valid pointer.
      
      I just tried to use xstrdup in new code and found it to be missing.
      However I expected it to be present as xmalloc and xrealloc are
      already commonly used throughout the code.
      
      [jc: removed the part that deals with last_XXX, which I am
       finding more and more dubious these days.]
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      9befac47
  33. 29 8月, 2006 1 次提交
  34. 18 8月, 2006 1 次提交
  35. 16 8月, 2006 1 次提交