[PATCH] Add git-index-pack -l to list objects in a pack
From: Sam Vilain <hidden>
Date: 2016-06-15 22:43:14
I couldn't figure out how to make git-unpack-objects -n work. But it seems to be easy in the loop in index-pack --- index-pack.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index 82c8da3..f657db7 100644
--- a/index-pack.c
+++ b/index-pack.c@@ -45,6 +45,7 @@ static int nr_resolved_deltas; static int from_stdin; static int verbose; +static int list_objects; static struct progress progress;
@@ -717,6 +718,8 @@ int main(int argc, char **argv) if (*c) die("bad %s", arg); input_len = sizeof(*hdr); + } else if (!strcmp(arg, "-l")) { + list_objects = 1; } else if (!strcmp(arg, "-v")) { verbose = 1; } else if (!strcmp(arg, "-o")) {
@@ -802,8 +805,11 @@ int main(int argc, char **argv) free(deltas); idx_objects = xmalloc((nr_objects) * sizeof(struct pack_idx_entry *)); - for (i = 0; i < nr_objects; i++) + for (i = 0; i < nr_objects; i++) { idx_objects[i] = &objects[i].idx; + if (list_objects) + printf("%s\n", sha1_to_hex(idx_objects[i]->sha1)); + } curr_index = write_idx_file(index_name, idx_objects, nr_objects, sha1); free(idx_objects);
--
1.5.2.0.45.gfea6d-dirty