git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/3] diff: add pathspec support to --no-index
@ 2025-05-21 23:29 Jacob Keller
  2025-05-21 23:29 ` [PATCH v4 1/3] pathspec: add match_leading_pathspec variant Jacob Keller
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Jacob Keller @ 2025-05-21 23:29 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jacob Keller

From: Jacob Keller <jacob.keller@gmail.com>

This series adds support for using pathspecs to limit the comparison when
using git diff --no-index. This is similar to how you can limit what is
included with pathspecs when comparing inside a repository.

This version uses only one set of pathspecs and instead uses some logic to
skip past the root of each directory tree being scanned. This avoids needing
to parse pathspecs multiple times, and is overall a simpler approach.

I also opted to add a match_leading_pathspec() instead of exposing the
match_pathspec_with_flags(), since I didn't how DO_MATCH_EXCLUDES wasn't
exposed. It felt messy.

I tried a couple of different methods for skipping past the leading portion
of a path, including skip_prefix. Ultimately just the index to skip to
seemed like the simplest solution. I like that it means we only need a
single pathspec array now, and that we no longer have to worry about
changing prefix_path_gently.

Changes since v3:
* Drop the patch modifying prefix_path(_gently).
* Instead of exposing the do_match_pathspec flags, create a
  match_leading_pathspec() variant that sets both flags when is_dir is true.
* Use some simple logic to skip past the starting portions of each path
  before calling match_leading_pathspec
* Re-write the commit message for the final patch
* Add a couple more test cases
* Simplify existing test cases to use --name-status
* Drop remaining TODOs

Jacob Keller (3):
  pathspec: add match_leading_pathspec variant
  pathspec: add flag to indicate operation without repository
  diff --no-index: support limiting by pathspec

 pathspec.h                  | 11 +++++
 builtin/diff.c              |  2 +-
 diff-no-index.c             | 89 ++++++++++++++++++++++++++++++-------
 dir.c                       | 19 ++++++--
 pathspec.c                  |  6 ++-
 Documentation/git-diff.adoc | 10 +++--
 t/t4053-diff-no-index.sh    | 75 +++++++++++++++++++++++++++++++
 7 files changed, 187 insertions(+), 25 deletions(-)

-- 
2.48.1.397.gec9d649cc640


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-09-24 18:23 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 23:29 [PATCH v4 0/3] diff: add pathspec support to --no-index Jacob Keller
2025-05-21 23:29 ` [PATCH v4 1/3] pathspec: add match_leading_pathspec variant Jacob Keller
2025-05-21 23:29 ` [PATCH v4 2/3] pathspec: add flag to indicate operation without repository Jacob Keller
2025-05-21 23:29 ` [PATCH v4 3/3] diff --no-index: support limiting by pathspec Jacob Keller
2025-06-04  2:37   ` Ben Knoble
2025-06-04 17:22     ` Jacob Keller
2025-06-04 18:27     ` Jacob Keller
2025-06-04 20:19       ` Junio C Hamano
2025-06-04 21:05         ` Jacob Keller
2025-06-04 21:36           ` D. Ben Knoble
2025-06-04 23:22             ` Junio C Hamano
2025-09-23 14:57   ` Johannes Schindelin
2025-09-23 22:48     ` Jacob Keller
2025-09-24 11:19       ` Johannes Schindelin
2025-09-24 18:19         ` Jacob Keller
2025-09-24 18:23           ` Jacob Keller
2025-05-22 21:37 ` [PATCH v4 0/3] diff: add pathspec support to --no-index Junio C Hamano
2025-05-22 21:50   ` Jacob Keller
2025-05-22 22:04     ` Junio C Hamano
2025-06-03 21:12 ` Junio C Hamano
2025-06-04  2:32   ` Ben Knoble
2025-06-05 15:34   ` Phillip Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).