git-archive: work in bare repos

This moves the call to git_config to a place where it doesn't break the
logic for using git archive in a bare repository but retains the fix to
make git archive respect core.autocrlf.

Tests are by René Scharfe.

Signed-off-by: Charles Bailey <charles@hashpling.org>
Tested-by: Deskin Miller <deskinm@umich.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Charles Bailey 2008-10-25 11:38:14 -04:00 committed by Junio C Hamano
parent 225f1d0c6a
commit ddff856351
3 changed files with 23 additions and 2 deletions

View File

@ -338,5 +338,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
parse_treeish_arg(argv, &args, prefix);
parse_pathspec_arg(argv + 1, &args);
git_config(git_default_config, NULL);
return ar->write_archive(&args);
}

View File

@ -111,8 +111,6 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
{
const char *remote = NULL;
git_config(git_default_config, NULL);
remote = extract_remote_arg(&argc, argv);
if (remote)
return run_remote_archiver(remote, argc, argv);

View File

@ -57,6 +57,11 @@ test_expect_success \
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
git commit-tree $treeid </dev/null)'
test_expect_success \
'create bare clone' \
'git clone --bare . bare.git &&
cp .gitattributes bare.git/info/attributes'
test_expect_success \
'remove ignored file' \
'rm a/ignored'
@ -73,6 +78,14 @@ test_expect_success \
'git archive vs. git tar-tree' \
'diff b.tar b2.tar'
test_expect_success \
'git archive in a bare repo' \
'(cd bare.git && git archive HEAD) >b3.tar'
test_expect_success \
'git archive vs. the same in a bare repo' \
'test_cmp b.tar b3.tar'
test_expect_success \
'validate file modification time' \
'mkdir extract &&
@ -151,6 +164,14 @@ test_expect_success \
'git archive --format=zip' \
'git archive --format=zip HEAD >d.zip'
test_expect_success \
'git archive --format=zip in a bare repo' \
'(cd bare.git && git archive --format=zip HEAD) >d1.zip'
test_expect_success \
'git archive --format=zip vs. the same in a bare repo' \
'test_cmp d.zip d1.zip'
$UNZIP -v >/dev/null 2>&1
if [ $? -eq 127 ]; then
echo "Skipping ZIP tests, because unzip was not found"