diff mbox series

[3/3] split-index: it really is incompatible with the sparse index

Message ID 1bb57ccd61452124119bb663f5e35e9676748c82.1642613380.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 451b66c533b9ede47951d16c0127ab33372125ca
Headers show
Series : sparse index vs split index fixes | expand

Commit Message

Johannes Schindelin Jan. 19, 2022, 5:29 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

... at least for now. So let's error out if we are even trying to
initialize the split index when the index is sparse, or when trying to
write the split index extension for a sparse index.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 read-cache.c  | 3 +++
 split-index.c | 3 +++
 2 files changed, 6 insertions(+)

Comments

Junio C Hamano Jan. 21, 2022, 11:39 p.m. UTC | #1
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> ... at least for now. So let's error out if we are even trying to
> initialize the split index when the index is sparse, or when trying to
> write the split index extension for a sparse index.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  read-cache.c  | 3 +++
>  split-index.c | 3 +++
>  2 files changed, 6 insertions(+)

Good.  Will queue.


> diff --git a/read-cache.c b/read-cache.c
> index cbe73f14e5e..a932e01fc7a 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -3009,6 +3009,9 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
>  	    !is_null_oid(&istate->split_index->base_oid)) {
>  		struct strbuf sb = STRBUF_INIT;
>  
> +		if (istate->sparse_index)
> +			die(_("cannot write split index for a sparse index"));
> +
>  		err = write_link_extension(&sb, istate) < 0 ||
>  			write_index_ext_header(f, eoie_c, CACHE_EXT_LINK,
>  					       sb.len) < 0;
> diff --git a/split-index.c b/split-index.c
> index 8e52e891c3b..9d0ccc30d00 100644
> --- a/split-index.c
> +++ b/split-index.c
> @@ -5,6 +5,9 @@
>  struct split_index *init_split_index(struct index_state *istate)
>  {
>  	if (!istate->split_index) {
> +		if (istate->sparse_index)
> +			die(_("cannot use split index with a sparse index"));
> +
>  		CALLOC_ARRAY(istate->split_index, 1);
>  		istate->split_index->refcount = 1;
>  	}
Johannes Schindelin Jan. 22, 2022, 9:32 a.m. UTC | #2
Hi Junio,

On Fri, 21 Jan 2022, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > ... at least for now. So let's error out if we are even trying to
> > initialize the split index when the index is sparse, or when trying to
> > write the split index extension for a sparse index.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >  read-cache.c  | 3 +++
> >  split-index.c | 3 +++
> >  2 files changed, 6 insertions(+)
>
> Good.  Will queue.

Thank you!
Dscho
diff mbox series

Patch

diff --git a/read-cache.c b/read-cache.c
index cbe73f14e5e..a932e01fc7a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3009,6 +3009,9 @@  static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
 	    !is_null_oid(&istate->split_index->base_oid)) {
 		struct strbuf sb = STRBUF_INIT;
 
+		if (istate->sparse_index)
+			die(_("cannot write split index for a sparse index"));
+
 		err = write_link_extension(&sb, istate) < 0 ||
 			write_index_ext_header(f, eoie_c, CACHE_EXT_LINK,
 					       sb.len) < 0;
diff --git a/split-index.c b/split-index.c
index 8e52e891c3b..9d0ccc30d00 100644
--- a/split-index.c
+++ b/split-index.c
@@ -5,6 +5,9 @@ 
 struct split_index *init_split_index(struct index_state *istate)
 {
 	if (!istate->split_index) {
+		if (istate->sparse_index)
+			die(_("cannot use split index with a sparse index"));
+
 		CALLOC_ARRAY(istate->split_index, 1);
 		istate->split_index->refcount = 1;
 	}