Skip to contentSkip to conversation

fetch2/git: Fix trailing slash in clone command causing double slash in alternates

PATCH New Jamin Lin 1 participant 2 messages May 15

lore
Share & tools
lore

Jamin Lin

author
#0 lore raw

PATCH 1/1 fetch2/git: Fix trailing slash in clone command causing double slash in alternates

The unpack() method constructs the git clone command with a trailing slash appended to ud.clonedir:

git clone -s <clonedir>/ <destdir>

When git processes 'clone -s', it writes the source object path into <destdir>/.git/objects/info/alternates by appending '/objects' to the source path. The extra trailing slash produces a double slash:

<clonedir>//objects

Newer versions of git refuse to normalize this path and report:

error: unable to normalize alternate object path: <path>//objects
fatal: bad object HEAD

Remove the spurious trailing slash so the alternates file contains a valid, normalizable path.

---
 lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/git.py +1 -1
index 01bebb764..b2b39549d 100644
@@ -697,7 +697,7 @@ class Git(FetchMethod):
             if update and os.path.exists(destdir):
                 update_mode = True
             else:
-                runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
+                runfetchcmd("%s clone %s %s %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
             source_found = True
         else:
             source_error.append("clone directory not available or not up to date: " + ud.clonedir)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/1 fetch2/git: Fix trailing slash in clone command causing double slash in alternates

The unpack() method constructs the git clone command with a trailing slash appended to ud.clonedir:

git clone -s <clonedir>/ <destdir>

When git processes 'clone -s', it writes the source object path into <destdir>/.git/objects/info/alternates by appending '/objects' to the source path. The extra trailing slash produces a double slash:

<clonedir>//objects

Newer versions of git refuse to normalize this path and report:

error: unable to normalize alternate object path: <path>//objects
fatal: bad object HEAD

Remove the spurious trailing slash so the alternates file contains a valid, normalizable path.

---
 lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/fetch2/git.py +1 -1
index 01bebb764..b2b39549d 100644
@@ -697,7 +697,7 @@ class Git(FetchMethod):
             if update and os.path.exists(destdir):
                 update_mode = True
             else:
-                runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
+                runfetchcmd("%s clone %s %s %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
             source_found = True
         else:
             source_error.append("clone directory not available or not up to date: " + ud.clonedir)
Signature · 1 line
2.43.0