{"thread":{"id":"66696","subject":"[PATCH] read-cache: hide refresh_cache_entry()","startedAt":"2026-10-28T20:34:42Z","lastAt":"2026-11-02T19:00:57Z","messageCount":5,"participants":["Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556705","messageId":"xmqq4ie58syl.fsf@gitster.g","threadId":"66696","inReplyTo":null,"subject":"[PATCH] read-cache: hide refresh_cache_entry()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-28T20:34:42Z","receivedAt":"2026-10-28T20:34:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Once upon a time, there was a merge strategy called \"recursive\",\nwhich was added in 6d297f8137 (Status update on merge-recursive in\nC, 2006-07-08).  This implementation came with its own machinery\nthat creates an in-core index entry, and then refreshed the index\nentry it created by calling the refresh_cache_entry() function\nborrowed from the read-cache.c API.  refresh_cache_entry() used to\nbe file-scope static, but was made public with this change.\n\nWhen ad45b327c0 (merge-recursive.[ch]: thoroughly debug these,\n2025-04-08) finally removed the entire code for the \"recursive\"\nmerge strategy, the last external caller of refresh_cache_entry()\nwent with it.\n\nHide the low-level implementation detail again by making it a\nfile-scope static function.  The external callers would indirectly\ncall it when they call make_cache_entry() or rename_index_entry_at()\nexternal interface, which \"ort\" (the successor of \"recursive\") does.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n read-cache-ll.h | 2 --\n read-cache.c    | 8 +++++---\n 2 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/read-cache-ll.h b/read-cache-ll.h\nindex 066dd8bc3b..dd30befbb3 100644\n--- a/read-cache-ll.h\n+++ b/read-cache-ll.h\n@@ -475,8 +475,6 @@ int refresh_index(struct index_state *, unsigned int flags, const struct pathspe\n  */\n int repo_refresh_and_write_index(struct repository*, unsigned int refresh_flags, unsigned int write_flags, int gentle, const struct pathspec *, char *seen, const char *header_msg);\n \n-struct cache_entry *refresh_cache_entry(struct index_state *, struct cache_entry *, unsigned int);\n-\n void set_alternate_index_output(const char *);\n \n extern int verify_index_checksum;\ndiff --git a/read-cache.c b/read-cache.c\nindex c4cf08a3a3..94dff890a7 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -129,6 +129,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n \treturn *pool_ptr;\n }\n \n+static struct cache_entry *refresh_cache_entry(struct index_state *, struct cache_entry *, unsigned int);\n+\n static const char *alternate_index_output;\n \n static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n@@ -1624,9 +1626,9 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \treturn has_errors;\n }\n \n-struct cache_entry *refresh_cache_entry(struct index_state *istate,\n-\t\t\t\t\tstruct cache_entry *ce,\n-\t\t\t\t\tunsigned int options)\n+static struct cache_entry *refresh_cache_entry(struct index_state *istate,\n+\t\t\t\t\t       struct cache_entry *ce,\n+\t\t\t\t\t       unsigned int options)\n {\n \treturn refresh_cache_ent(istate, ce, options, NULL, NULL, NULL, NULL);\n }\n-- \n2.56.0-433-ga9209adf11\n\n\n"},{"id":"556869","messageId":"auRm0Ohkg3OQIbWE@pks.im","threadId":"66696","inReplyTo":"xmqq4ie58syl.fsf@gitster.g","subject":"Re: [PATCH] read-cache: hide refresh_cache_entry()","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-30T09:43:44Z","receivedAt":"2026-10-30T09:43:44Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 28, 2026 at 01:34:42PM -0700, Junio C Hamano wrote:\n> Once upon a time, there was a merge strategy called \"recursive\",\n> which was added in 6d297f8137 (Status update on merge-recursive in\n> C, 2006-07-08).  This implementation came with its own machinery\n> that creates an in-core index entry, and then refreshed the index\n> entry it created by calling the refresh_cache_entry() function\n> borrowed from the read-cache.c API.  refresh_cache_entry() used to\n> be file-scope static, but was made public with this change.\n> \n> When ad45b327c0 (merge-recursive.[ch]: thoroughly debug these,\n> 2025-04-08) finally removed the entire code for the \"recursive\"\n> merge strategy, the last external caller of refresh_cache_entry()\n> went with it.\n> \n> Hide the low-level implementation detail again by making it a\n> file-scope static function.  The external callers would indirectly\n> call it when they call make_cache_entry() or rename_index_entry_at()\n> external interface, which \"ort\" (the successor of \"recursive\") does.\n\nSeeing all these patches dropping public declarations I wonder whether\nthey should have been part of the same patch series :)\n\n> diff --git a/read-cache.c b/read-cache.c\n> index c4cf08a3a3..94dff890a7 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -129,6 +129,8 @@ static struct mem_pool *find_mem_pool(struct index_state *istate)\n>  \treturn *pool_ptr;\n>  }\n>  \n> +static struct cache_entry *refresh_cache_entry(struct index_state *, struct cache_entry *, unsigned int);\n> +\n>  static const char *alternate_index_output;\n>  \n>  static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n\nCould we avoid this forward declaration by moving the function around?\n\nPatrick\n\n"},{"id":"556929","messageId":"xmqqpkwrxkbq.fsf@gitster.g","threadId":"66696","inReplyTo":"auRm0Ohkg3OQIbWE@pks.im","subject":"Re: [PATCH] read-cache: hide refresh_cache_entry()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-30T15:46:33Z","receivedAt":"2026-10-30T15:46:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n>> Hide the low-level implementation detail again by making it a\n>> file-scope static function.  The external callers would indirectly\n>> call it when they call make_cache_entry() or rename_index_entry_at()\n>> external interface, which \"ort\" (the successor of \"recursive\") does.\n>\n> Seeing all these patches dropping public declarations I wonder whether\n> they should have been part of the same patch series :)\n\nPerhaps ;-).\n\n>> +static struct cache_entry *refresh_cache_entry(struct index_state *, struct cache_entry *, unsigned int);\n>> +\n>>  static const char *alternate_index_output;\n>>  \n>>  static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n>\n> Could we avoid this forward declaration by moving the function around?\n\nAs refresh_cache_entry() that has mere one line in its body calls\nrefresh_cache_ent() that is a screenful and defined nearby, both of\nthem need to be moved upward, so it becomes a rather unsightly\nchange, even though nobody would care when they only look at the end\nresult X-<.\n\nBy the way, I tried \"history fixup\" to make this change, and noticed\nthat the subcommand ignores \"[notes] rewriteref = refs/notes/amlog\",\njust like \"git history reword\" does.  Again, I wonder if this is a\nknown limitation, or a deliberate design.\n\n\n"},{"id":"557137","messageId":"auhbjFvD8CNXYcgQ@pks.im","threadId":"66696","inReplyTo":"xmqqpkwrxkbq.fsf@gitster.g","subject":"Re: [PATCH] read-cache: hide refresh_cache_entry()","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-02T09:44:44Z","receivedAt":"2026-11-02T09:44:44Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Oct 30, 2026 at 08:46:33AM -0700, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> >> Hide the low-level implementation detail again by making it a\n> >> file-scope static function.  The external callers would indirectly\n> >> call it when they call make_cache_entry() or rename_index_entry_at()\n> >> external interface, which \"ort\" (the successor of \"recursive\") does.\n> >\n> > Seeing all these patches dropping public declarations I wonder whether\n> > they should have been part of the same patch series :)\n> \n> Perhaps ;-).\n> \n> >> +static struct cache_entry *refresh_cache_entry(struct index_state *, struct cache_entry *, unsigned int);\n> >> +\n> >>  static const char *alternate_index_output;\n> >>  \n> >>  static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)\n> >\n> > Could we avoid this forward declaration by moving the function around?\n> \n> As refresh_cache_entry() that has mere one line in its body calls\n> refresh_cache_ent() that is a screenful and defined nearby, both of\n> them need to be moved upward, so it becomes a rather unsightly\n> change, even though nobody would care when they only look at the end\n> result X-<.\n\nWell, people probably know by now that I myself tend to err more on the\nside of fixing up stuff, even if it's a bit more on the painful side of\nthings. So I'm not going to surprise you by saying that I think that\nwould be worth it.\n\nIn any case, I don't feel strongly about it.\n\n> By the way, I tried \"history fixup\" to make this change, and noticed\n> that the subcommand ignores \"[notes] rewriteref = refs/notes/amlog\",\n> just like \"git history reword\" does.  Again, I wonder if this is a\n> known limitation, or a deliberate design.\n\nYeah, I already replied in the other series, this is a known limitation.\nI've created an issue to track this that we may have capacity to work on\nin the next release cycle. But I wouldn't mind anybody else beating us\nto it.\n\nPatrick\n\n"},{"id":"557225","messageId":"xmqqld7bhxcm.fsf@gitster.g","threadId":"66696","inReplyTo":"auhbjFvD8CNXYcgQ@pks.im","subject":"Re: [PATCH] read-cache: hide refresh_cache_entry()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-02T19:00:57Z","receivedAt":"2026-11-02T19:00:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n>> > Could we avoid this forward declaration by moving the function around?\n>> \n>> As refresh_cache_entry() that has mere one line in its body calls\n>> refresh_cache_ent() that is a screenful and defined nearby, both of\n>> them need to be moved upward, so it becomes a rather unsightly\n>> change, even though nobody would care when they only look at the end\n>> result X-<.\n>\n> Well, people probably know by now that I myself tend to err more on the\n> side of fixing up stuff, even if it's a bit more on the painful side of\n> things. So I'm not going to surprise you by saying that I think that\n> would be worth it.\n>\n> In any case, I don't feel strongly about it.\n\nFWIW, the version with large code movement will be the final\nversion, as my philosophy is \"once written, unless there is a\ncompelling reason, do not flip flop\" and the last one I wrote was\nthe one you suggested, so that I can see how bad the result looks.\n\nI think the patch itself may be ugly but the result is easier to\nwork on going forward.  Thanks for pushing.\n\n"}]}