@matheusbsbs / matheus-bagliano / commits / d4ff6d92c3
Fork 0

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> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn Pearce committed Oct 29, 2006 at 04:37 UTC d4ff6d92c3d7020233a9b4990a3545ee54a5c033
1 file changed +19 -1
sha1_file.c
+19 -1
@@ -1203,6 +1203,24 @@ unsigned long find_pack_entry_one(const unsigned char *sha1,
1203 return 0;
1204 }
1205
1206 +static int matches_pack_name(struct packed_git *p, const char *ig)
1207 +{
1208 + const char *last_c, *c;
1209 +
1210 + if (!strcmp(p->pack_name, ig))
1211 + return 0;
1212 +
1213 + for (c = p->pack_name, last_c = c; *c;)
1214 + if (*c == '/')
1215 + last_c = ++c;
1216 + else
1217 + ++c;
1218 + if (!strcmp(last_c, ig))
1219 + return 0;
1220 +
1221 + return 1;
1222 +}
1223 +
1224 static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
1225 {
1226 struct packed_git *p;
@@ -1214,7 +1232,7 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
1232 if (ignore_packed) {
1233 const char **ig;
1234 for (ig = ignore_packed; *ig; ig++)
1217 - if (!strcmp(p->pack_name, *ig))
1235 + if (!matches_pack_name(p, *ig))
1236 break;
1237 if (*ig)
1238 continue;