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

Re: [RFC PATCH 4/7] dir: Directories should be checked for matching pathspecs too

From
Elijah Newren <newren@gmail.com>
Date
Apr 5, 2018, 19:15 UTC
Message-ID
<CABPp-BEnFiEnao0NqU3GerYkpxO9fJadQLHo6_PZ-hXLZfbbdg@mail.gmail.com>
In-Reply-To
<20180405185805.GA21164@sigill.intra.peff.net>
On Thu, Apr 5, 2018 at 11:58 AM, Jeff King <peff@peff.net> wrote:
Show 9 quoted lines
> It sounds like correct_untracked_entries() is doing the wrong thing, and
> it should be aware of the pathspec-matching when culling entries. In
> other words, my understanding was that read_directory() does not
> necessarily promise to cull fully (which is what led to cf424f5fd in the
> first place), and callers are forced to apply their own pathspecs.
>
> The distinction is academic for this particular bug, but it makes me
> wonder if there are other cases where "clean" needs to be more careful
> with what comes out of dir.c.

Interesting, I read things very differently. Looking back at commit 6b1db43109ab ("clean: teach clean -d to preserve ignored paths", 2017-05-23), which introduced correct_untracked_entries(), I thought that correct_untracked_entries() wasn't there to correct pathspec issues with fill_directory(), but instead to special case the handling of files which are both untracked and ignored. Did I mis-read or were there other commits that changed the semantics?

Also, it would just seem odd to me that fill_directory() requires pathspecs, and it uses those pathspecs, but it doesn't guarantee that the files it returns matches them. That seems like an API ripe for mis-use, especially since I don't see any comment in the code about such an assumption. Is that really the expectation?

Previous: Jeff KingNext: Jeff King
Message 6 of 17 in “Fix `git clean` with pathspecs”
  1. 0/7 Fix `git clean` with pathspecsElijah Newren, Apr 5, 2018
  2. 7/7 If we do not want globs to recurse into subdirs without -d...Elijah Newren, Apr 5, 2018
  3. 6/7 dir: If our pathspec might match files under a dir, recurse into itElijah Newren, Apr 5, 2018
  4. 4/7 dir: Directories should be checked for matching pathspecs tooElijah Newren, Apr 5, 2018
  5. Jeff KingApr 5, 2018
  6. Elijah NewrenApr 5, 2018
  7. Jeff KingApr 5, 2018
  8. Junio C HamanoApr 9, 2018
  9. 3/7 t7300: Add some testcases showing failure to clean specified pathspecsElijah Newren, Apr 5, 2018
  10. 5/7 dir: Make the DO_MATCH_SUBMODULE code reusable for a non-submodule caseElijah Newren, Apr 5, 2018
  11. 1/7 dir.c: Fix typo in commentElijah Newren, Apr 5, 2018
  12. 2/7 dir.c: fix off-by-one error in match_pathspec_itemElijah Newren, Apr 5, 2018
  13. Jeff KingApr 5, 2018
  14. Elijah NewrenApr 5, 2018
  15. Jeff KingApr 5, 2018
  16. Elijah NewrenApr 5, 2018
  17. Jeff KingApr 6, 2018

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.