Skip to content

Commit 68c7c59

Browse files
matheustavaresavar
authored andcommitted
clone: copy hidden paths at local clone
Make the copy_or_link_directory function no longer skip hidden directories. This function, used to copy .git/objects, currently skips all hidden directories but not hidden files, which is an odd behaviour. The reason for that could be unintentional: probably the intention was to skip '.' and '..' only but it ended up accidentally skipping all directories starting with '.'. Besides being more natural, the new behaviour is more permissive to the user. Also adjust tests to reflect this behaviour change. Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Co-authored-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa1da7d commit 68c7c59

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
427427
continue;
428428
}
429429
if (S_ISDIR(buf.st_mode)) {
430-
if (de->d_name[0] != '.')
430+
if (!is_dot_or_dotdot(de->d_name))
431431
copy_or_link_directory(src, dest,
432432
src_repo, src_baselen);
433433
continue;

t/t5604-clone-reference.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,25 @@ test_expect_success 'clone a repo with garbage in objects/*' '
247247
done &&
248248
find S-* -name "*some*" | sort >actual &&
249249
cat >expected <<-EOF &&
250+
S--dissociate/.git/objects/.some-hidden-dir
251+
S--dissociate/.git/objects/.some-hidden-dir/.some-dot-file
252+
S--dissociate/.git/objects/.some-hidden-dir/some-file
250253
S--dissociate/.git/objects/.some-hidden-file
251254
S--dissociate/.git/objects/some-dir
252255
S--dissociate/.git/objects/some-dir/.some-dot-file
253256
S--dissociate/.git/objects/some-dir/some-file
254257
S--dissociate/.git/objects/some-file
258+
S--local/.git/objects/.some-hidden-dir
259+
S--local/.git/objects/.some-hidden-dir/.some-dot-file
260+
S--local/.git/objects/.some-hidden-dir/some-file
255261
S--local/.git/objects/.some-hidden-file
256262
S--local/.git/objects/some-dir
257263
S--local/.git/objects/some-dir/.some-dot-file
258264
S--local/.git/objects/some-dir/some-file
259265
S--local/.git/objects/some-file
266+
S--no-hardlinks/.git/objects/.some-hidden-dir
267+
S--no-hardlinks/.git/objects/.some-hidden-dir/.some-dot-file
268+
S--no-hardlinks/.git/objects/.some-hidden-dir/some-file
260269
S--no-hardlinks/.git/objects/.some-hidden-file
261270
S--no-hardlinks/.git/objects/some-dir
262271
S--no-hardlinks/.git/objects/some-dir/.some-dot-file

0 commit comments

Comments
 (0)