archive-tar: turn length miscalculation warning into BUG

Now that we're confident our pax extended header calculation is correct, turn the criticality of the assertion up to the maximum, from warning right up to BUG. Simplify the test, as the stderr comparison step would not be reached in case the BUG message is triggered. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Aug 17, 2019 at 18:24 UTC 71d41ff651a54028856c4224777ef405de48ae66
2 files changed +4 -5
archive-tar.c
+3 -3
@@ -158,9 +158,9 @@ static void strbuf_append_ext_header(struct strbuf *sb, const char *keyword,
158 strbuf_addch(sb, '\n');
159
160 if (len != sb->len - orig_len)
161 - warning("pax extended header length miscalculated as %"PRIuMAX
162 - ", should be %"PRIuMAX,
163 - (uintmax_t)len, (uintmax_t)(sb->len - orig_len));
161 + BUG("pax extended header length miscalculated as %"PRIuMAX
162 + ", should be %"PRIuMAX,
163 + (uintmax_t)len, (uintmax_t)(sb->len - orig_len));
164 }
165
166 /*
t/t5004-archive-corner-cases.sh
+1 -2
@@ -220,8 +220,7 @@ build_tree() {
220 test_expect_success 'tar archive with long paths' '
221 blob=$(echo foo | git hash-object -w --stdin) &&
222 tree=$(build_tree $blob | git mktree) &&
223 - git archive -o long_paths.tar $tree 2>stderr &&
224 - test_must_be_empty stderr
223 + git archive -o long_paths.tar $tree
224 '
225
226 test_done