summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-12-17 06:47:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-12-17 18:47:56 (GMT)
commit728350b76a2244e7cf79412f46e990e763ebf89e (patch)
treeeaccb4628faf5958536a690a0fe0169235f528c5
parent207394908e9465d0169608725aeaa5bb355086e0 (diff)
downloadgit-728350b76a2244e7cf79412f46e990e763ebf89e.zip
git-728350b76a2244e7cf79412f46e990e763ebf89e.tar.gz
git-728350b76a2244e7cf79412f46e990e763ebf89e.tar.bz2
revision.c: propagate tag names from pending array
When we unwrap a tag to find its commit for a traversal, we do not propagate the "name" field of the tag in the pending array (i.e., the ref name the user gave us in the first place) to the commit (instead, we use an empty string). This means that "git log --source" will never show the tag-name for commits we reach through it. This was broken in 2073949 (traverse_commit_list: support pending blobs/trees with paths, 2014-10-15). That commit tried to be careful and avoid propagating the path information for a tag (which would be nonsensical) to trees and blobs. But it should not have cut off the "name" field, which should carry forward to children. Note that this does mean that the "name" field will carry forward to blobs and trees, too. Whereas prior to 2073949, we always gave them an empty string. This is the right thing to do, but in practice no callers probably use it (since now we have an explicit separate "path" field, which was the point of 2073949). We add tests here not only for the broken case, but also a basic sanity test of "log --source" in general, which did not have any coverage in the test suite. Reported-by: Raymundo <gypark@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--revision.c3
-rwxr-xr-xt/t4202-log.sh29
2 files changed, 30 insertions, 2 deletions
diff --git a/revision.c b/revision.c
index ebe3e93..0a0ef3c 100644
--- a/revision.c
+++ b/revision.c
@@ -300,9 +300,8 @@ static struct commit *handle_commit(struct rev_info *revs,
/*
* We'll handle the tagged object by looping or dropping
* through to the non-tag handlers below. Do not
- * propagate data from the tag's pending entry.
+ * propagate path data from the tag's pending entry.
*/
- name = "";
path = NULL;
mode = 0;
}
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 99ab7ca..043c48e 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -872,4 +872,33 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
grep "^| | gpg: Good signature" actual
'
+test_expect_success 'set up --source tests' '
+ git checkout --orphan source-a &&
+ test_commit one &&
+ test_commit two &&
+ git checkout -b source-b HEAD^ &&
+ test_commit three
+'
+
+test_expect_success 'log --source paints branch names' '
+ cat >expect <<-\EOF &&
+ 09e12a9 source-b three
+ 8e393e1 source-a two
+ 1ac6c77 source-b one
+ EOF
+ git log --oneline --source source-a source-b >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --source paints tag names' '
+ git tag -m tagged source-tag &&
+ cat >expect <<-\EOF &&
+ 09e12a9 source-tag three
+ 8e393e1 source-a two
+ 1ac6c77 source-tag one
+ EOF
+ git log --oneline --source source-tag source-a >actual &&
+ test_cmp expect actual
+'
+
test_done