threads / patch / 8467

patchAdd git-index-pack -l to list objects in a pack

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

## tl;dr

4 messages between Jun 6, 2007 and Jun 6, 2007. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Sam Vilain· Jun 6, 2007, 09:39 UTC · lore
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(-)
Show changes to index-pack.c +7 −1
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
Nicolas Pitre· Jun 6, 2007, 13:55 UTC · re: Sam Vilain · lore

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

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
Sam Vilain· Jun 6, 2007, 21:23 UTC · re: Nicolas Pitre · lore

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

Nicolas Pitre 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?
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(-)
Show changes to Documentation/git-unpack-objects.txt +2 −2
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
Junio C Hamano· Jun 6, 2007, 21:35 UTC · re: Sam Vilain · lore

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

Sam Vilain <sam.vilain@catalyst.net.nz> writes:
Show 10 quoted lines
> Nicolas Pitre 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?
>
> 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?
I think this is "incorrect expectation".  The document says:
>  -n::
> -        Only list the objects that would be unpacked, don't actually unpack
> -        them.

I suspect that you were trying to unpack in a repository that already had that object? They are not "the objects that would be unpacked" hence not listed.

← back to recent threads