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 <matheus.bernardino@usp.br> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Co-authored-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matheus Tavares committed
Jul 10, 2019 at 20:59 UTC
68c7c59cf202a4d90d96f19076a33d12278c5864
2 files changed
+10
-1
builtin/clone.c
+1
-1
@@ -427,7 +427,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
427
continue;
428
}
429
if (S_ISDIR(buf.st_mode)) {
430
- if (de->d_name[0] != '.')
430
+ if (!is_dot_or_dotdot(de->d_name))
431
copy_or_link_directory(src, dest,
432
src_repo, src_baselen);
433
continue;
t/t5604-clone-reference.sh
+9
@@ -247,16 +247,25 @@ test_expect_success 'clone a repo with garbage in objects/*' '
247
done &&
248
find S-* -name "*some*" | sort >actual &&
249
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
253
S--dissociate/.git/objects/.some-hidden-file
254
S--dissociate/.git/objects/some-dir
255
S--dissociate/.git/objects/some-dir/.some-dot-file
256
S--dissociate/.git/objects/some-dir/some-file
257
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
261
S--local/.git/objects/.some-hidden-file
262
S--local/.git/objects/some-dir
263
S--local/.git/objects/some-dir/.some-dot-file
264
S--local/.git/objects/some-dir/some-file
265
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
269
S--no-hardlinks/.git/objects/.some-hidden-file
270
S--no-hardlinks/.git/objects/some-dir
271
S--no-hardlinks/.git/objects/some-dir/.some-dot-file