[PATCH] Add git-index-pack -l to list objects in a pack

Subsystems: the rest

DORMANTno replies

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[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

Re: [PATCH] Add git-index-pack -l to list objects in a pack

From: Nicolas Pitre <hidden>
Date: 2016-06-15 22:43:14

On Wed, 6 Jun 2007, Sam Vilain wrote:
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
Why don't you simply use git-show-index?


Nicolas

Re: [PATCH] Add git-index-pack -l to list objects in a pack

From: Sam Vilain <hidden>
Date: 2016-06-15 22:43:14

Nicolas Pitre wrote:
quoted
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
Why don't you simply use git-show-index?
Because I found the enticing -n switch in the documentation first?

That command certainly would have done the trick for what I needed it
to do.  Perhaps change the documentation of the switch?

Subject: [PATCH] fix documentation of unpack-objects -n

unpack-objects -n didn't print the object list as promised on the
manual page, so alter the documentation to reflect the behaviour
---
 Documentation/git-unpack-objects.txt |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-unpack-objects.txt b/Documentation/git-unpack-objects.txt
index ff6184b..b1b3ec9 100644
--- a/Documentation/git-unpack-objects.txt
+++ b/Documentation/git-unpack-objects.txt
@@ -27,8 +27,8 @@ new packs and replace existing ones.
 OPTIONS
 -------
 -n::
-        Only list the objects that would be unpacked, don't actually unpack
-        them.
+        Dry run.  Check the pack file without actually unpacking
+	the objects.
 
 -q::
 	The command usually shows percentage progress.  This
-- 
1.5.2.0.45.gfea6d-dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help