Skip to contentSkip to conversation

Problem with cg-clone

DISCUSSION Marcel Holtmann 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi guys,

I installed the latest git and cogito from their repositories and now the local clone command is failing:

# cg-clone linux-2.6 test-2.6
defaulting to local storage area
Using hard links
`/data/kernel/linux-2.6/.git/HEAD' -> `.git/refs/heads/.origin-fetching'
error: Couldn't find 8a212ab6b8a4ccc6f3c3d1beba5f92655c576404: not separate or in any pack
Cannot obtain needed object 8a212ab6b8a4ccc6f3c3d1beba5f92655c576404
while processing commit 0000000000000000000000000000000000000000.
cg-fetch: objects fetch failed
cg-clone: fetch failed

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?

Regards

Marcel

#1 lore raw
Quoted 3 lines · Marcel Holtmann

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.

#2 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 3 lines · Marcel Holtmann

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?

Quoted 5 lines

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

---

local-fetch.c +13 -2
index 87a93de..21f5bf8 100644
@@ -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 */
#3 lore raw
In reply to Marcel Holtmann
Quoted 12 lines · Marcel Holtmann

I installed the latest git and cogito from their repositories and now the local clone command is failing:

# cg-clone linux-2.6 test-2.6
defaulting to local storage area
Using hard links
`/data/kernel/linux-2.6/.git/HEAD' -> `.git/refs/heads/.origin-fetching'
error: Couldn't find 8a212ab6b8a4ccc6f3c3d1beba5f92655c576404: not separate or in any pack
Cannot obtain needed object 8a212ab6b8a4ccc6f3c3d1beba5f92655c576404
while processing commit 0000000000000000000000000000000000000000.
cg-fetch: objects fetch failed
cg-clone: fetch failed

The attached patch should fix git-local-fetch which I think the above problem is. git-clone -l -s would be much faster if you are doing a local clone, however.

---

local-fetch.c +3 -2
index 87a93de..0a07114 100644
@@ -52,9 +52,10 @@ 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)
 {
+	safe_create_leading_directories(dest);
 	if (use_link) {
 		if (!link(source, dest)) {
 			pull_say("link %s\n", hex);
@@ -150,7 +151,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 */
#4 lore raw

Hi Junio,

Quoted 13 lines
Quoted 12 lines

I installed the latest git and cogito from their repositories and now the local clone command is failing:

# cg-clone linux-2.6 test-2.6
defaulting to local storage area
Using hard links
`/data/kernel/linux-2.6/.git/HEAD' -> `.git/refs/heads/.origin-fetching'
error: Couldn't find 8a212ab6b8a4ccc6f3c3d1beba5f92655c576404: not separate or in any pack
Cannot obtain needed object 8a212ab6b8a4ccc6f3c3d1beba5f92655c576404
while processing commit 0000000000000000000000000000000000000000.
cg-fetch: objects fetch failed
cg-clone: fetch failed
Quoted 3 lines

The attached patch should fix git-local-fetch which I think the above problem is. git-clone -l -s would be much faster if you are doing a local clone, however.

I can confirm that with this patch everything is back to normal.

Regards

Marcel

#5 lore raw
Quoted 5 lines · Marcel Holtmann
Quoted 3 lines

The attached patch should fix git-local-fetch which I think the above problem is. git-clone -l -s would be much faster if you are doing a local clone, however.

I can confirm that with this patch everything is back to normal.

Thanks. What Linus separately done (funny we did that two-minutes apart) amounts to the same thing.