git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] rev-list: disable bitmaps when "-n" is used with listing objects

From
Jeff King <peff@peff.net>
Date
Jun 2, 2016, 23:10 UTC
Message-ID
<20160602231049.GB11247@sigill.intra.peff.net>
In-Reply-To
<20160602230925.GA11196@sigill.intra.peff.net>

You can ask rev-list to use bitmaps to speed up an --objects traversal, which should generally give you your answers much faster.

Likewise, you can ask rev-list to limit such a traversal with `-n`, in which case we'll show only a limited set of commits (and only the tree and commit objects directly reachable from those commits).

But if you do both together, the results are nonsensical. We end up limiting any fallback traversal we do to _find_ the bitmaps, but the actual set of objects we output will be picked arbitrarily from the union of any bitmaps we do find, and will involve the objects of many more commits.

It's possible that somebody might want this as a "show me what you can, but limit the amount of work you do" flag. But as with the prior commit clamping "--count", the results are basically non-deterministic; you'll get the values from some commits between `n` and the total number, and you can't tell which.

And unlike the `--count` case, we can't easily generate the "real" value from the bitmap values (you can't just walk back `-n` commits and subtract out the reachable objects from the boundary commits; the bitmaps for `X` record its total reachability, so you don't know which objects are directly from `X` itself, which from `X^`, and so on).

So let's just fallback to the non-bitmap code path in this case, so we always give a sane answer.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/rev-list.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index aaa79a3..9fb6608 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -365,7 +365,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 				printf("%d\n", commit_count);
 				return 0;
 			}
-		} else if (revs.tag_objects && revs.tree_objects && revs.blob_objects) {
+		} else if (!revs.max_count &&
+			   revs.tag_objects && revs.tree_objects && revs.blob_objects) {
 			if (!prepare_bitmap_walk(&revs)) {
 				traverse_bitmap_commit_list(&show_object_fast);
 				return 0;
-- 
2.9.0.rc1.132.g33c7f30
Previous: Jeff King
Message 6 of 6 in “corner cases with "rev-list --use-bitmap-index -n"”
  1. 0/2 corner cases with "rev-list --use-bitmap-index -n"Jeff King, Jun 2, 2016
  2. 1/2 rev-list: "adjust" results of "--count --use-bitmap-index -n"Jeff King, Jun 2, 2016
  3. 0/2 corner cases with "rev-list --use-bitmap-index -n"Jeff King, Jun 3, 2016
  4. 1/2 rev-list: "adjust" results of "--count --use-bitmap-index -n"Jeff King, Jun 3, 2016
  5. 2/2 rev-list: disable bitmaps when "-n" is used with listing objectsJeff King, Jun 3, 2016
  6. 2/2 rev-list: disable bitmaps when "-n" is used with listing objectsJeff King, Jun 2, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.