diff --git a/archive-tar.c b/archive-tar.c index 181da4e843..3d76977c3f 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -149,7 +149,7 @@ static void strbuf_append_ext_header(struct strbuf *sb, const char *keyword, /* "%u %s=%s\n" */ len = 1 + 1 + strlen(keyword) + 1 + valuelen + 1; - for (tmp = len; tmp > 9; tmp /= 10) + for (tmp = 1; len / 10 >= tmp; tmp *= 10) len++; strbuf_grow(sb, len); diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index 2f15d1899d..4966a74b4d 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -217,7 +217,7 @@ build_tree() { ' "$1" } -test_expect_failure 'tar archive with long paths' ' +test_expect_success 'tar archive with long paths' ' blob=$(echo foo | git hash-object -w --stdin) && tree=$(build_tree $blob | git mktree) && git archive -o long_paths.tar $tree 2>stderr &&