Skip to contentSkip to conversation

git-tar-tree: Lift path length limit

PATCH In review Rene Scharfe 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-tar-tree: Lift path length limit

Last minute patch? This lifts the limits from path length and link path length that are in git-tar-tree.

Have a nice vacation!

Rene

---
commit 2d7b8f2afc47c753aaab4bf48587fdea730b0db3
tree 378fae86e43460c1c53feccbde3573ced26818f6
parent a02ebff6127c5fc981668fb570f0a80f2b7657ca
author Rene Scharfe <[email protected]> 1115320521 +0200 committer Rene Scharfe <[email protected]> 1115320521 +0200

tar-tree.c (mode:100644 sha1:0fb6514c27a0f0edc2fc6e9850c361c8a58c0a9f) renamed from tar-tree.c (mode:100644 sha1:a09cb416595094e493a52dd7f45d943c81c0310a) +6 -8
Index: tar-tree.c
===================================================================
@@ -212,7 +212,7 @@
                                   const char *path, unsigned int namelen,
                                   void *content, unsigned int contentsize)
 {
-	char *p;
+	char *buffer, *p;
 	unsigned int pathlen, size, linkpathlen = 0;
 
 	size = pathlen = extended_header_len("path", namelen);
@@ -220,18 +220,18 @@
 		linkpathlen = extended_header_len("linkpath", contentsize);
 		size += linkpathlen;
 	}
-	if (size > RECORDSIZE)
-		die("tar-tree: extended header too big, wtf?");
 	write_header(NULL, TYPEFLAG_EXT_HEADER, NULL, NULL, headerfilename,
 	             0100600, NULL, size);
 
-	p = get_record();
+	buffer = p = malloc(size);
+	if (!buffer)
+		die("git-tar-tree: %s", strerror(errno));
 	append_extended_header_prefix(&p, pathlen, "path");
 	append_path(&p, is_dir, basepath, prefix, path);
 	append_char(&p, '\n');
 	if (flags & EXT_HEADER_LINKPATH)
 		append_extended_header(&p, "linkpath", content, contentsize);
-	write_if_needed();
+	write_blocked(buffer, size);
 }
 
 static void write_global_extended_header(const char *sha1)
@@ -269,9 +269,7 @@
 	}
 
 	namelen = path_len(S_ISDIR(mode), basepath, prefix, path);
-	if (namelen > 500)
-		die("tar-tree: name too log of object %s\n", sha1_to_hex(sha1));
-	else if (namelen > 100)
+	if (namelen > 100)
 		ext_header |= EXT_HEADER_PATH;
 	if (typeflag == TYPEFLAG_LNK && size > 100)
 		ext_header |= EXT_HEADER_LINKPATH;
#1 lore raw
Quoted 1 line · Rene Scharfe

Last minute patch?

This leaks memory. D'oh!

Petr, would you add the (hopefully) fixed version below to your tree now that Linus is on vacation? (Patch applies to tip of GIT tree.)

Thanks,
Rene

Lift path length limits from git-tar-tree.

---
commit d36797f64ee0431e6a73aa1c77a7fe7c18b6ce9f
tree ab8e6967a08ac343b69b527f663e6a9722fcea08
parent bf60144c0ab50e88c0086a90c5cb35b81613ad14
author Rene Scharfe <[email protected]> 1115322098 +0200 committer Rene Scharfe <[email protected]> 1115322098 +0200

tar-tree.c (mode:100644 sha1:8b0d75bd2cf12a531aee3d51e59a8ac8102ba6be) renamed from tar-tree.c (mode:100644 sha1:9d9bd7be98502f64e4a643ef0973182f3483251e) +7 -8
Index: tar-tree.c
===================================================================
@@ -212,7 +212,7 @@
                                   const char *path, unsigned int namelen,
                                   void *content, unsigned int contentsize)
 {
-	char *p;
+	char *buffer, *p;
 	unsigned int pathlen, size, linkpathlen = 0;
 
 	size = pathlen = extended_header_len("path", namelen);
@@ -220,18 +220,19 @@
 		linkpathlen = extended_header_len("linkpath", contentsize);
 		size += linkpathlen;
 	}
-	if (size > RECORDSIZE)
-		die("tar-tree: extended header too big, wtf?");
 	write_header(NULL, TYPEFLAG_EXT_HEADER, NULL, NULL, headerfilename,
 	             0100600, NULL, size);
 
-	p = get_record();
+	buffer = p = malloc(size);
+	if (!buffer)
+		die("git-tar-tree: %s", strerror(errno));
 	append_extended_header_prefix(&p, pathlen, "path");
 	append_path(&p, is_dir, basepath, prefix, path);
 	append_char(&p, '\n');
 	if (flags & EXT_HEADER_LINKPATH)
 		append_extended_header(&p, "linkpath", content, contentsize);
-	write_if_needed();
+	write_blocked(buffer, size);
+	free(buffer);
 }
 
 static void write_global_extended_header(const char *sha1)
@@ -269,9 +270,7 @@
 	}
 
 	namelen = path_len(S_ISDIR(mode), basepath, prefix, path);
-	if (namelen > 500)
-		die("tar-tree: name too log of object %s\n", sha1_to_hex(sha1));
-	else if (namelen > 100)
+	if (namelen > 100)
 		ext_header |= EXT_HEADER_PATH;
 	if (typeflag == TYPEFLAG_LNK && size > 100)
 		ext_header |= EXT_HEADER_LINKPATH;
#2 lore raw

Dear diary, on Sat, May 07, 2005 at 02:57:06AM CEST, I got a letter where Rene Scharfe <[email protected]> told me that...

Quoted 7 lines · Rene Scharfe
Quoted 1 line

Last minute patch?

This leaks memory. D'oh!

Petr, would you add the (hopefully) fixed version below to your tree now that Linus is on vacation? (Patch applies to tip of GIT tree.)

It appears to me that the patch currently in the git tree is this (correct) one?

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"PB" == Petr Baudis <[email protected]> writes:

PB> Dear diary, on Sat, May 07, 2005 at 02:57:06AM CEST, I got a letter PB> where Rene Scharfe <[email protected]> told me that...

Quoted 7 lines
Quoted 7 lines · Rene Scharfe
Quoted 1 line

Last minute patch?

This leaks memory. D'oh!

Petr, would you add the (hopefully) fixed version below to your tree now that Linus is on vacation? (Patch applies to tip of GIT tree.)

PB> It appears to me that the patch currently in the git tree is this PB> (correct) one?

Yes it was merged before Linus left the machine last night.