Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Tue, 27 May 2008 02:49:01 +0000 (19:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 May 2008 02:49:01 +0000 (19:49 -0700)
* maint:
Documentation: fix graph in git-rev-parse.txt
show-branch --current: do not barf on detached HEAD

1  2 
Documentation/git-rev-parse.txt
builtin-show-branch.c
index 69599ffb679b17ebbe6ba85c772cd10a3511d89e,5981c79f6a2568c33b455c649946d6af2d9baeb3..5641d995180b7aed563872b2403dbd29870a2185
@@@ -52,11 -52,6 +52,11 @@@ OPTION
        The parameter given must be usable as a single, valid
        object name.  Otherwise barf and abort.
  
 +-q, --quiet::
 +      Only meaningful in `--verify` mode. Do not output an error
 +      message if the first argument is not a valid object name;
 +      instead exit with non-zero status silently.
 +
  --sq::
        Usually the output is made one line per flag and
        parameter.  This option makes output a single line,
@@@ -243,16 -238,18 +243,18 @@@ Here is an illustration, by Jon Loelige
  and C are parents of commit node A.  Parent commits are ordered
  left-to-right.
  
-     G   H   I   J
-      \ /     \ /
-       D   E   F
-        \  |  / \ 
-         \ | /   |
-          \|/    |
-           B     C
-            \   /
-             \ /
-              A
+ ........................................
+ G   H   I   J
+  \ /     \ /
+   D   E   F
+    \  |  / \
+     \ | /   |
+      \|/    |
+       B     C
+        \   /
+         \ /
+          A
+ ........................................
  
      A =      = A^0
      B = A^   = A^1     = A~1
@@@ -347,7 -344,7 +349,7 @@@ Each line of options has this format
  
        * Use `*` to mean that this option should not be listed in the usage
          generated for the `-h` argument. It's shown for `--help-all` as
 -        documented in linkgit:gitcli[5].
 +        documented in linkgit:gitcli[7].
  
        * Use `!` to not make the corresponding negated long option available.
  
@@@ -378,31 -375,6 +380,31 @@@ C?        option C with an optional arg
  eval `echo "$OPTS_SPEC" | git-rev-parse --parseopt -- "$@" || echo exit $?`
  ------------
  
 +EXAMPLES
 +--------
 +
 +* Print the object name of the current commit:
 ++
 +------------
 +$ git rev-parse --verify HEAD
 +------------
 +
 +* Print the commit object name from the revision in the $REV shell variable:
 ++
 +------------
 +$ git rev-parse --verify $REV
 +------------
 ++
 +This will error out if $REV is empty or not a valid revision.
 +
 +* Same as above:
 ++
 +------------
 +$ git rev-parse --default master --verify $REV
 +------------
 ++
 +but if $REV is empty, the commit object name from master will be printed.
 +
  
  Author
  ------
diff --combined builtin-show-branch.c
index ee4269dd33aa0b2229eaac0ce7b75f7893447b0f,a383323184bdcfb5258ed8d375ac22990f95877c..93047f5117796fb7556fa23871397e68e9f5e4c2
@@@ -533,7 -533,7 +533,7 @@@ static void append_one_rev(const char *
        die("bad sha1 reference %s", av);
  }
  
 -static int git_show_branch_config(const char *var, const char *value)
 +static int git_show_branch_config(const char *var, const char *value, void *cb)
  {
        if (!strcmp(var, "showbranch.default")) {
                if (!value)
                return 0;
        }
  
 -      return git_default_config(var, value);
 +      return git_default_config(var, value, cb);
  }
  
  static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
@@@ -611,7 -611,7 +611,7 @@@ int cmd_show_branch(int ac, const char 
        int reflog = 0;
        const char *reflog_base = NULL;
  
 -      git_config(git_show_branch_config);
 +      git_config(git_show_branch_config, NULL);
  
        /* If nothing is specified, try the default first */
        if (ac == 1 && default_num) {
                                has_head++;
                }
                if (!has_head) {
-                       int pfxlen = strlen("refs/heads/");
-                       append_one_rev(head + pfxlen);
+                       int offset = !prefixcmp(head, "refs/heads/") ? 11 : 0;
+                       append_one_rev(head + offset);
                }
        }