From: Petr Štetiar Date: Tue, 9 Feb 2021 21:21:15 +0000 (+0100) Subject: phase1: fix gitcheckout with corrupted .git X-Git-Tag: v1~51 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=976b2fd5170db09a34985d8d479a6d45dc214787;p=buildbot.git phase1: fix gitcheckout with corrupted .git When the container running `git clone` is killed it will leave the .git directory in unusable state which then leads in the following errors: if [ -d .git ]; then git checkout -f master; git branch --set-upstream-to origin/master; else exit 0; fi error: pathspec 'master' did not match any file(s) known to git. fatal: branch 'master' does not exist Fix it by removing .git completely if this happens, otherwise it might simply leave shared build directory in the unusable state. Signed-off-by: Petr Štetiar --- diff --git a/phase1/master.cfg b/phase1/master.cfg index 7186f5a..2cba85e 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -710,7 +710,7 @@ for target in targets: factory.addStep(ShellCommand( name = "gitcheckout", description = "Ensure that Git HEAD is sane", - command = "if [ -d .git ]; then git checkout -f %s; git branch --set-upstream-to origin/%s; else exit 0; fi" %(repo_branch, repo_branch), + command = "if [ -d .git ]; then git checkout -f %s && git branch --set-upstream-to origin/%s || rm -fr .git; else exit 0; fi" %(repo_branch, repo_branch), haltOnFailure = True)) # check out the source