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

Re: [PATCH 12/12] builtin/*: remove or amend "USE_THE_INDEX_COMPATIBILITY_MACROS"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 18, 2022, 19:27 UTC
Message-ID
<221118.86mt8of3hi.gmgdl@evledraar.gmail.com>
In-Reply-To
<Y3fSJwm7qoVmvPA8@nand.local>
On Fri, Nov 18 2022, Taylor Blau wrote:
Show 10 quoted lines
> On Fri, Nov 18, 2022 at 12:31:06PM +0100, Ævar Arnfjörð Bjarmason wrote:
>> Follow-up the preceding commit and change
>> "USE_THE_INDEX_COMPATIBILITY_MACROS" to the more narrow
>> "USE_THE_INDEX_VARIABLE" in cases where we still use "the_index".
>>
>> Then remove "USE_THE_INDEX_VARIABLE" entirely in the few cases where
>> we don't require any compatibility macros or variables anymore.
>
> Could this get squashed into the previous commit? IOW, is there any
> reason to keep them separate?

I figured it would be easier to review if I split out the changes that are coccinelle-created v.s. the ones I made manually.

But I don't have a preference at all, whatever you think is easier.

This *could* also be a 3 patch series, which I'd prefer, but figured it would get push-back, so I thought I'd spoon-feed the list.

I.e. just:
 1. Fix discard_index() return value
 2. Add and apply the *.cocci rule to *ALL THE THINGS*"
 3. Narrow down the macro for t/helper/*

At that point we wouldn't need "USE_THE_INDEX_VARIABLE", as we'd have nothing except "the_index", so "USE_THE_INDEX_COMPATIBILITY_MACROS" would do exactly what "USE_THE_INDEX_VARIABLE" does in this topic.

(We could still rename it, but I think probably the churn isn't worth it if it's not a stop-gap to new macro use being re-introduced)

It would rip the band-aid off, there's conflicts, but the --remerge-diff with "seen" is rather easy, or:

	diff --git a/builtin/commit.c b/builtin/commit.c
	remerge CONFLICT (content): Merge conflict in builtin/commit.c
	index 4fb7604cc24..c7dbdb2a866 100644
	--- a/builtin/commit.c
	+++ b/builtin/commit.c
	@@ -991,16 +991,11 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
	 		struct object_id oid;
	 		const char *parent = "HEAD";
	 
	-<<<<<<< c23106a1d9f (hi)
	-		if (!the_index.cache_nr && repo_read_index(the_repository) < 0)
	-			die(_("Cannot read index"));
	-=======
	-		if (!active_nr) {
	-			discard_cache();
	-			if (read_cache() < 0)
	+		if (!the_index.cache_nr) {
	+			discard_index(&the_index);
	+			if (repo_read_index(the_repository) < 0)
	 				die(_("Cannot read index"));
	 		}
	->>>>>>> 75ae5b855fb (Merge branch 'rj/branch-copy-and-rename' into seen)
	 
	 		if (amend)
	 			parent = "HEAD^1";
	diff --git a/builtin/read-tree.c b/builtin/read-tree.c
	remerge CONFLICT (content): Merge conflict in builtin/read-tree.c
	index 5dcf0d09ed1..5d6e638c4b1 100644
	--- a/builtin/read-tree.c
	+++ b/builtin/read-tree.c
	@@ -250,15 +250,11 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
	 	if (opts.debug_unpack)
	 		opts.fn = debug_merge;
	 
	-<<<<<<< c23106a1d9f (hi)
	-	cache_tree_free(&the_index.cache_tree);
	-=======
	 	/* If we're going to prime_cache_tree later, skip cache tree update */
	 	if (nr_trees == 1 && !opts.prefix)
	 		opts.skip_cache_tree_update = 1;
	 
	-	cache_tree_free(&active_cache_tree);
	->>>>>>> 75ae5b855fb (Merge branch 'rj/branch-copy-and-rename' into seen)
	+	cache_tree_free(&the_index.cache_tree);
	 	for (i = 0; i < nr_trees; i++) {
	 		struct tree *tree = trees[i];
	 		parse_tree(tree);
	diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
	index 93051b25f56..5514afdfe7a 100644
	--- a/t/helper/test-cache-tree.c
	+++ b/t/helper/test-cache-tree.c
	@@ -30,7 +30,7 @@ int cmd__cache_tree(int argc, const char **argv)
	 
	 	argc = parse_options(argc, argv, NULL, options, test_cache_tree_usage, 0);
	 
	-	if (read_cache() < 0)
	+	if (repo_read_index(the_repository) < 0)
	 		die(_("unable to read index file"));
	 
	 	oidcpy(&oid, &the_index.cache_tree->oid);
	
...and can also be applied by a "take theirs", re-run the cocci, apply
cocci patch, so no manual resolution needed. Any future conflicts would
be solved with the same procedure.

The diff would be just under ~2k lines, but pretty trivial in terms of non-cocci changes.

Anyway, just let me know. Right now I'm assuming I'll just re-roll this (pending any further feedback for a bit) with squashing & some other minor changes...

Previous: Taylor BlauNext: Taylor Blau
Message 16 of 32 in “tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROS”
  1. 00/12 tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROSÆvar Arnfjörð Bjarmason, Nov 18, 2022
  2. 01/12 cache.h: remove unused "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 18, 2022
  3. 02/12 builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  4. 03/12 cocci & cache.h: remove rarely used "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 18, 2022
  5. 04/12 read-cache API & users: make discard_index() return voidÆvar Arnfjörð Bjarmason, Nov 18, 2022
  6. 05/12 cocci: add a index-compatibility.pending.cocciÆvar Arnfjörð Bjarmason, Nov 18, 2022
  7. 06/12 cocci & cache.h: apply a selection of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 18, 2022
  8. 07/12 cocci & cache.h: apply variable section of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 18, 2022
  9. 08/12 cocci: apply "pending" index-compatibility to "t/helper/*.c"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  10. 09/12 {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  11. Taylor BlauNov 18, 2022
  12. 10/12 cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  13. Taylor BlauNov 18, 2022
  14. 12/12 builtin/*: remove or amend "USE_THE_INDEX_COMPATIBILITY_MACROS"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  15. Taylor BlauNov 18, 2022
  16. Ævar Arnfjörð BjarmasonNov 18, 2022
  17. Taylor BlauNov 18, 2022
  18. 11/12 cocci: apply "pending" index-compatibility to some "builtin/*.c"Ævar Arnfjörð Bjarmason, Nov 18, 2022
  19. Phillip WoodNov 18, 2022
  20. Ævar Arnfjörð BjarmasonNov 18, 2022
  21. 00/11 tree-wide: chip away at USE_THE_INDEX_COMPATIBILITY_MACROSÆvar Arnfjörð Bjarmason, Nov 19, 2022
  22. 01/11 cache.h: remove unused "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 19, 2022
  23. 02/11 builtin/{grep,log}.: don't define "USE_THE_INDEX_COMPATIBILITY_MACROS"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  24. 03/11 cocci & cache.h: remove rarely used "the_index" compat macrosÆvar Arnfjörð Bjarmason, Nov 19, 2022
  25. 04/11 read-cache API & users: make discard_index() return voidÆvar Arnfjörð Bjarmason, Nov 19, 2022
  26. 05/11 cocci: add a index-compatibility.pending.cocciÆvar Arnfjörð Bjarmason, Nov 19, 2022
  27. 06/11 cocci & cache.h: apply a selection of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 19, 2022
  28. 08/11 cocci: apply "pending" index-compatibility to "t/helper/*.c"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  29. 07/11 cocci & cache.h: apply variable section of "pending" index-compatibilityÆvar Arnfjörð Bjarmason, Nov 19, 2022
  30. 09/11 {builtin/*,repository}.c: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  31. 10/11 cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE"Ævar Arnfjörð Bjarmason, Nov 19, 2022
  32. 11/11 cocci: apply "pending" index-compatibility to some "builtin/*.c"Ævar Arnfjörð Bjarmason, Nov 19, 2022

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.