summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sha1_name.c3
-rwxr-xr-xt/t0100-previous.sh8
2 files changed, 10 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 73a915ff1b..9b5d14b4bf 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1263,11 +1263,12 @@ int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)
{
char *at;
const char *start;
- int len = interpret_nth_prior_checkout(name, namelen, buf);
+ int len;
if (!namelen)
namelen = strlen(name);
+ len = interpret_nth_prior_checkout(name, namelen, buf);
if (!len) {
return len; /* syntax Ok, not enough switches */
} else if (len > 0) {
diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh
index e0a6940232..58c0b7e9b6 100755
--- a/t/t0100-previous.sh
+++ b/t/t0100-previous.sh
@@ -56,5 +56,13 @@ test_expect_success 'merge @{-100} before checking out that many branches yet' '
test_must_fail git merge @{-100}
'
+test_expect_success 'log -g @{-1}' '
+ git checkout -b last_branch &&
+ git checkout -b new_branch &&
+ echo "last_branch@{0}" >expect &&
+ git log -g --format=%gd @{-1} >actual &&
+ test_cmp expect actual
+'
+
test_done