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

Re: [PATCH v2 6/9] object-file: split out functions relating to index subsystem

From
Patrick Steinhardt <ps@pks.im>
Date
Apr 15, 2025, 09:19 UTC
Message-ID
<Z_4kmxMhCnsRyPwn@pks.im>
In-Reply-To
<20250412081724.GA109770@coredump.intra.peff.net>
On Sat, Apr 12, 2025 at 04:17:24AM -0400, Jeff King wrote:
Show 39 quoted lines
> On Fri, Apr 11, 2025 at 11:29:55AM +0200, Patrick Steinhardt wrote:
> 
> > Split out functions relating to the index subsystem from "object-file.c"
> > to help us separate concerns.
> 
> I know these functions all start with "index_", and they do take an
> index_state variable, but I'm not sure they are really about Git's index
> subsystem at all.
> 
> The term "index" here is more about "compute the sha1 index of the
> content". E.g., the function index_path() goes all the way back to
> ec1fcc16af (Show original and resulting blob object info in diff
> output., 2005-10-07)!
> 
> Back then it did not take an index struct, or even care about having an
> index at all. Later, they learned to call convert_to_git() in 6c510bee20
> (Lazy man's auto-CRLF, 2007-02-13). And that function may check the
> index for .gitattributes files.
> 
> It originally just used the global the_index variable for that, but
> later commits like 58bf2a4cc7 (sha1-file.c: remove implicit dependency
> on the_index, 2018-09-21) passed the istate around the call stack.
> 
> So having access to an index struct is mostly incidental to these
> functions. Which makes sense looking at the callers: there are many
> pure-object operations that would work without an index (or even a repo
> in some cases!) like hash-object, git-replace, diff.
> 
>   Side note: I'm actually not even sure we would read attributes from
>   the index, since we don't set GIT_ATTR_INDEX. So I wondered if we
>   could simply pass NULL to convert_to_git() here. But I think these
>   days some of the "auto" CRLF modes also have heuristics based on
>   what's the content we find in the index for that path. See
>   has_crlf_in_index() and its callers.
> 
> 
> So it seems to me that these really are more about creating objects than
> they are about the index. I don't mind splitting them out, but it seems
> like they're equally weird in read-cache.[ch].

Yeah, I was too trigger-happy in this case indeed. I'll retain the code as-is for now, thanks!

Patrick
Previous: Junio C HamanoNext: Patrick Steinhardt
Message 34 of 53 in “Split up "object-file.c"”
  1. 0/9 Split up "object-file.c"Patrick Steinhardt, Apr 8, 2025
  2. 1/9 object-file: move `safe_create_leading_directories()` into "dir.c"Patrick Steinhardt, Apr 8, 2025
  3. Elijah NewrenApr 9, 2025
  4. Patrick SteinhardtApr 11, 2025
  5. Elijah NewrenApr 11, 2025
  6. Patrick SteinhardtApr 15, 2025
  7. Junio C HamanoApr 15, 2025
  8. 2/9 object-file: move `git_open_cloexec()` to "compat/open.c"Patrick Steinhardt, Apr 8, 2025
  9. 3/9 object-file: move `xmmap()` into "wrapper.c"Patrick Steinhardt, Apr 8, 2025
  10. Elijah NewrenApr 9, 2025
  11. 4/9 object-file: split out functions relating to object store subsystemPatrick Steinhardt, Apr 8, 2025
  12. 5/9 object-file: split up concerns of `HASH_*` flagsPatrick Steinhardt, Apr 8, 2025
  13. 6/9 object-file: split out functions relating to index subsystemPatrick Steinhardt, Apr 8, 2025
  14. 7/9 object: split out functions relating to object store subsystemPatrick Steinhardt, Apr 8, 2025
  15. 8/9 object-store: remove global array of cached objectsPatrick Steinhardt, Apr 8, 2025
  16. 9/9 object-store: merge "object-store-ll.h" and "object-store.h"Patrick Steinhardt, Apr 8, 2025
  17. Junio C HamanoApr 8, 2025
  18. Patrick SteinhardtApr 11, 2025
  19. Elijah NewrenApr 9, 2025
  20. Patrick SteinhardtApr 11, 2025
  21. 0/9 Split up "object-file.c"Patrick Steinhardt, Apr 11, 2025
  22. 1/9 object-file: move `safe_create_leading_directories()` into "dir.c"Patrick Steinhardt, Apr 11, 2025
  23. Junio C HamanoApr 11, 2025
  24. Eric SunshineApr 11, 2025
  25. Patrick SteinhardtApr 15, 2025
  26. Junio C HamanoApr 15, 2025
  27. 2/9 object-file: move `git_open_cloexec()` to "compat/open.c"Patrick Steinhardt, Apr 11, 2025
  28. 3/9 object-file: move `xmmap()` into "wrapper.c"Patrick Steinhardt, Apr 11, 2025
  29. 4/9 object-file: split out functions relating to object store subsystemPatrick Steinhardt, Apr 11, 2025
  30. 5/9 object-file: split up concerns of `HASH_*` flagsPatrick Steinhardt, Apr 11, 2025
  31. 6/9 object-file: split out functions relating to index subsystemPatrick Steinhardt, Apr 11, 2025
  32. Jeff KingApr 12, 2025
  33. Junio C HamanoApr 14, 2025
  34. Patrick SteinhardtApr 15, 2025
  35. 7/9 object: split out functions relating to object store subsystemPatrick Steinhardt, Apr 11, 2025
  36. 8/9 object-store: remove global array of cached objectsPatrick Steinhardt, Apr 11, 2025
  37. Junio C HamanoApr 11, 2025
  38. Patrick SteinhardtApr 15, 2025
  39. 9/9 object-store: merge "object-store-ll.h" and "object-store.h"Patrick Steinhardt, Apr 11, 2025
  40. 00/10 Split up "object-file.c"Patrick Steinhardt, Apr 15, 2025
  41. 01/10 object-file: move `mkdir_in_gitdir()` into "path.c"Patrick Steinhardt, Apr 15, 2025
  42. 02/10 object-file: move `safe_create_leading_directories()` into "path.c"Patrick Steinhardt, Apr 15, 2025
  43. 03/10 object-file: move `git_open_cloexec()` to "compat/open.c"Patrick Steinhardt, Apr 15, 2025
  44. 04/10 object-file: move `xmmap()` into "wrapper.c"Patrick Steinhardt, Apr 15, 2025
  45. 05/10 object-file: split out functions relating to object store subsystemPatrick Steinhardt, Apr 15, 2025
  46. 06/10 object-file: split up concerns of `HASH_*` flagsPatrick Steinhardt, Apr 15, 2025
  47. 07/10 object-file: drop `index_blob_stream()`Patrick Steinhardt, Apr 15, 2025
  48. 08/10 object: split out functions relating to object store subsystemPatrick Steinhardt, Apr 15, 2025
  49. 09/10 object-store: remove global array of cached objectsPatrick Steinhardt, Apr 15, 2025
  50. 10/10 object-store: merge "object-store-ll.h" and "object-store.h"Patrick Steinhardt, Apr 15, 2025
  51. Elijah NewrenApr 16, 2025
  52. Patrick SteinhardtApr 16, 2025
  53. Junio C HamanoApr 16, 2025

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.