show-branch -g: default to the current branch.
Now we have a separate reflog on HEAD, show-branch -g without an explicit parameter defaults to the current branch, or HEAD when it is detached from branches. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 3, 2007 at 23:31 UTC
632ac9fd12a2d4ff2c1a1fcd63492ce24315221f
2 files changed
+9
-4
Documentation/git-show-branch.txt
+5
-3
@@ -11,7 +11,7 @@ SYNOPSIS
11
'git-show-branch' [--all] [--remotes] [--topo-order] [--current]
12
[--more=<n> | --list | --independent | --merge-base]
13
[--no-name | --sha1-name] [--topics] [<rev> | <glob>]...
14
-'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] <ref>
14
+'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]
15
16
DESCRIPTION
17
-----------
@@ -97,11 +97,13 @@ OPTIONS
97
will show the revisions given by "git rev-list {caret}master
98
topic1 topic2"
99
100
---reflog[=<n>[,<base>]] <ref>::
100
+--reflog[=<n>[,<base>]] [<ref>]::
101
Shows <n> most recent ref-log entries for the given
102
ref. If <base> is given, <n> entries going back from
103
that entry. <base> can be specified as count or date.
104
- `-g` can be used as a short-hand for this option.
104
+ `-g` can be used as a short-hand for this option. When
105
+ no explicit <ref> parameter is given, it defaults to the
106
+ current branch (or `HEAD` if it is detached).
107
108
Note that --more, --list, --independent and --merge-base options
109
are mutually exclusive.
builtin-show-branch.c
+4
-1
@@ -690,7 +690,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
690
691
if (ac == 0) {
692
static const char *fake_av[2];
693
- fake_av[0] = "HEAD";
693
+ const char *refname;
694
+
695
+ refname = resolve_ref("HEAD", sha1, 1, NULL);
696
+ fake_av[0] = xstrdup(refname);
697
fake_av[1] = NULL;
698
av = fake_av;
699
ac = 1;