@matheusbsbs / matheus-bagliano / commits / 8a2f87332b
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Feb 3, 2008 at 00:00 UTC 8a2f87332b847edc7f8fc5f305889c863651ecb5
2 files changed +19 -1
builtin-commit.c
+1 -1
@@ -601,7 +601,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
601
602 if (get_sha1(use_message, sha1))
603 die("could not lookup commit %s", use_message);
604 - commit = lookup_commit(sha1);
604 + commit = lookup_commit_reference(sha1);
605 if (!commit || parse_commit(commit))
606 die("could not parse commit %s", use_message);
607
t/t7501-commit.sh
+18
@@ -327,4 +327,22 @@ test_expect_success 'amend using the message from another commit' '
327
328 '
329
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 +
348 test_done