Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Fix errors when clone.bundle missing on server
Browse files Browse the repository at this point in the history
Catch curl failures to download clone.bundle; don't let git try to parse
the 404 page as a bundle file (was causing much user confusion).

This should eliminate false error messages from init and sync such as:
  error: '.repo/manifests.git/clone.bundle' does not look like a v2 bundle file
  fatal: Could not read bundle '.repo/manifests.git/clone.bundle'.
  error: RPC failed; result=22, HTTP code = 400

Signed-off-by: Matt Gumbel <matthew.k.gumbel@intel.com>
Change-Id: I7994f7c0baecfb45bb5a5850c48bd2a0ffabe773
  • Loading branch information
intelmatt authored and gerrit code review committed Sep 6, 2012
1 parent bb1b5f5 commit 2dc810c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions project.py
Expand Up @@ -1529,7 +1529,7 @@ def _FetchBundle(self, srcUrl, tmpPath, dstPath, quiet):
if os.path.exists(dstPath):
os.remove(dstPath)

cmd = ['curl', '--output', tmpPath, '--netrc', '--location']
cmd = ['curl', '--fail', '--output', tmpPath, '--netrc', '--location']
if quiet:
cmd += ['--silent']
if os.path.exists(tmpPath):
Expand All @@ -1549,9 +1549,19 @@ def _FetchBundle(self, srcUrl, tmpPath, dstPath, quiet):
except OSError:
return False

ok = proc.wait() == 0
curlret = proc.wait()

if curlret == 22:
# From curl man page:
# 22: HTTP page not retrieved. The requested url was not found or
# returned another error with the HTTP error code being 400 or above.
# This return code only appears if -f, --fail is used.
if not quiet:
print >> sys.stderr, "Server does not provide clone.bundle; ignoring."
return False

if os.path.exists(tmpPath):
if ok and os.stat(tmpPath).st_size > 16:
if curlret == 0 and os.stat(tmpPath).st_size > 16:
os.rename(tmpPath, dstPath)
return True
else:
Expand Down

0 comments on commit 2dc810c

Please sign in to comment.