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

Re: [PATCH] diff: spell DIFF_INDEX_CACHED out when calling run_diff_index()

From
Jeff King <peff@peff.net>
Date
Aug 21, 2023, 18:36 UTC
Message-ID
<20230821183611.GB2617193@coredump.intra.peff.net>
In-Reply-To
<xmqqfs4cqsbl.fsf@gitster.g>
On Mon, Aug 21, 2023 at 09:21:50AM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> Many callers of run_diff_index() passed literal "1" for the option
> flag word, which should better be spelled out as DIFF_INDEX_CACHED
> for readablity.  Everybody else passes "0" that can stay as-is.
> 
> The other bit in the option flag word is DIFF_INDEX_MERGE_BASE, but
> curiously there is only one caller that can pass it, which is "git
> diff-index --merge-base" itself---no internal callers uses the
> feature.
> 
> A bit tricky call to the function is in builtin/submodule--helper.c
> where the .cached member in a private struct is set/reset as a plain
> Boolean flag, which happens to be "1" and happens to match the value
> of DIFF_INDEX_CACHED.

Good catch. I guess this is conversion that should have been done in 4c3fe82ef1 (diff-lib: accept option flags in run_diff_index(), 2020-09-20). That commit did fix up some callers, but missed these ones.

While this is conceptually orthogonal to what I'm looking at in the other part of the thread, the textual conflicts are really annoying. I'm going to float this to the front of my series and build on top.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 19 in “"git diff --no-pager --exit-code" errors out but returns zero exit code”
  1. Romain ChossartAug 20, 2023
  2. diff: handle negative status in diff_result_code()Jeff King, Aug 21, 2023
  3. Junio C HamanoAug 21, 2023
  4. diff: spell DIFF_INDEX_CACHED out when calling run_diff_index()Junio C Hamano, Aug 21, 2023
  5. Jeff KingAug 21, 2023
  6. Junio C HamanoAug 21, 2023
  7. Jeff KingAug 21, 2023
  8. Junio C HamanoAug 21, 2023
  9. 0/7 cleaning up diff_result_code()Jeff King, Aug 21, 2023
  10. 1/7 diff: spell DIFF_INDEX_CACHED out when calling run_diff_index()Jeff King, Aug 21, 2023
  11. 2/7 diff-files: avoid negative exit valueJeff King, Aug 21, 2023
  12. 3/7 diff: show usage for unknown builtin_diff_files() optionsJeff King, Aug 21, 2023
  13. 4/7 diff: die when failing to read index in git-diff builtinJeff King, Aug 21, 2023
  14. Junio C HamanoAug 22, 2023
  15. 5/7 diff: drop useless return from run_diff_{files,index} functionsJeff King, Aug 21, 2023
  16. 6/7 diff: drop useless return values in git-diff helpersJeff King, Aug 21, 2023
  17. 7/7 diff: drop useless "status" parameter from diff_result_code()Jeff King, Aug 21, 2023
  18. Junio C HamanoAug 22, 2023
  19. Jeff KingAug 23, 2023

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.