mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Handle case where 'git remote prune' needs to be run
Handle the case when this error occurs: error: some local refs could not be updated; try running 'git remote prune origin' to remove any old, conflicting branches This is usually caused by a reference getting changed from a file to a directory. For example: Initially someone creates a branch 'foo' and it is stored as: .git/refs/remotes/origin/foo Then later on it is decided to change the layout structure where 'foo' is a directory with branches below it: .git/refs/remotes/origin/foo/master The problem occurs when someone still has '.git/refs/remotes/origin/foo' on their system and does a repo sync. When this occurs the error message for needing to do a 'git remote prune origin' occurs. Now when doing a 'git fetch' if the error message from git says that a 'git remote prune' is needed, it will do the prune and then retry the fetch. Change-Id: I4c6f5aa6bd932f0ef7a39134400bedd52e82f633 Signed-off-by: John L. Villalovos <john.l.villalovos@intel.com>
This commit is contained in:
parent
24245e0094
commit
126e298214
14
project.py
14
project.py
@ -1871,10 +1871,22 @@ class Project(object):
|
|||||||
|
|
||||||
ok = False
|
ok = False
|
||||||
for _i in range(2):
|
for _i in range(2):
|
||||||
ret = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy).Wait()
|
gitcmd = GitCommand(self, cmd, bare=True, capture_stderr=True,
|
||||||
|
ssh_proxy=ssh_proxy)
|
||||||
|
ret = gitcmd.Wait()
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
ok = True
|
ok = True
|
||||||
break
|
break
|
||||||
|
# If needed, run the 'git remote prune' the first time through the loop
|
||||||
|
elif (not _i and
|
||||||
|
"error:" in gitcmd.stderr and
|
||||||
|
"git remote prune" in gitcmd.stderr):
|
||||||
|
prunecmd = GitCommand(self, ['remote', 'prune', name], bare=True,
|
||||||
|
capture_stderr=True, ssh_proxy=ssh_proxy)
|
||||||
|
if prunecmd.Wait():
|
||||||
|
print(prunecmd.stderr, file=sys.stderr)
|
||||||
|
break
|
||||||
|
continue
|
||||||
elif current_branch_only and is_sha1 and ret == 128:
|
elif current_branch_only and is_sha1 and ret == 128:
|
||||||
# Exit code 128 means "couldn't find the ref you asked for"; if we're in sha1
|
# Exit code 128 means "couldn't find the ref you asked for"; if we're in sha1
|
||||||
# mode, we just tried sync'ing from the upstream field; it doesn't exist, thus
|
# mode, we just tried sync'ing from the upstream field; it doesn't exist, thus
|
||||||
|
Loading…
Reference in New Issue
Block a user