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

Re: Problem with cg-clone

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 29, 2005, 19:57 UTC
Message-ID
<Pine.LNX.4.64.0510291255230.3348@g5.osdl.org>
In-Reply-To
<7vacgs157c.fsf@assigned-by-dhcp.cox.net>
On Sat, 29 Oct 2005, Junio C Hamano wrote:
Show 12 quoted lines
>
> Marcel Holtmann <marcel@holtmann.org> writes:
> 
> > Previously this was working fine and since cogito hasn't changed the
> > last few days, I suspect that git is at fault here or changed something.
> > Any ideas?
> 
> I think I know what is going on.
> 
> git-init-db does not create .git/objects/[0-9a-f]{2}/
> directories anymore, but git-local-fetch has not taught to
> create them on demand.
Here's a quick hack, totally untested, of course.

More properly it should use move_temp_to_file(), but if you're about to do a v0.99.9 release, maybe this could be good enough.

		Linus
---
diff --git a/local-fetch.c b/local-fetch.c
index 87a93de..21f5bf8 100644
--- a/local-fetch.c
+++ b/local-fetch.c
@@ -52,9 +52,20 @@ static int setup_indices(void)
 	return 0;
 }
 
-static int copy_file(const char *source, const char *dest, const char *hex,
+static int copy_file(const char *source, char *dest, const char *hex,
 		     int warn_if_not_exists)
 {
+	char *dir = strrchr(dest, '/');
+
+	if (dir) {
+		*dir = 0;
+		if (mkdir(dir, 0777)) {
+			if (errno != EEXIST)
+				perror(dir);
+		}
+		*dir = '/';
+	}
+
 	if (use_link) {
 		if (!link(source, dest)) {
 			pull_say("link %s\n", hex);
@@ -150,7 +161,7 @@ static int fetch_file(const unsigned cha
 	static int object_name_start = -1;
 	static char filename[PATH_MAX];
 	char *hex = sha1_to_hex(sha1);
-	const char *dest_filename = sha1_file_name(sha1);
+	char *dest_filename = sha1_file_name(sha1);
 
  	if (object_name_start < 0) {
 		strcpy(filename, path); /* e.g. git.git */
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “Problem with cg-clone”
  1. Marcel HoltmannOct 29, 2005
  2. Junio C HamanoOct 29, 2005
  3. Linus TorvaldsOct 29, 2005
  4. Junio C HamanoOct 29, 2005
  5. Marcel HoltmannOct 29, 2005
  6. Junio C HamanoOct 29, 2005

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.