[PATCH v3 0/4] diff: add pathspec support to --no-index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jacob Keller <jacob.keller@xxxxxxxxx>

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 likely still needs some reworks, and I have some open questions in the
final implementation:

 1) pathspecs must all come after the first two path arguments, you
    can't re-arrange them to come first. I'm treating them sort of like
    the treeish arguments to git diff-tree.

 2) The pathspecs are interpreted relative to the provided paths, and
    thus will always need to be specified as relative paths, and will be
    interpreted as relative to the root of the search for each path
    separately.

 3) negative pathspecs have to be fully qualified from the root, i.e.
    ':(exclude)file' will only exclude 'a/file' and not 'a/b/file'
    unless you also use '(glob)' or similar. I think this matches the
    other pathspec support, but I an not 100% sure.

  4) I'm not certain about exposing match_pathspec_with_flags as-is,
     since DO_MATCH_EXCLUDE shouldn't be passed. I got the behavior I
     expected with DO_MATCH_LEADING_PATHSPEC, but it feels a bit of a
     weird API. Perhaps match_pathspec could set both flags when is_dir
     is true? But would that break other callers?

However, this version now has documentation and some test cases. I found a
few issues with my original implementation in v2, which I've fixed.

I also an open to suggestions on better ways to handle the matching.
Currently I need a separate set of pathspecs for both paths, since I need to
make sure they get rooted appropriately. I don't know if there is a better
solution that would allow using the same pathspec structure for both
comparisons.

Jacob Keller (4):
  prefix_path: support prefixes not ending in trailing slash
  pathspec: expose match_pathspec_with_flags
  pathspec: add flag to indicate operation without repository
  diff --no-index: support limiting by pathspec

 pathspec.h                  |  13 +++++
 builtin/diff.c              |   2 +-
 diff-no-index.c             |  91 ++++++++++++++++++++++++------
 dir.c                       |  20 ++++---
 pathspec.c                  |   6 +-
 setup.c                     |   4 +-
 Documentation/git-diff.adoc |  10 +++-
 t/t0060-path-utils.sh       |  18 ++++++
 t/t4053-diff-no-index.sh    | 107 ++++++++++++++++++++++++++++++++++++
 9 files changed, 240 insertions(+), 31 deletions(-)

-- 
2.48.1.397.gec9d649cc640





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux