diff mbox series

bitbake: fetch2: git: revert path checks

Message ID 20230913084032.19477-1-mikko.rapeli@linaro.org
State New
Headers show
Series bitbake: fetch2: git: revert path checks | expand

Commit Message

Mikko Rapeli Sept. 13, 2023, 8:40 a.m. UTC
Commit 10f38157a069cb6938323cadd5e523037a29ace9
triggers re-clones of uptodate repositories when their
access path changes. This is wrong. It is enough that
needed commits are found from the git repo. For example
when same DL_DIR is accessed using two different paths
due to a symlink, then the resulting absolute paths will
differ but the content is the same. Trust the content.

Avoids extra downloads of large repositories like linux-yocto
for kernel when the local cache was already uptodate.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 bitbake/lib/bb/fetch2/git.py | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index e11271b757..0c547ea303 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -371,19 +371,7 @@  class Git(FetchMethod):
             # The directory may exist, but not be the top level of a bare git
             # repository in which case it needs to be deleted and re-cloned.
             try:
-                # Since clones can be bare, use --absolute-git-dir instead of --show-toplevel
-                output = runfetchcmd("LANG=C %s rev-parse --absolute-git-dir" % ud.basecmd, d, workdir=ud.clonedir)
-
-                toplevel = os.path.abspath(output.rstrip())
-                abs_clonedir = os.path.abspath(ud.clonedir).rstrip('/')
-                # The top level Git directory must either be the clone directory
-                # or a child of the clone directory. Any ancestor directory of
-                # the clone directory is not valid as the Git directory (and
-                # probably belongs to some other unrelated repository), so a
-                # clone is required
-                if os.path.commonprefix([abs_clonedir, toplevel]) != abs_clonedir:
-                    logger.warning("Top level directory '%s' doesn't match expected '%s'. Re-cloning", toplevel, ud.clonedir)
-                    needs_clone = True
+                runfetchcmd("LANG=C %s rev-parse --absolute-git-dir" % ud.basecmd, d, workdir=ud.clonedir)
             except bb.fetch2.FetchError as e:
                 logger.warning("Unable to get top level for %s (not a git directory?): %s", ud.clonedir, e)
                 needs_clone = True