]> Pileus Git - ~andy/git/commitdiff
log: properly handle decorations with chained tags
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 17 Dec 2013 04:28:21 +0000 (04:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Dec 2013 22:37:03 +0000 (14:37 -0800)
git log did not correctly handle decorations when a tag object referenced
another tag object that was no longer a ref, such as when the second tag was
deleted.  The commit would not be decorated correctly because parse_object had
not been called on the second tag and therefore its tagged field had not been
filled in, resulting in none of the tags being associated with the relevant
commit.

Call parse_object to fill in this field if it is absent so that the chain of
tags can be dereferenced and the commit can be properly decorated.  Include
tests as well to prevent future regressions.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
log-tree.c
t/t4205-log-pretty-formats.sh

index 8534d91826f3cf05f810a28728ee8bd51649d819..1982631ca497002b746873cd62fabbc4b7f9d3ce 100644 (file)
@@ -134,6 +134,8 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
                obj = ((struct tag *)obj)->tagged;
                if (!obj)
                        break;
+               if (!obj->parsed)
+                       parse_object(obj->sha1);
                add_name_decoration(DECORATION_REF_TAG, refname, obj);
        }
        return 0;
index fb000411395d50639334c3c0395b2b975aa4bc12..2a6278bb333d2843ee617ff69227feae115aefea 100755 (executable)
@@ -310,4 +310,19 @@ EOF
        test_cmp expected actual
 '
 
+test_expect_success 'log decoration properly follows tag chain' '
+       git tag -a tag1 -m tag1 &&
+       git tag -a tag2 -m tag2 tag1 &&
+       git tag -d tag1 &&
+       git commit --amend -m shorter &&
+       git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
+       cat <<EOF >expected &&
+6a908c10688b2503073c39c9ba26322c73902bb5  (tag: refs/tags/tag2)
+9f716384d92283fb915a4eee5073f030638e05f9  (tag: refs/tags/message-one)
+b87e4cccdb77336ea79d89224737be7ea8e95367  (tag: refs/tags/message-two)
+EOF
+       sort actual >actual1 &&
+       test_cmp expected actual1
+'
+
 test_done