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

[RFC/PATCH 2/8] split-index: add {add,remove}_split_index() functions

From
Christian Couder <christian.couder@gmail.com>
Date
Jul 11, 2016, 17:22 UTC
Message-ID
<20160711172254.13439-3-chriscool@tuxfamily.org>
In-Reply-To
<20160711172254.13439-1-chriscool@tuxfamily.org>

Also use the functions in cmd_update_index() in builtin/update-index.c.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin/update-index.c | 17 ++++-------------
 split-index.c          | 18 ++++++++++++++++++
 split-index.h          |  2 ++
 3 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 6cdfd5f..f06fe80 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -1108,19 +1108,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 		strbuf_release(&buf);
 	}
 
-	if (split_index > 0) {
-		init_split_index(&the_index);
-		the_index.cache_changed |= SPLIT_INDEX_ORDERED;
-	} else if (!split_index && the_index.split_index) {
-		/*
-		 * can't discard_split_index(&the_index); because that
-		 * will destroy split_index->base->cache[], which may
-		 * be shared with the_index.cache[]. So yeah we're
-		 * leaking a bit here.
-		 */
-		the_index.split_index = NULL;
-		the_index.cache_changed |= SOMETHING_CHANGED;
-	}
+	if (split_index > 0)
+		add_split_index(&the_index);
+	else if (!split_index && the_index.split_index)
+		remove_split_index(&the_index);
 
 	switch (untracked_cache) {
 	case UC_UNSPECIFIED:
diff --git a/split-index.c b/split-index.c
index 3c75d4b..9466b69 100644
--- a/split-index.c
+++ b/split-index.c
@@ -319,3 +319,21 @@ void replace_index_entry_in_base(struct index_state *istate,
 		istate->split_index->base->cache[new->index - 1] = new;
 	}
 }
+
+void add_split_index(struct index_state *istate)
+{
+	init_split_index(istate);
+	istate->cache_changed |= SPLIT_INDEX_ORDERED;
+}
+
+void remove_split_index(struct index_state *istate)
+{
+	/*
+	 * can't discard_split_index(&the_index); because that
+	 * will destroy split_index->base->cache[], which may
+	 * be shared with the_index.cache[]. So yeah we're
+	 * leaking a bit here.
+	 */
+	istate->split_index = NULL;
+	istate->cache_changed |= SOMETHING_CHANGED;
+}
diff --git a/split-index.h b/split-index.h
index c1324f5..df91c1b 100644
--- a/split-index.h
+++ b/split-index.h
@@ -31,5 +31,7 @@ void merge_base_index(struct index_state *istate);
 void prepare_to_write_split_index(struct index_state *istate);
 void finish_writing_split_index(struct index_state *istate);
 void discard_split_index(struct index_state *istate);
+void add_split_index(struct index_state *istate);
+void remove_split_index(struct index_state *istate);
 
 #endif
-- 
2.9.0.250.g7087ccc.dirty
Previous: Christian CouderNext: Christian Couder
Message 2 of 19 in “Add configuration options for split-index”
  1. 0/8 Add configuration options for split-indexChristian Couder, Jul 11, 2016
  2. 2/8 split-index: add {add,remove}_split_index() functionsChristian Couder, Jul 11, 2016
  3. 3/8 read-cache: add and then use tweak_split_index()Christian Couder, Jul 11, 2016
  4. 5/8 Documentation/config: add information for core.splitIndexChristian Couder, Jul 11, 2016
  5. 6/8 Documentation/git-update-index: talk about core.splitIndex config varChristian Couder, Jul 11, 2016
  6. 7/8 t1700: add tests for core.splitIndexChristian Couder, Jul 11, 2016
  7. 4/8 update-index: warn in case of split-index incoherencyChristian Couder, Jul 11, 2016
  8. 8/8 read-cache: unlink old sharedindex filesChristian Couder, Jul 11, 2016
  9. Duy NguyenJul 11, 2016
  10. Christian CouderJul 12, 2016
  11. Duy NguyenJul 12, 2016
  12. Christian CouderJul 12, 2016
  13. Duy NguyenJul 13, 2016
  14. Christian CouderJul 13, 2016
  15. 1/8 config: add git_config_get_split_index()Christian Couder, Jul 11, 2016
  16. Duy NguyenJul 12, 2016
  17. Christian CouderJul 23, 2016
  18. Duy NguyenJul 25, 2016
  19. Christian CouderJul 25, 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.