clone: copy hidden paths at local clone
authorMatheus Tavares <matheus.bernardino@usp.br>
Wed, 10 Jul 2019 23:59:01 +0000 (20:59 -0300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Jul 2019 20:52:15 +0000 (13:52 -0700)
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>
builtin/clone.c
t/t5604-clone-reference.sh

index 5956b1c..541f0e1 100644 (file)
@@ -427,7 +427,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
                        continue;
                }
                if (S_ISDIR(buf.st_mode)) {
-                       if (de->d_name[0] != '.')
+                       if (!is_dot_or_dotdot(de->d_name))
                                copy_or_link_directory(src, dest,
                                                       src_repo, src_baselen);
                        continue;
index 459ad8a..4894237 100755 (executable)
@@ -247,16 +247,25 @@ test_expect_success 'clone a repo with garbage in objects/*' '
        done &&
        find S-* -name "*some*" | sort >actual &&
        cat >expected <<-EOF &&
+       S--dissociate/.git/objects/.some-hidden-dir
+       S--dissociate/.git/objects/.some-hidden-dir/.some-dot-file
+       S--dissociate/.git/objects/.some-hidden-dir/some-file
        S--dissociate/.git/objects/.some-hidden-file
        S--dissociate/.git/objects/some-dir
        S--dissociate/.git/objects/some-dir/.some-dot-file
        S--dissociate/.git/objects/some-dir/some-file
        S--dissociate/.git/objects/some-file
+       S--local/.git/objects/.some-hidden-dir
+       S--local/.git/objects/.some-hidden-dir/.some-dot-file
+       S--local/.git/objects/.some-hidden-dir/some-file
        S--local/.git/objects/.some-hidden-file
        S--local/.git/objects/some-dir
        S--local/.git/objects/some-dir/.some-dot-file
        S--local/.git/objects/some-dir/some-file
        S--local/.git/objects/some-file
+       S--no-hardlinks/.git/objects/.some-hidden-dir
+       S--no-hardlinks/.git/objects/.some-hidden-dir/.some-dot-file
+       S--no-hardlinks/.git/objects/.some-hidden-dir/some-file
        S--no-hardlinks/.git/objects/.some-hidden-file
        S--no-hardlinks/.git/objects/some-dir
        S--no-hardlinks/.git/objects/some-dir/.some-dot-file