threads / patch / 43698

patch, 3 partsRe: [PATCH 1/3] Allow short pack names to git-pack-objects --unpacked=.

Subject: Re: [PATCH 1/3] Allow short pack names to git-pack-objects --unpacked=.

## tl;dr

2 messages between Oct 29, 2006 and Oct 29, 2006. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Shawn Pearce· Oct 29, 2006, 09:37 UTC · lore

[PATCH 1/3] Allow short pack names to git-pack-objects --unpacked=.

Allow short pack names to git-pack-objects --unpacked=.

This allows us to pass just the file name of a pack rather than the complete path when we want pack-objects to consider its contents as though they were loose objects. This can be helpful if $GIT_OBJECT_DIRECTORY contains shell metacharacters which make it cumbersome to pass complete paths safely in a shell script.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 sha1_file.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
Show changes to sha1_file.c +19 −1
diff --git a/sha1_file.c b/sha1_file.c
index e89d24c..5e6c8b8 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1203,6 +1203,24 @@ unsigned long find_pack_entry_one(const
 	return 0;
 }
 
+static int matches_pack_name(struct packed_git *p, const char *ig)
+{
+	const char *last_c, *c;
+
+	if (!strcmp(p->pack_name, ig))
+		return 0;
+
+	for (c = p->pack_name, last_c = c; *c;)
+		if (*c == '/')
+			last_c = ++c;
+		else
+			++c;
+	if (!strcmp(last_c, ig))
+		return 0;
+
+	return 1;
+}
+
 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
 {
 	struct packed_git *p;
@@ -1214,7 +1232,7 @@ static int find_pack_entry(const unsigne
 		if (ignore_packed) {
 			const char **ig;
 			for (ig = ignore_packed; *ig; ig++)
-				if (!strcmp(p->pack_name, *ig))
+				if (!matches_pack_name(p, *ig))
 					break;
 			if (*ig)
 				continue;
-- 
1.4.3.3.g7d63
Shawn Pearce· Oct 29, 2006, 09:44 UTC · re: Shawn Pearce · lore
Ok, I'm a freaking idiot:
> Subject: [PATCH 1/3] Allow short pack names to git-pack-objects --unpacked=.
> 
> Allow short pack names to git-pack-objects --unpacked=.

I meant to delete the first two lines of the body of the message before sending so that git-am didn't stutter the first line of the commit message when applied, yet I managed to not do that. *sigh*

← back to recent threads