Skip to content

Commit 8a2f873

Browse files
committed
Fix "git-commit -C $tag"
The scripted version might not have handled this correctly either, but the version rewritten in C definitely does not grok this and complains $tag is not a commit object. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71bda8b commit 8a2f873

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

builtin-commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
601601

602602
if (get_sha1(use_message, sha1))
603603
die("could not lookup commit %s", use_message);
604-
commit = lookup_commit(sha1);
604+
commit = lookup_commit_reference(sha1);
605605
if (!commit || parse_commit(commit))
606606
die("could not parse commit %s", use_message);
607607

t/t7501-commit.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,22 @@ test_expect_success 'amend using the message from another commit' '
327327
328328
'
329329

330+
test_expect_success 'amend using the message from a commit named with tag' '
331+
332+
git reset --hard &&
333+
test_tick &&
334+
git commit --allow-empty -m "old commit" &&
335+
old=$(git rev-parse --verify HEAD) &&
336+
git tag -a -m "tag on old" tagged-old HEAD &&
337+
test_tick &&
338+
git commit --allow-empty -m "new commit" &&
339+
new=$(git rev-parse --verify HEAD) &&
340+
test_tick &&
341+
git commit --allow-empty --amend -C tagged-old &&
342+
git show --pretty="format:%ad %s" "$old" >expected &&
343+
git show --pretty="format:%ad %s" HEAD >actual &&
344+
diff -u expected actual
345+
346+
'
347+
330348
test_done

0 commit comments

Comments
 (0)