From: Junio C Hamano Date: Tue, 27 May 2008 02:49:01 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.5.6-rc1~42 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2fe18392f0355c80295b8b74b24fc817183d3752?ds=inline;hp=-c Merge branch 'maint' * maint: Documentation: fix graph in git-rev-parse.txt show-branch --current: do not barf on detached HEAD --- 2fe18392f0355c80295b8b74b24fc817183d3752 diff --combined Documentation/git-rev-parse.txt index 69599ffb67,5981c79f6a..5641d99518 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@@ -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 ee4269dd33,a383323184..93047f5117 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@@ -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) @@@ -547,7 -547,7 +547,7 @@@ 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) { @@@ -782,8 -782,8 +782,8 @@@ 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); } }