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

[PATCH v4 00/12] Fix some git clean issues

From
Elijah Newren <newren@gmail.com>
Date
Sep 17, 2019, 16:34 UTC
Message-ID
<20190917163504.14566-1-newren@gmail.com>
In-Reply-To
<20190912221240.18057-1-newren@gmail.com>
This patch series fixes a few issues with git-clean:
  * Failure to clean when multiple pathspecs are specified, reported both
    in April 2018[1] and again in May 2019[2].
  * Failure to preserve both tracked and untracked files within a nested
    Git repository reported a few weeks ago by SZEDER[3].
It builds on sg/clean-nested-repo-with-ignored.

[1] https://public-inbox.org/git/20180405173446.32372-4-newren@gmail.com/ [2] https://public-inbox.org/git/20190531183651.10067-1-rafa.almas@gmail.com/ [3] https://public-inbox.org/git/20190825185918.3909-1-szeder.dev@gmail.com/

Changes since v3:
  * Clarified a couple commit messages highlighted by Junio.
Elijah Newren (12):
  t7300: add testcases showing failure to clean specified pathspecs
  dir: fix typo in comment
  dir: fix off-by-one error in match_pathspec_item
  dir: also check directories for matching pathspecs
  dir: make the DO_MATCH_SUBMODULE code reusable for a non-submodule
    case
  dir: if our pathspec might match files under a dir, recurse into it
  dir: add commentary explaining match_pathspec_item's return value
  git-clean.txt: do not claim we will delete files with -n/--dry-run
  clean: disambiguate the definition of -d
  clean: avoid removing untracked files in a nested git repository
  clean: rewrap overly long line
  clean: fix theoretical path corruption
 Documentation/git-clean.txt | 16 +++++-----
 builtin/clean.c             | 15 +++++++--
 dir.c                       | 63 +++++++++++++++++++++++++++----------
 dir.h                       |  8 +++--
 t/t7300-clean.sh            | 44 +++++++++++++++++++++++---
 5 files changed, 112 insertions(+), 34 deletions(-)
Range-diff:
 1:  fe35ab8cc3 !  1:  a48d4e7faf t7300: add testcases showing failure to clean specified pathspecs
    @@ -28,9 +28,15 @@
         showed that the same buggy behavior exists without using that flag, and
         has in fact existed since before cf424f5fd89b.
     
    -    Add testcases showing that multiple untracked files within entirely
    -    untracked directories cannot be cleaned when specifying these files to
    -    git clean via pathspecs.
    +    Although these problems at first are perceived to be different (e.g.
    +    never clearing out the requested files vs. taking multiple invocations
    +    to get everything cleared out), they are actually just different
    +    manifestations of the same problem.  The case with multiple directories
    +    that have no tracked files is the more general case; solving it will
    +    solve all the others.  So, I concentrate on it.  Add testcases showing
    +    that multiple untracked files within entirely untracked directories
    +    cannot be cleaned when specifying these files to git clean via
    +    pathspecs.
     
         Signed-off-by: Elijah Newren <newren@gmail.com>
     
 2:  707d287d79 =  2:  eb00b46822 dir: fix typo in comment
 3:  bb316e82b2 !  3:  c0e5b820a9 dir: fix off-by-one error in match_pathspec_item
    @@ -6,11 +6,22 @@
         namelen will be 4, and match[namelen] will be 'b'.  The correct location
         of the directory separator is namelen-1.
     
    -    The reason the code worked anyway was that the following code immediately
    -    checked whether the first matchlen characters matched (which they do) and
    -    then bailed and return MATCHED_RECURSIVELY anyway since wildmatch doesn't
    -    have the ability to check if "name" can be matched as a directory (or
    -    prefix) against the pathspec.
    +    However, other callers of match_pathspec_item() such as builtin/grep.c's
    +    submodule_path_match() will compare against a path named "foo" instead of
    +    "foo/".  It might be better to change all the callers to be consistent,
    +    as discussed at
    +       https://public-inbox.org/git/xmqq7e6cdnkr.fsf@gitster-ct.c.googlers.com/
    +    and
    +       https://public-inbox.org/git/CABPp-BERWUPCPq-9fVW1LNocqkrfsoF4BPj3gJd9+En43vEkTQ@mail.gmail.com/
    +    but there are many cases to audit, so for now just make sure we handle
    +    both cases with and without a trailing slash.
    +
    +    The reason the code worked despite this sometimes-off-by-one error was
    +    that the subsequent code immediately checked whether the first matchlen
    +    characters matched (which they do) and then bailed and return
    +    MATCHED_RECURSIVELY anyway since wildmatch doesn't have the ability to
    +    check if "name" can be matched as a directory (or prefix) against the
    +    pathspec.
     
         Signed-off-by: Elijah Newren <newren@gmail.com>
     
 4:  56319f934a =  4:  397775ec35 dir: also check directories for matching pathspecs
 5:  81593a565c =  5:  b836de82c0 dir: make the DO_MATCH_SUBMODULE code reusable for a non-submodule case
 6:  9566823a0f =  6:  feb317d090 dir: if our pathspec might match files under a dir, recurse into it
 7:  7821898ba7 =  7:  0a574d6779 dir: add commentary explaining match_pathspec_item's return value
 8:  13def5df57 =  8:  0eaa08537c git-clean.txt: do not claim we will delete files with -n/--dry-run
 9:  e6b274abf7 =  9:  a1438301bb clean: disambiguate the definition of -d
10:  5f4ef14765 = 10:  8dc21923ee clean: avoid removing untracked files in a nested git repository
11:  4e30e62eb1 = 11:  707b6a5509 clean: rewrap overly long line
12:  de2444f7cb = 12:  84a90010ed clean: fix theoretical path corruption
-- 
2.22.1.17.g6e632477f7.dirty
Previous: Elijah NewrenNext: Elijah Newren
Message 42 of 73 in “t7300-clean: demonstrate deleting nested repo with an ignored file breakage”
  1. t7300-clean: demonstrate deleting nested repo with an ignored file breakageSZEDER Gábor, Aug 25, 2019
  2. SZEDER GáborAug 25, 2019
  3. Philip OakleyAug 25, 2019
  4. SZEDER GáborAug 26, 2019
  5. 00/12 Fix some git clean issuesElijah Newren, Sep 5, 2019
  6. 01/12 t7300: Add some testcases showing failure to clean specified pathspecsElijah Newren, Sep 5, 2019
  7. 02/12 dir: fix typo in commentElijah Newren, Sep 5, 2019
  8. 04/12 dir: Directories should be checked for matching pathspecs tooElijah Newren, Sep 5, 2019
  9. 03/12 dir: fix off-by-one error in match_pathspec_itemElijah Newren, Sep 5, 2019
  10. 05/12 dir: Make the DO_MATCH_SUBMODULE code reusable for a non-submodule caseElijah Newren, Sep 5, 2019
  11. 07/12 dir: add commentary explaining match_pathspec_item's return valueElijah Newren, Sep 5, 2019
  12. 06/12 dir: If our pathspec might match files under a dir, recurse into itElijah Newren, Sep 5, 2019
  13. 10/12 clean: avoid removing untracked files in a nested git repositoryElijah Newren, Sep 5, 2019
  14. SZEDER GáborSep 5, 2019
  15. 09/12 clean: disambiguate the definition of -dElijah Newren, Sep 5, 2019
  16. 11/12 clean: rewrap overly long lineElijah Newren, Sep 5, 2019
  17. 12/12 clean: fix theoretical path corruptionElijah Newren, Sep 5, 2019
  18. SZEDER GáborSep 5, 2019
  19. Elijah NewrenSep 7, 2019
  20. 08/12 git-clean.txt: do not claim we will delete files with -n/--dry-runElijah Newren, Sep 5, 2019
  21. SZEDER GáborSep 5, 2019
  22. Elijah NewrenSep 7, 2019
  23. 00/12 Fix some git clean issuesElijah Newren, Sep 12, 2019
  24. 01/12 t7300: add testcases showing failure to clean specified pathspecsElijah Newren, Sep 12, 2019
  25. Junio C HamanoSep 13, 2019
  26. Elijah NewrenSep 13, 2019
  27. Junio C HamanoSep 13, 2019
  28. 03/12 dir: fix off-by-one error in match_pathspec_itemElijah Newren, Sep 12, 2019
  29. Junio C HamanoSep 13, 2019
  30. 02/12 dir: fix typo in commentElijah Newren, Sep 12, 2019
  31. 05/12 dir: make the DO_MATCH_SUBMODULE code reusable for a non-submodule caseElijah Newren, Sep 12, 2019
  32. 04/12 dir: also check directories for matching pathspecsElijah Newren, Sep 12, 2019
  33. 06/12 dir: if our pathspec might match files under a dir, recurse into itElijah Newren, Sep 12, 2019
  34. Junio C HamanoSep 13, 2019
  35. 07/12 dir: add commentary explaining match_pathspec_item's return valueElijah Newren, Sep 12, 2019
  36. Junio C HamanoSep 13, 2019
  37. 09/12 clean: disambiguate the definition of -dElijah Newren, Sep 12, 2019
  38. 10/12 clean: avoid removing untracked files in a nested git repositoryElijah Newren, Sep 12, 2019
  39. 11/12 clean: rewrap overly long lineElijah Newren, Sep 12, 2019
  40. 08/12 git-clean.txt: do not claim we will delete files with -n/--dry-runElijah Newren, Sep 12, 2019
  41. 12/12 clean: fix theoretical path corruptionElijah Newren, Sep 12, 2019
  42. 00/12 Fix some git clean issuesElijah Newren, Sep 17, 2019
  43. 02/12 dir: fix typo in commentElijah Newren, Sep 17, 2019
  44. 01/12 t7300: add testcases showing failure to clean specified pathspecsElijah Newren, Sep 17, 2019
  45. 03/12 dir: fix off-by-one error in match_pathspec_itemElijah Newren, Sep 17, 2019
  46. 04/12 dir: also check directories for matching pathspecsElijah Newren, Sep 17, 2019
  47. [BUG] git is segfaulting, was [PATCH v4 04/12] dir: also check directories for matching pathspecsDenton Liu, Sep 25, 2019
  48. Elijah NewrenSep 25, 2019
  49. Denton LiuSep 25, 2019
  50. Denton LiuSep 26, 2019
  51. Elijah NewrenSep 27, 2019
  52. SZEDER GáborSep 27, 2019
  53. SZEDER GáborSep 27, 2019
  54. Denton LiuSep 27, 2019
  55. dir: special case check for the possibility that pathspec is NULLElijah Newren, Sep 30, 2019
  56. Denton LiuSep 30, 2019
  57. Elijah NewrenOct 1, 2019
  58. dir: special case check for the possibility that pathspec is NULLElijah Newren, Oct 1, 2019
  59. Denton LiuOct 1, 2019
  60. Elijah NewrenOct 1, 2019
  61. dir: special case check for the possibility that pathspec is NULLElijah Newren, Oct 1, 2019
  62. Denton LiuOct 1, 2019
  63. Elijah NewrenOct 1, 2019
  64. Elijah NewrenOct 2, 2019
  65. SZEDER GáborOct 7, 2019
  66. 08/12 git-clean.txt: do not claim we will delete files with -n/--dry-runElijah Newren, Sep 17, 2019
  67. 11/12 clean: rewrap overly long lineElijah Newren, Sep 17, 2019
  68. 12/12 clean: fix theoretical path corruptionElijah Newren, Sep 17, 2019
  69. 09/12 clean: disambiguate the definition of -dElijah Newren, Sep 17, 2019
  70. 10/12 clean: avoid removing untracked files in a nested git repositoryElijah Newren, Sep 17, 2019
  71. 07/12 dir: add commentary explaining match_pathspec_item's return valueElijah Newren, Sep 17, 2019
  72. 06/12 dir: if our pathspec might match files under a dir, recurse into itElijah Newren, Sep 17, 2019
  73. 05/12 dir: make the DO_MATCH_SUBMODULE code reusable for a non-submodule caseElijah Newren, Sep 17, 2019

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.