diff options
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index e11271b757..4385d0b37a 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -373,20 +373,17 @@ class Git(FetchMethod): | |||
373 | try: | 373 | try: |
374 | # Since clones can be bare, use --absolute-git-dir instead of --show-toplevel | 374 | # Since clones can be bare, use --absolute-git-dir instead of --show-toplevel |
375 | output = runfetchcmd("LANG=C %s rev-parse --absolute-git-dir" % ud.basecmd, d, workdir=ud.clonedir) | 375 | output = runfetchcmd("LANG=C %s rev-parse --absolute-git-dir" % ud.basecmd, d, workdir=ud.clonedir) |
376 | toplevel = output.rstrip() | ||
376 | 377 | ||
377 | toplevel = os.path.abspath(output.rstrip()) | 378 | if not bb.utils.path_is_descendant(toplevel, ud.clonedir): |
378 | abs_clonedir = os.path.abspath(ud.clonedir).rstrip('/') | 379 | logger.warning("Top level directory '%s' is not a descendant of '%s'. Re-cloning", toplevel, ud.clonedir) |
379 | # The top level Git directory must either be the clone directory | ||
380 | # or a child of the clone directory. Any ancestor directory of | ||
381 | # the clone directory is not valid as the Git directory (and | ||
382 | # probably belongs to some other unrelated repository), so a | ||
383 | # clone is required | ||
384 | if os.path.commonprefix([abs_clonedir, toplevel]) != abs_clonedir: | ||
385 | logger.warning("Top level directory '%s' doesn't match expected '%s'. Re-cloning", toplevel, ud.clonedir) | ||
386 | needs_clone = True | 380 | needs_clone = True |
387 | except bb.fetch2.FetchError as e: | 381 | except bb.fetch2.FetchError as e: |
388 | logger.warning("Unable to get top level for %s (not a git directory?): %s", ud.clonedir, e) | 382 | logger.warning("Unable to get top level for %s (not a git directory?): %s", ud.clonedir, e) |
389 | needs_clone = True | 383 | needs_clone = True |
384 | except FileNotFoundError as e: | ||
385 | logger.warning("%s", e) | ||
386 | needs_clone = True | ||
390 | 387 | ||
391 | if needs_clone: | 388 | if needs_clone: |
392 | shutil.rmtree(ud.clonedir) | 389 | shutil.rmtree(ud.clonedir) |