aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin-count-objects.c2
-rw-r--r--builtin-prune-packed.c2
-rw-r--r--cache.h2
-rw-r--r--revision.c24
-rw-r--r--revision.h6
-rw-r--r--sha1_file.c26
6 files changed, 47 insertions, 15 deletions
diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index 1d3729aa9..73c598242 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -62,7 +62,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
hex[40] = 0;
if (get_sha1_hex(hex, sha1))
die("internal error");
- if (has_sha1_pack(sha1))
+ if (has_sha1_pack(sha1, NULL))
(*packed_loose)++;
}
}
diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c
index d3dd94d9e..960db4985 100644
--- a/builtin-prune-packed.c
+++ b/builtin-prune-packed.c
@@ -19,7 +19,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len)
memcpy(hex+2, de->d_name, 38);
if (get_sha1_hex(hex, sha1))
continue;
- if (!has_sha1_pack(sha1))
+ if (!has_sha1_pack(sha1, NULL))
continue;
memcpy(pathname + len, de->d_name, 38);
if (dryrun)
diff --git a/cache.h b/cache.h
index a53204f6d..ac51ed1d2 100644
--- a/cache.h
+++ b/cache.h
@@ -259,7 +259,7 @@ extern int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
extern int write_sha1_to_fd(int fd, const unsigned char *sha1);
extern int move_temp_to_file(const char *tmpfile, const char *filename);
-extern int has_sha1_pack(const unsigned char *sha1);
+extern int has_sha1_pack(const unsigned char *sha1, const char **ignore);
extern int has_sha1_file(const unsigned char *sha1);
extern void *map_sha1_file(const unsigned char *sha1, unsigned long *);
extern int legacy_loose_object(unsigned char *);
diff --git a/revision.c b/revision.c
index db0168275..6a2539b62 100644
--- a/revision.c
+++ b/revision.c
@@ -416,7 +416,8 @@ static void limit_list(struct rev_info *revs)
if (revs->max_age != -1 && (commit->date < revs->max_age))
obj->flags |= UNINTERESTING;
- if (revs->unpacked && has_sha1_pack(obj->sha1))
+ if (revs->unpacked &&
+ has_sha1_pack(obj->sha1, revs->ignore_packed))
obj->flags |= UNINTERESTING;
add_parents_to_list(revs, commit, &list);
if (obj->flags & UNINTERESTING) {
@@ -671,6 +672,16 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
return 0;
}
+static void add_ignore_packed(struct rev_info *revs, const char *name)
+{
+ int num = ++revs->num_ignore_packed;
+
+ revs->ignore_packed = xrealloc(revs->ignore_packed,
+ sizeof(const char **) * (num + 1));
+ revs->ignore_packed[num-1] = name;
+ revs->ignore_packed[num] = NULL;
+}
+
/*
* Parse revision information, filling in the "rev_info" structure,
* and removing the used arguments from the argument list.
@@ -811,6 +822,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
}
if (!strcmp(arg, "--unpacked")) {
revs->unpacked = 1;
+ free(revs->ignore_packed);
+ revs->ignore_packed = NULL;
+ revs->num_ignore_packed = 0;
+ continue;
+ }
+ if (!strncmp(arg, "--unpacked=", 11)) {
+ revs->unpacked = 1;
+ add_ignore_packed(revs, arg+11);
continue;
}
if (!strcmp(arg, "-r")) {
@@ -1057,7 +1076,8 @@ struct commit *get_revision(struct rev_info *revs)
*/
if (!revs->limited) {
if ((revs->unpacked &&
- has_sha1_pack(commit->object.sha1)) ||
+ has_sha1_pack(commit->object.sha1,
+ revs->ignore_packed)) ||
(revs->max_age != -1 &&
(commit->date < revs->max_age)))
continue;
diff --git a/revision.h b/revision.h
index c1f71afe6..a5c35d05c 100644
--- a/revision.h
+++ b/revision.h
@@ -38,7 +38,7 @@ struct rev_info {
blob_objects:1,
edge_hint:1,
limited:1,
- unpacked:1,
+ unpacked:1, /* see also ignore_packed below */
boundary:1,
parents:1;
@@ -57,6 +57,10 @@ struct rev_info {
unsigned int shown_one:1,
abbrev_commit:1,
relative_date:1;
+
+ const char **ignore_packed; /* pretend objects in these are unpacked */
+ int num_ignore_packed;
+
unsigned int abbrev;
enum cmit_fmt commit_format;
struct log_info *loginfo;
diff --git a/sha1_file.c b/sha1_file.c
index 428d791ba..d5d048af6 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1189,12 +1189,20 @@ int find_pack_entry_one(const unsigned char *sha1,
return 0;
}
-static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
+static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
{
struct packed_git *p;
prepare_packed_git();
for (p = packed_git; p; p = p->next) {
+ if (ignore_packed) {
+ const char **ig;
+ for (ig = ignore_packed; *ig; ig++)
+ if (!strcmp(p->pack_name, *ig))
+ break;
+ if (*ig)
+ continue;
+ }
if (find_pack_entry_one(sha1, e, p))
return 1;
}
@@ -1227,10 +1235,10 @@ int sha1_object_info(const unsigned char *sha1, char *type, unsigned long *sizep
if (!map) {
struct pack_entry e;
- if (find_pack_entry(sha1, &e))
+ if (find_pack_entry(sha1, &e, NULL))
return packed_object_info(&e, type, sizep);
reprepare_packed_git();
- if (find_pack_entry(sha1, &e))
+ if (find_pack_entry(sha1, &e, NULL))
return packed_object_info(&e, type, sizep);
return error("unable to find %s", sha1_to_hex(sha1));
}
@@ -1253,7 +1261,7 @@ static void *read_packed_sha1(const unsigned char *sha1, char *type, unsigned lo
{
struct pack_entry e;
- if (!find_pack_entry(sha1, &e)) {
+ if (!find_pack_entry(sha1, &e, NULL)) {
error("cannot read sha1_file for %s", sha1_to_hex(sha1));
return NULL;
}
@@ -1266,7 +1274,7 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size
void *map, *buf;
struct pack_entry e;
- if (find_pack_entry(sha1, &e))
+ if (find_pack_entry(sha1, &e, NULL))
return read_packed_sha1(sha1, type, size);
map = map_sha1_file(sha1, &mapsize);
if (map) {
@@ -1275,7 +1283,7 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size
return buf;
}
reprepare_packed_git();
- if (find_pack_entry(sha1, &e))
+ if (find_pack_entry(sha1, &e, NULL))
return read_packed_sha1(sha1, type, size);
return NULL;
}
@@ -1707,10 +1715,10 @@ int has_pack_file(const unsigned char *sha1)
return 1;
}
-int has_sha1_pack(const unsigned char *sha1)
+int has_sha1_pack(const unsigned char *sha1, const char **ignore_packed)
{
struct pack_entry e;
- return find_pack_entry(sha1, &e);
+ return find_pack_entry(sha1, &e, ignore_packed);
}
int has_sha1_file(const unsigned char *sha1)
@@ -1718,7 +1726,7 @@ int has_sha1_file(const unsigned char *sha1)
struct stat st;
struct pack_entry e;
- if (find_pack_entry(sha1, &e))
+ if (find_pack_entry(sha1, &e, NULL))
return 1;
return find_sha1_file(sha1, &st) ? 1 : 0;
}