summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8ca7880)
raw | patch | inline | side by side (parent: 8ca7880)
author | Dave Olszewski <cxreg@pobox.com> | |
Sat, 13 Mar 2010 22:47:05 +0000 (14:47 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 14 Mar 2010 05:23:43 +0000 (21:23 -0800) |
If a revision is specified, it happens not to have any commits, don't
use the default revision. By doing so, surprising and undesired
behavior can happen, such as showing the reflog for HEAD when a branch
was specified.
[jc: squashed a test from René]
Signed-off-by: Dave Olszewski <cxreg@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
use the default revision. By doing so, surprising and undesired
behavior can happen, such as showing the reflog for HEAD when a branch
was specified.
[jc: squashed a test from René]
Signed-off-by: Dave Olszewski <cxreg@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c | patch | blob | history | |
t/t1411-reflog-show.sh | patch | blob | history |
diff --git a/revision.c b/revision.c
index 29721ecf84316d01b18ffdee8bdefa8dbb3887db..490b484084e875e9b6c5aea1168437bba4bb500a 100644 (file)
--- a/revision.c
+++ b/revision.c
*/
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
{
- int i, flags, left, seen_dashdash, read_from_stdin;
+ int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
const char **prune_data = NULL;
/* First, search for "--" */
@@ -1460,6 +1460,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
append_prune_data(&prune_data, argv + i);
break;
}
+ else
+ got_rev_arg = 1;
}
if (prune_data)
@@ -1469,7 +1471,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->def = def;
if (revs->show_merge)
prepare_show_merge(revs);
- if (revs->def && !revs->pending.nr) {
+ if (revs->def && !revs->pending.nr && !got_rev_arg) {
unsigned char sha1[20];
struct object *object;
unsigned mode;
diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
index c18ed8edf994f3d701ab1d01c2e05b2585174d31..ba25ff354d6fc4998237b1145737faf6c836966e 100755 (executable)
--- a/t/t1411-reflog-show.sh
+++ b/t/t1411-reflog-show.sh
test_cmp expect actual
'
+: >expect
+test_expect_success 'empty reflog file' '
+ git branch empty &&
+ : >.git/logs/refs/heads/empty &&
+
+ git log -g empty >actual &&
+ test_cmp expect actual
+'
+
test_done