aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2010-02-08 00:30:20 +0100
committerJunio C Hamano <gitster@pobox.com>2010-02-07 15:40:27 -0800
commitfe12d8e84f745303d64757307e9a6a81a6608018 (patch)
tree0e0fbad1cb5efcb49c893c5a94f2bcbdc15754af /t
parent2b26e0e18907132eaac2a8163de0cac552217082 (diff)
downloadgit-fe12d8e84f745303d64757307e9a6a81a6608018.tar.gz
git-fe12d8e84f745303d64757307e9a6a81a6608018.tar.xz
archive: simplify archive format guessing
The code to guess an output archive's format consumed any --format options and built a new one. Jonathan noticed that it does so in an unsafe way, risking to overflow the static buffer fmt_opt. Change the code to keep the existing --format options intact and to only add a new one if a format could be guessed based on the output file name. The new option is added as the first one, allowing the existing ones to overrule it, i.e. explicit --format options given on the command line win over format guesses, as before. To simplify the code further, format_from_name() is changed to return the full --format option, thus no potentially dangerous sprintf() calls are needed any more. Reported-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t5000-tar-tree.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 0037f63d9..27bfba55b 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -189,6 +189,16 @@ test_expect_success 'git archive --format=zip with --output' \
'git archive --format=zip --output=d2.zip HEAD &&
test_cmp d.zip d2.zip'
+test_expect_success 'git archive with --output, inferring format' '
+ git archive --output=d3.zip HEAD &&
+ test_cmp d.zip d3.zip
+'
+
+test_expect_success 'git archive with --output, override inferred format' '
+ git archive --format=tar --output=d4.zip HEAD &&
+ test_cmp b.tar d4.zip
+'
+
$UNZIP -v >/dev/null 2>&1
if [ $? -eq 127 ]; then
say "Skipping ZIP tests, because unzip was not found"