git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net
Subject: [PATCH 1/3] pack-bitmap: add 'test_bitmap_commits()' helper
Date: Wed, 31 Mar 2021 21:32:07 -0400	[thread overview]
Message-ID: <053ba4b8319cae9fc804b5f9ce452be1bb16e1da.1617240723.git.me@ttaylorr.com> (raw)
In-Reply-To: <cover.1617240723.git.me@ttaylorr.com>

The next patch will add a 'bitmap' test-tool which prints the list of
commits that have bitmaps computed.

The test helper could implement this itself, but it would need access to
the 'bitmaps' field of the 'pack_bitmap' struct. To avoid exposing this
private detail, implement the entirety of the helper behind a
test_bitmap_commits() function in pack-bitmap.c.

There is some precedence for this with test_bitmap_walk() which is used
to implement the '--test-bitmap' flag in 'git rev-list' (and is also
implemented in pack-bitmap.c).

A caller will be added in the next patch.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 pack-bitmap.c | 18 ++++++++++++++++++
 pack-bitmap.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/pack-bitmap.c b/pack-bitmap.c
index 1ebe0c8162..7554510b14 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1350,6 +1350,24 @@ void test_bitmap_walk(struct rev_info *revs)
 	free_bitmap_index(bitmap_git);
 }
 
+int test_bitmap_commits(struct repository *r)
+{
+	struct bitmap_index *bitmap_git = prepare_bitmap_git(r);
+	struct object_id oid;
+	MAYBE_UNUSED void *value;
+
+	if (!bitmap_git)
+		die("failed to load bitmap indexes");
+
+	kh_foreach(bitmap_git->bitmaps, oid, value, {
+		printf("%s\n", oid_to_hex(&oid));
+	});
+
+	free_bitmap_index(bitmap_git);
+
+	return 0;
+}
+
 int rebuild_bitmap(const uint32_t *reposition,
 		   struct ewah_bitmap *source,
 		   struct bitmap *dest)
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 36d99930d8..c3cdd80756 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -49,6 +49,7 @@ void traverse_bitmap_commit_list(struct bitmap_index *,
 				 struct rev_info *revs,
 				 show_reachable_fn show_reachable);
 void test_bitmap_walk(struct rev_info *revs);
+int test_bitmap_commits(struct repository *r);
 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
 					 struct list_objects_filter_options *filter);
 int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
-- 
2.31.1.163.ga65ce7f831


  reply	other threads:[~2021-04-01  1:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01  1:32 [PATCH 0/3] pack-objects: introduce pack.preferBitmapTips Taylor Blau
2021-04-01  1:32 ` Taylor Blau [this message]
2021-04-01  1:32 ` [PATCH 2/3] t/helper/test-bitmap.c: initial commit Taylor Blau
2021-05-26 18:30   ` SunCC doesn't compile v2.32.0-rc* anymore (was "Re: [PATCH 2/3] t/helper/test-bitmap.c: initial commit") Ævar Arnfjörð Bjarmason
2021-05-26 18:44     ` Taylor Blau
2021-05-26 21:10       ` Ævar Arnfjörð Bjarmason
2021-05-27  0:52         ` [PATCH] pack-objects: move builtin-only code to its own header Ævar Arnfjörð Bjarmason
2021-05-27  1:30           ` Junio C Hamano
2021-05-27  2:40           ` Junio C Hamano
2021-05-27  3:14           ` Junio C Hamano
2021-05-27 12:51             ` Ævar Arnfjörð Bjarmason
2021-04-01  1:32 ` [PATCH 3/3] builtin/pack-objects.c: respect 'pack.preferBitmapTips' Taylor Blau
2021-04-01 13:05   ` Derrick Stolee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=053ba4b8319cae9fc804b5f9ce452be1bb16e1da.1617240723.git.me@ttaylorr.com \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).