Skip to contentSkip to conversation

build_clone: git clean newly cloned trees

PATCH In review Ian Jackson 3 participants 3 messages Oct 29, 2015 – Nov 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build_clone: git clean newly cloned trees

This may seem redundant, however:

git does not track empty directories. So it can happen that a directory is created as part of git clone', but is empty in the revision switched to with git checkout'.

In this situation, the tree we are going to build ought not to contain this directory, because that directory will not (in general) be produced, eg when the revision being switched to becomes master.

We can use git clean to produce a working tree whose contents - including the presence or absence of empty directories - depends only on the commit we are trying to check out, and not on the previous states of the git history or working tree.

For example, if a directory is made empty (ie, deleted, since git does not distinguish) in xen.git#staging, osstest's clones of xen.git#master will produce the directory, but `git checkout' of staging won't delete it. If the xen.git build system mistakenly depends on this directory, we won't detect this until the deletion reaches master. This situation actually occurred with xen.git#598e97f "tools/python: remove broken xl binding" (fixed in b261366f).

---
 Osstest/TestSupport.pm |    1 +
 1 file changed, 1 insertion(+)
Osstest/TestSupport.pm +1 -0
index f9eba6b..aa41952 100644
@@ -1231,6 +1231,7 @@ END
 END
                          (length($r{"revision_$which"}) ? <<END : ''));
 	    git checkout '$r{"revision_$which"}'
+	    git clean -xdf
 END
     } else {
         die "$vcs $which $tree ?";
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Ian Jackson

This may seem redundant, however:

git does not track empty directories. So it can happen that a directory is created as part of git clone', but is empty in the revision switched to with git checkout'.

In this situation, the tree we are going to build ought not to contain this directory, because that directory will not (in general) be produced, eg when the revision being switched to becomes master.

We can use git clean to produce a working tree whose contents - including the presence or absence of empty directories - depends only on the commit we are trying to check out, and not on the previous states of the git history or working tree.

For example, if a directory is made empty (ie, deleted, since git does not distinguish) in xen.git#staging, osstest's clones of xen.git#master will produce the directory, but `git checkout' of staging won't delete it. If the xen.git build system mistakenly depends on this directory, we won't detect this until the deletion reaches master. This situation actually occurred with xen.git#598e97f "tools/python: remove broken xl binding" (fixed in b261366f).

Quoted 2 lines
Quoted 16 lines
---
 Osstest/TestSupport.pm |    1 +
 1 file changed, 1 insertion(+)
Osstest/TestSupport.pm +1 -0
index f9eba6b..aa41952 100644
@@ -1231,6 +1231,7 @@ END
 END
                          (length($r{"revision_$which"}) ? <<END : ''));
 	    git checkout '$r{"revision_$which"}'
+	    git clean -xdf
 END
     } else {
         die "$vcs $which $tree ?";
Acked-by
#2 lore raw
Quoted 24 lines · Andrew Cooper
Quoted 23 lines · Ian Jackson

This may seem redundant, however:

git does not track empty directories. So it can happen that a directory is created as part of git clone', but is empty in the revision switched to with git checkout'.

In this situation, the tree we are going to build ought not to contain this directory, because that directory will not (in general) be produced, eg when the revision being switched to becomes master.

We can use git clean to produce a working tree whose contents - including the presence or absence of empty directories - depends only on the commit we are trying to check out, and not on the previous states of the git history or working tree.

For example, if a directory is made empty (ie, deleted, since git does not distinguish) in xen.git#staging, osstest's clones of xen.git#master will produce the directory, but `git checkout' of staging won't delete it. If the xen.git build system mistakenly depends on this directory, we won't detect this until the deletion reaches master. This situation actually occurred with xen.git#598e97f "tools/python: remove broken xl binding" (fixed in b261366f).

Quoted 4 lines
Quoted 2 lines