archive-tar: huge offset and future timestamps would not work on 32-bit

As we are not yet moving everything to size_t but still using ulong internally when talking about the size of object, platforms with 32-bit long will not be able to produce tar archive with 4GB+ file, and cannot grok 077777777777UL as a constant. Disable the extended header feature and do not test it on them. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jul 14, 2016 at 13:04 UTC 29493589e97a2de0c4c1c314f61ccafaee3b5caf
2 files changed +11 -6
archive-tar.c
+5
@@ -25,8 +25,13 @@ static int write_tar_filter_archive(const struct archiver *ar,
25 *
26 * Likewise for the mtime (which happens to use a buffer of the same size).
27 */
28 +#if ULONG_MAX == 0xFFFFFFFF
29 +#define USTAR_MAX_SIZE ULONG_MAX
30 +#define USTAR_MAX_MTIME ULONG_MAX
31 +#else
32 #define USTAR_MAX_SIZE 077777777777UL
33 #define USTAR_MAX_MTIME 077777777777UL
34 +#endif
35
36 /* writes out the whole block, but only if it is full */
37 static void write_if_needed(void)
t/t5000-tar-tree.sh
+6 -6
@@ -347,7 +347,7 @@ test_lazy_prereq TAR_HUGE '
347 test_cmp expect actual
348 '
349
350 -test_expect_success 'set up repository with huge blob' '
350 +test_expect_success LONG_IS_64BIT 'set up repository with huge blob' '
351 obj_d=19 &&
352 obj_f=f9c8273ec45a8938e6999cb59b3ff66739902a &&
353 obj=${obj_d}${obj_f} &&
@@ -360,7 +360,7 @@ test_expect_success 'set up repository with huge blob' '
360
361 # We expect git to die with SIGPIPE here (otherwise we
362 # would generate the whole 64GB).
363 -test_expect_success 'generate tar with huge size' '
363 +test_expect_success LONG_IS_64BIT 'generate tar with huge size' '
364 {
365 git archive HEAD
366 echo $? >exit-code
@@ -369,13 +369,13 @@ test_expect_success 'generate tar with huge size' '
369 test_cmp expect exit-code
370 '
371
372 -test_expect_success TAR_HUGE 'system tar can read our huge size' '
372 +test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our huge size' '
373 echo 68719476737 >expect &&
374 tar_info huge.tar | cut -d" " -f1 >actual &&
375 test_cmp expect actual
376 '
377
378 -test_expect_success 'set up repository with far-future commit' '
378 +test_expect_success LONG_IS_64BIT 'set up repository with far-future commit' '
379 rm -f .git/index &&
380 echo content >file &&
381 git add file &&
@@ -383,11 +383,11 @@ test_expect_success 'set up repository with far-future commit' '
383 git commit -m "tempori parendum"
384 '
385
386 -test_expect_success 'generate tar with future mtime' '
386 +test_expect_success LONG_IS_64BIT 'generate tar with future mtime' '
387 git archive HEAD >future.tar
388 '
389
390 -test_expect_success TAR_HUGE 'system tar can read our future mtime' '
390 +test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our future mtime' '
391 echo 4147 >expect &&
392 tar_info future.tar | cut -d" " -f2 >actual &&
393 test_cmp expect actual