git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-clone --reference problem?

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 23, 2006, 18:34 UTC
Message-ID
<Pine.LNX.4.64.0604231122490.3701@g5.osdl.org>
In-Reply-To
<1145810080.16166.223.camel@shinybook.infradead.org>
On Sun, 23 Apr 2006, David Woodhouse wrote:
>
> Should I expect cloning with alternates using '--reference' to be
> transitive?
Well, certainly not now.
> Using '--reference clone1 --reference linux-2.6' for the second clone
> works OK, but surely it ought to work with just '--reference clone1'? 

Actually, I don't think using "--reference clone1 --reference linux-2.6" works OK at all - in the sense that it doesn't do what you _think_ it does.

It doesn't use two reference repos at all: it uses just one, which is the last one (ie linux-2.6).

Maybe something like this could work.

Untested, of course. It probably isn't even syntactically correct shell. Whatever. You get the idea.

(That while-loop could probably be simplified to just a 
  cat ""$reference/objects/info/alternates" >> "$GIT_DIR/objects/info/alternates"

because all alternates _should_ already be absolute paths, but hey, whatever. I also forget whether we decided that non-absolute paths were relative to the $reference directory, or to the $reference/objects/ directory. The while-loop should be fixed to match whatever that decision was (or just not accept anything but absolute paths: make it use a

	grep '^/' ..
instead of "cat"?)
		Linus
---
diff --git a/git-clone.sh b/git-clone.sh
index 0805168..df4c135 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -221,6 +221,13 @@ then
 		fi
 		reference=$(cd "$reference" && pwd)
 		echo "$reference/objects" >"$GIT_DIR/objects/info/alternates"
+		if test -s "$reference/objects/info/alternates"
+		then
+			while read alt
+			do
+				echo $(cd "$reference" && cd "$alt" && pwd) >> "$GIT_DIR/objects/info/alternates"
+			done < "$reference/objects/info/alternates"
+		fi
 		(cd "$reference" && tar cf - refs) |
 		(cd "$GIT_DIR/refs" &&
 		 mkdir reference-tmp &&
Previous: Junio C HamanoNext: Linus Torvalds
Message 3 of 5 in “git-clone --reference problem?”
  1. David WoodhouseApr 23, 2006
  2. Junio C HamanoApr 23, 2006
  3. Linus TorvaldsApr 23, 2006
  4. Linus TorvaldsApr 23, 2006
  5. Junio C HamanoApr 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.