Skip to content

Commit 2f040a9

Browse files
hasturkungitster
authored andcommitted
fast-export: fix anonymized tag using original length
Commit 7f40759 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 48bf2fa commit 2f040a9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

builtin/fast-export.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ static void handle_tag(const char *name, struct tag *tag)
821821
static struct hashmap tags;
822822
message = anonymize_str(&tags, anonymize_tag,
823823
message, message_size, NULL);
824+
message_size = strlen(message);
824825
}
825826
}
826827

t/t9351-fast-export-anonymize.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ test_expect_success 'setup simple repo' '
1818
git update-index --add --cacheinfo 160000,$fake_commit,link1 &&
1919
git update-index --add --cacheinfo 160000,$fake_commit,link2 &&
2020
git commit -m "add gitlink" &&
21-
git tag -m "annotated tag" mytag
21+
git tag -m "annotated tag" mytag &&
22+
git tag -m "annotated tag with long message" longtag
2223
'
2324

2425
test_expect_success 'export anonymized stream' '
@@ -55,7 +56,8 @@ test_expect_success 'stream retains other as refname' '
5556

5657
test_expect_success 'stream omits other refnames' '
5758
! grep main stream &&
58-
! grep mytag stream
59+
! grep mytag stream &&
60+
! grep longtag stream
5961
'
6062

6163
test_expect_success 'stream omits identities' '
@@ -118,9 +120,9 @@ test_expect_success 'identical gitlinks got identical oid' '
118120
test_line_count = 1 commits
119121
'
120122

121-
test_expect_success 'tag points to branch tip' '
123+
test_expect_success 'all tags point to branch tip' '
122124
git rev-parse $other_branch >expect &&
123-
git for-each-ref --format="%(*objectname)" | grep . >actual &&
125+
git for-each-ref --format="%(*objectname)" | grep . | uniq >actual &&
124126
test_cmp expect actual
125127
'
126128

0 commit comments

Comments
 (0)