Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Fri, 23 May 2008 23:05:46 +0000 (16:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 May 2008 23:05:46 +0000 (16:05 -0700)
* maint:
rev-parse --symbolic-full-name: don't print '^' if SHA1 is not a ref
Add missing "short" alternative to --date in rev-list-options.txt
git-show.txt: Not very stubby these days.
Clarify repack -n documentation

1  2 
Documentation/rev-list-options.txt
builtin-rev-parse.c
index 3558348b720aa62d6a34719daed5fb623a10501d,9cd677105df1324cfa760e42f10b2629f5eb6962..dfcef79a6b772ae5fb11fc378772042ba465615f
@@@ -13,11 -13,10 +13,11 @@@ include::pretty-options.txt[
  
        Synonym for `--date=relative`.
  
- --date={relative,local,default,iso,rfc}::
+ --date={relative,local,default,iso,rfc,short}::
  
        Only takes effect for dates shown in human-readable format, such
 -      as when using "--pretty".
 +      as when using "--pretty". `log.date` config variable sets a default
 +      value for log command's --date option.
  +
  `--date=relative` shows dates relative to the current time,
  e.g. "2 hours ago".
@@@ -76,16 -75,6 +76,16 @@@ you would get an output line this
        -xxxxxxx... 1st on a
  -----------------------------------------------------------------------
  
 +--graph::
 +
 +      Draw a text-based graphical representation of the commit history
 +      on the left hand side of the output.  This may cause extra lines
 +      to be printed in between commits, in order for the graph history
 +      to be drawn properly.
 ++
 +This implies the '--topo-order' option by default, but the
 +'--date-order' option may also be specified.
 +
  Diff Formatting
  ~~~~~~~~~~~~~~~
  
diff --combined builtin-rev-parse.c
index f8d8548e9cddd7d2d123fcf0fdee513754df86c1,00b607824dda2dab1c1ffb8bfdbd0972baa44ec5..ab3e85054e174d2d328c625f1db744854b62f5f7
@@@ -28,6 -28,8 +28,6 @@@ static int symbolic
  static int abbrev;
  static int output_sq;
  
 -static int revs_count;
 -
  /*
   * Some arguments are relevant "revision" arguments,
   * others are about output format or other details.
@@@ -94,15 -96,22 +94,21 @@@ static void show(const char *arg
                puts(arg);
  }
  
+ /* Like show(), but with a negation prefix according to type */
+ static void show_with_type(int type, const char *arg)
+ {
+       if (type != show_type)
+               putchar('^');
+       show(arg);
+ }
  /* Output a revision, only if filter allows it */
  static void show_rev(int type, const unsigned char *sha1, const char *name)
  {
        if (!(filter & DO_REVS))
                return;
        def = NULL;
 -      revs_count++;
  
-       if (type != show_type)
-               putchar('^');
        if (symbolic && name) {
                if (symbolic == SHOW_SYMBOLIC_FULL) {
                        unsigned char discard[20];
                                 */
                                break;
                        case 1: /* happy */
-                               show(full);
+                               show_with_type(type, full);
                                break;
                        default: /* ambiguous */
                                error("refname '%s' is ambiguous", name);
                                break;
                        }
                } else {
-                       show(name);
+                       show_with_type(type, name);
                }
        }
        else if (abbrev)
-               show(find_unique_abbrev(sha1, abbrev));
+               show_with_type(type, find_unique_abbrev(sha1, abbrev));
        else
-               show(sha1_to_hex(sha1));
+               show_with_type(type, sha1_to_hex(sha1));
  }
  
  /* Output a flag, only if filter allows it. */
@@@ -147,7 -156,7 +153,7 @@@ static int show_flag(const char *arg
        return 0;
  }
  
 -static void show_default(void)
 +static int show_default(void)
  {
        const char *s = def;
  
                def = NULL;
                if (!get_sha1(s, sha1)) {
                        show_rev(NORMAL, sha1, s);
 -                      return;
 +                      return 1;
                }
        }
 +      return 0;
  }
  
  static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
@@@ -363,19 -371,10 +369,19 @@@ static int cmd_parseopt(int argc, cons
        return 0;
  }
  
 +static void die_no_single_rev(int quiet)
 +{
 +      if (quiet)
 +              exit(1);
 +      else
 +              die("Needed a single revision");
 +}
 +
  int cmd_rev_parse(int argc, const char **argv, const char *prefix)
  {
 -      int i, as_is = 0, verify = 0;
 +      int i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;
        unsigned char sha1[20];
 +      const char *name = NULL;
  
        if (argc > 1 && !strcmp("--parseopt", argv[1]))
                return cmd_parseopt(argc - 1, argv + 1, prefix);
                                verify = 1;
                                continue;
                        }
 +                      if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
 +                              quiet = 1;
 +                              continue;
 +                      }
                        if (!strcmp(arg, "--short") ||
                            !prefixcmp(arg, "--short=")) {
                                filter &= ~(DO_FLAGS|DO_NOREV);
                                continue;
                        }
                        if (show_flag(arg) && verify)
 -                              die("Needed a single revision");
 +                              die_no_single_rev(quiet);
                        continue;
                }
  
                /* Not a flag argument */
                if (try_difference(arg))
                        continue;
 -              if (!get_sha1(arg, sha1)) {
 -                      show_rev(NORMAL, sha1, arg);
 -                      continue;
 +              name = arg;
 +              type = NORMAL;
 +              if (*arg == '^') {
 +                      name++;
 +                      type = REVERSED;
                }
 -              if (*arg == '^' && !get_sha1(arg+1, sha1)) {
 -                      show_rev(REVERSED, sha1, arg+1);
 +              if (!get_sha1(name, sha1)) {
 +                      if (verify)
 +                              revs_count++;
 +                      else
 +                              show_rev(type, sha1, name);
                        continue;
                }
 +              if (verify)
 +                      die_no_single_rev(quiet);
                as_is = 1;
                if (!show_file(arg))
                        continue;
 -              if (verify)
 -                      die("Needed a single revision");
                verify_filename(prefix, arg);
        }
 -      show_default();
 -      if (verify && revs_count != 1)
 -              die("Needed a single revision");
 +      if (verify) {
 +              if (revs_count == 1) {
 +                      show_rev(type, sha1, name);
 +                      return 0;
 +              } else if (revs_count == 0 && show_default())
 +                      return 0;
 +              die_no_single_rev(quiet);
 +      } else
 +              show_default();
        return 0;
  }