]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fast-export: fix anonymized tag using original length
authorTal Kelrich <hasturkun@gmail.com>
Tue, 31 Aug 2021 15:55:54 +0000 (15:55 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 31 Aug 2021 19:11:57 +0000 (12:11 -0700)
Commit 7f4075949686 (fast-export: tighten anonymize_mem() interface to
handle only strings, 2020-06-23) changed the interface used in anonymizing
strings, but failed to update the size of annotated tag messages to match
the new anonymized string.

As a result, exporting tags having messages longer than 13 characters
would create output that couldn't be parsed by fast-import,
as the data length indicated was larger than the data output.

Reset the message size when anonymizing, and add a tag with a "long"
message to the test.

Signed-off-by: Tal Kelrich <hasturkun@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fast-export.c
t/t9351-fast-export-anonymize.sh

index 85a76e0ef8be683cfb7511b46192f90f6519ad6d..8b7fc2dcd5e5b85cfeb84490f47e5a670eb837d1 100644 (file)
@@ -821,6 +821,7 @@ static void handle_tag(const char *name, struct tag *tag)
                        static struct hashmap tags;
                        message = anonymize_str(&tags, anonymize_tag,
                                                message, message_size, NULL);
+                       message_size = strlen(message);
                }
        }
 
index 1c6e6fcdaf3c5a258dd9a98647b38a2cd82631b6..77047e250dc2c862182619f717b6b96206a38ec7 100755 (executable)
@@ -18,7 +18,8 @@ test_expect_success 'setup simple repo' '
        git update-index --add --cacheinfo 160000,$fake_commit,link1 &&
        git update-index --add --cacheinfo 160000,$fake_commit,link2 &&
        git commit -m "add gitlink" &&
-       git tag -m "annotated tag" mytag
+       git tag -m "annotated tag" mytag &&
+       git tag -m "annotated tag with long message" longtag
 '
 
 test_expect_success 'export anonymized stream' '
@@ -55,7 +56,8 @@ test_expect_success 'stream retains other as refname' '
 
 test_expect_success 'stream omits other refnames' '
        ! grep main stream &&
-       ! grep mytag stream
+       ! grep mytag stream &&
+       ! grep longtag stream
 '
 
 test_expect_success 'stream omits identities' '
@@ -118,9 +120,9 @@ test_expect_success 'identical gitlinks got identical oid' '
        test_line_count = 1 commits
 '
 
-test_expect_success 'tag points to branch tip' '
+test_expect_success 'all tags point to branch tip' '
        git rev-parse $other_branch >expect &&
-       git for-each-ref --format="%(*objectname)" | grep . >actual &&
+       git for-each-ref --format="%(*objectname)" | grep . | uniq >actual &&
        test_cmp expect actual
 '