Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <>
To: Jeff King <>
Cc: Tiago d'Almeida <>,
	Derrick Stolee <>,
Subject: Re: index.skipHash doesn't work with split index, was Re: Bug Report
Date: Wed, 5 Jul 2023 16:27:50 +0200 (CEST)	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>


On Thu, 29 Jun 2023, Jeff King wrote:

> On Tue, Jun 27, 2023 at 05:02:30PM +0100, Tiago d'Almeida wrote:
> > Attached to this email follow the `git bugreport` and global `config`
> > files, and the git_bug repo.
> Thanks for providing your config; it was very important to reproducing.
> The bug comes from the combination of "core.splitIndex" and
> "index.skipHash" (the latter is triggered in your config by
> "feature.manyFiles").
> Here's a quick reproduction:
>   git init repo
>   cd repo
>   touch file
>   git -c core.splitIndex=true -c index.skipHash=true add file

I ran into this issue while debugging the `commit -am` issue I worked on

The reason is that `write_shared_index()` calls `do_write_index()` without
any additional flags (see and
`do_write_index()` heeds the `index.skipHash` setting always (see

I briefly experimented with this diff, which is ugly and should not be
used as is, but it seemed to fix the issue for me:

-- snip --
diff --git a/read-cache.c b/read-cache.c
index ee6bcf40351..92a4aa2f25a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3292,14 +3294,17 @@ static int write_shared_index(struct index_state *istate,
 			      struct tempfile **temp, unsigned flags)
 	struct split_index *si = istate->split_index;
-	int ret, was_full = !istate->sparse_index;
+	int ret, was_full = !istate->sparse_index, saved_skip_hash;

 	convert_to_sparse(istate, 0);

 	trace2_region_enter_printf("index", "shared/do_write_index",
 				   the_repository, "%s", get_tempfile_path(*temp));
+	saved_skip_hash = si->base->repo->settings.index_skip_hash;
+	si->base->repo->settings.index_skip_hash = 0;
 	ret = do_write_index(si->base, *temp, WRITE_NO_EXTENSION, flags);
+	si->base->repo->settings.index_skip_hash = saved_skip_hash;
 	trace2_region_leave_printf("index", "shared/do_write_index",
 				   the_repository, "%s", get_tempfile_path(*temp));

-- snap --

The reason why this is needed is that the shared index _must_ have an
identifer that the split index can use, and that's that index hash.
Skipping it breaks that pattern.

Probably a much better idea than above-mentioned diff would be to add a
new flag as a sibling to `COMMIT_LOCK` (i.e. here: and use that
only in `write_shared_index()` to force the index hash to be computed and

I won't have time to work on this, though.


> That should add "file" to the index but doesn't. Removing either the
> splitIndex option or the skipHash option makes it work. I didn't dig
> further than that.
> Adding the author of skipHash to the cc.
> -Peff

  parent reply	other threads:[~2023-07-05 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 16:02 Bug Report Tiago d'Almeida
2023-06-29  8:38 ` index.skipHash doesn't work with split index, was " Jeff King
     [not found]   ` <>
     [not found]     ` <>
2023-07-03 19:16       ` Jeff King
2023-07-05 14:27   ` Johannes Schindelin [this message]
2023-07-05 17:30     ` Junio C Hamano

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:

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

  git send-email \ \ \ \ \ \ \

* 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.
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).