Skip to content

Commit ddff856

Browse files
hashplinggitster
authored andcommitted
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 <[email protected]> Tested-by: Deskin Miller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 225f1d0 commit ddff856

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

archive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,5 +338,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
338338
parse_treeish_arg(argv, &args, prefix);
339339
parse_pathspec_arg(argv + 1, &args);
340340

341+
git_config(git_default_config, NULL);
342+
341343
return ar->write_archive(&args);
342344
}

builtin-archive.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
111111
{
112112
const char *remote = NULL;
113113

114-
git_config(git_default_config, NULL);
115-
116114
remote = extract_remote_arg(&argc, argv);
117115
if (remote)
118116
return run_remote_archiver(remote, argc, argv);

t/t5000-tar-tree.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ test_expect_success \
5757
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
5858
git commit-tree $treeid </dev/null)'
5959

60+
test_expect_success \
61+
'create bare clone' \
62+
'git clone --bare . bare.git &&
63+
cp .gitattributes bare.git/info/attributes'
64+
6065
test_expect_success \
6166
'remove ignored file' \
6267
'rm a/ignored'
@@ -73,6 +78,14 @@ test_expect_success \
7378
'git archive vs. git tar-tree' \
7479
'diff b.tar b2.tar'
7580

81+
test_expect_success \
82+
'git archive in a bare repo' \
83+
'(cd bare.git && git archive HEAD) >b3.tar'
84+
85+
test_expect_success \
86+
'git archive vs. the same in a bare repo' \
87+
'test_cmp b.tar b3.tar'
88+
7689
test_expect_success \
7790
'validate file modification time' \
7891
'mkdir extract &&
@@ -151,6 +164,14 @@ test_expect_success \
151164
'git archive --format=zip' \
152165
'git archive --format=zip HEAD >d.zip'
153166

167+
test_expect_success \
168+
'git archive --format=zip in a bare repo' \
169+
'(cd bare.git && git archive --format=zip HEAD) >d1.zip'
170+
171+
test_expect_success \
172+
'git archive --format=zip vs. the same in a bare repo' \
173+
'test_cmp d.zip d1.zip'
174+
154175
$UNZIP -v >/dev/null 2>&1
155176
if [ $? -eq 127 ]; then
156177
echo "Skipping ZIP tests, because unzip was not found"

0 commit comments

Comments
 (0)