From 632ac9fd12a2d4ff2c1a1fcd63492ce24315221f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 3 Feb 2007 23:31:47 -0800 Subject: [PATCH] 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 --- Documentation/git-show-branch.txt | 8 +++++--- builtin-show-branch.c | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt index b38633c39..ba5313d51 100644 --- a/Documentation/git-show-branch.txt +++ b/Documentation/git-show-branch.txt @@ -11,7 +11,7 @@ SYNOPSIS 'git-show-branch' [--all] [--remotes] [--topo-order] [--current] [--more= | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [ | ]... -'git-show-branch' (-g|--reflog)[=[,]] [--list] +'git-show-branch' (-g|--reflog)[=[,]] [--list] [] DESCRIPTION ----------- @@ -97,11 +97,13 @@ OPTIONS will show the revisions given by "git rev-list {caret}master topic1 topic2" ---reflog[=[,]] :: +--reflog[=[,]] []:: Shows most recent ref-log entries for the given ref. If is given, entries going back from that entry. 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 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. diff --git a/builtin-show-branch.c b/builtin-show-branch.c index fa62e487b..0d94e40df 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -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; -- 2.45.2