show-branch -g: default to HEAD
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 25, 2007 at 22:14 UTC
df373ea99a1cf3056a72bad1d66f0e62f3b41c20
1 file changed
+13
-4
builtin-show-branch.c
+13
-4
@@ -662,13 +662,13 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
662
}
663
ac--; av++;
664
665
- if (!!extra || !!reflog) {
665
+ if (extra || reflog) {
666
/* "listing" mode is incompatible with
667
* independent nor merge-base modes.
668
*/
669
if (independent || merge_base)
670
usage(show_branch_usage);
671
- if (!!reflog && ((0 < extra) || all_heads || all_remotes))
671
+ if (reflog && ((0 < extra) || all_heads || all_remotes))
672
/*
673
* Asking for --more in reflog mode does not
674
* make sense. --list is Ok.
@@ -682,15 +682,22 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
682
if (ac + all_heads + all_remotes == 0)
683
all_heads = 1;
684
685
- if (all_heads + all_remotes)
686
- snarf_refs(all_heads, all_remotes);
685
if (reflog) {
686
unsigned char sha1[20];
687
char nth_desc[256];
688
char *ref;
689
int base = 0;
690
+
691
+ if (ac == 0) {
692
+ static const char *fake_av[2];
693
+ fake_av[0] = "HEAD";
694
+ fake_av[1] = NULL;
695
+ av = fake_av;
696
+ ac = 1;
697
+ }
698
if (ac != 1)
699
die("--reflog option needs one branch name");
700
+
701
if (MAX_REVS < reflog)
702
die("Only %d entries can be shown at one time.",
703
MAX_REVS);
@@ -735,6 +742,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
742
append_ref(nth_desc, sha1, 1);
743
}
744
}
745
+ else if (all_heads + all_remotes)
746
+ snarf_refs(all_heads, all_remotes);
747
else {
748
while (0 < ac) {
749
append_one_rev(*av);