Skip to content

Commit

Permalink
show-branch -g: default to the current branch.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Feb 4, 2007
1 parent dc9195a commit 632ac9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Documentation/git-show-branch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SYNOPSIS
'git-show-branch' [--all] [--remotes] [--topo-order] [--current]
[--more=<n> | --list | --independent | --merge-base]
[--no-name | --sha1-name] [--topics] [<rev> | <glob>]...
'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] <ref>
'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]

DESCRIPTION
-----------
Expand Down Expand Up @@ -97,11 +97,13 @@ OPTIONS
will show the revisions given by "git rev-list {caret}master
topic1 topic2"

--reflog[=<n>[,<base>]] <ref>::
--reflog[=<n>[,<base>]] [<ref>]::
Shows <n> most recent ref-log entries for the given
ref. If <base> is given, <n> entries going back from
that entry. <base> can be specified as count or date.
`-g` can be used as a short-hand for this option.
`-g` can be used as a short-hand for this option. When
no explicit <ref> parameter is given, it defaults to the
current branch (or `HEAD` if it is detached).

Note that --more, --list, --independent and --merge-base options
are mutually exclusive.
Expand Down
5 changes: 4 additions & 1 deletion builtin-show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)

if (ac == 0) {
static const char *fake_av[2];
fake_av[0] = "HEAD";
const char *refname;

refname = resolve_ref("HEAD", sha1, 1, NULL);
fake_av[0] = xstrdup(refname);
fake_av[1] = NULL;
av = fake_av;
ac = 1;
Expand Down

0 comments on commit 632ac9f

Please sign in to comment.