{"thread":{"id":"66745","subject":"[Outreachy] Guidance on a possible pathspec contribution","startedAt":"2026-11-02T11:25:28Z","lastAt":"2026-11-02T11:25:28Z","messageCount":1,"participants":["Srujith Poojary"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"557165","messageId":"CABh_KWhJt0JiqhJYxnZmvHjkAs-gCyP8++DK+Pr+-So142YfvA@mail.gmail.com","threadId":"66745","inReplyTo":null,"subject":"[Outreachy] Guidance on a possible pathspec contribution","fromName":"Srujith Poojary","fromEmail":"poojarysrujith@gmail.com","sentAt":"2026-11-02T11:25:28Z","receivedAt":"2026-11-02T11:25:28Z","isPatch":false,"sender":{"key":"poojarysrujith@gmail.com","avatar":null},"body":"Hello Git community,\n\nI am currently working on my proposal for the December 2026 round of\nOutreachy for the project \"Reduce Git's global state to enable Git's\nlibification.\"\n\nWhilst looking through pathspec.c, I noticed that\nfind_pathspecs_matching_skip_worktree() takes the index directly from\nthe global repository via the_repository->index.\n\nThis function finds pathspec matches for index entries that are either\nmarked as skip-worktree or are outside the sparse checkout.\n\nLooking at matches_skip_worktree() (which calls this helper), I\nnoticed that although the results are calculated and cached, no index\nis passed to the wrapper.\n\nThe existing find_pathspecs_matching_against_index() API already\naccepts an explicit struct index_state *istate from its caller.\nHowever, it also takes an enum ps_skip_worktree_action as an argument,\nwhich currently has only two options. One option includes\nskip-worktree and out-of-sparse-checkout entries in matching, while\nthe other ignores those entries. There is no option to match only\nthose special entries.\n\nI am thinking of two potential solutions.\n\nOption 1: Continue using the specialised helper function, but pass the\nindex_state explicitly. This would also require looking into passing\nthe index through matches_skip_worktree() and its callers.\n\nOption 2: Look into adding another option to the existing\nps_skip_worktree_action enum and updating the matching logic. This\ncould allow us to match only skip-worktree or out-of-sparse-checkout\nentries using the existing matching API.\n\nLooking into where matches_skip_worktree() is used, I found calls in\npathspec.c, builtin/add.c and builtin/rm.c.\n\nIn builtin/rm.c, I also noticed several other uses of the_repository.\nSimilarly, pathspec.c has other uses of the_repository, including in\ninit_pathspec_item(). So I understand that changing this helper alone\nwould only address one specific dependency and would not make the\nwhole of pathspec.c or builtin/rm.c independent of global repository\nstate.\n\nI have a few questions:\n\n- Do you think this is a useful and focused contribution to help with\nGit's libification?\n- Does passing the index explicitly through the specialised helper and\nwrapper make more sense, or should I look into modifying the existing\nmatching API?\n- Is there any similar work already planned or being done?\n\nI haven't implemented either of these approaches or tested them yet. I\nwanted to get a good understanding of how the existing code works and\ncheck whether this would be a suitable contribution before proceeding.\n\nThanks for your time.\n\nKind regards,\nSrujith\n\n"}]}