diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-06-17 10:44:41 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-06-17 10:44:42 -0700 |
| commit | 2024ab3d97c482809cdc50e6adcc35750cd3bda0 (patch) | |
| tree | 49894980f3d53a331ba24fdfa88b2cf2e3f6c212 /pathspec.c | |
| parent | 5e22d03832742362ad83733f838e645aba9c9bb4 (diff) | |
| parent | 09fb155f11128b505c227aae673de957c9388240 (diff) | |
| download | git-2024ab3d97c482809cdc50e6adcc35750cd3bda0.tar.xz | |
Merge branch 'jk/diff-no-index-with-pathspec'
"git diff --no-index dirA dirB" can limit the comparison with
pathspec at the end of the command line, just like normal "git
diff".
* jk/diff-no-index-with-pathspec:
diff --no-index: support limiting by pathspec
pathspec: add flag to indicate operation without repository
pathspec: add match_leading_pathspec variant
Diffstat (limited to 'pathspec.c')
| -rw-r--r-- | pathspec.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pathspec.c b/pathspec.c index 2b4e434bc0..a3ddd701c7 100644 --- a/pathspec.c +++ b/pathspec.c @@ -492,7 +492,7 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags, if (!match) { const char *hint_path; - if (!have_git_dir()) + if ((flags & PATHSPEC_NO_REPOSITORY) || !have_git_dir()) die(_("'%s' is outside the directory tree"), copyfrom); hint_path = repo_get_work_tree(the_repository); @@ -614,6 +614,10 @@ void parse_pathspec(struct pathspec *pathspec, (flags & PATHSPEC_PREFER_FULL)) BUG("PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL are incompatible"); + if ((flags & PATHSPEC_NO_REPOSITORY) && + (~magic_mask & (PATHSPEC_ATTR | PATHSPEC_FROMTOP))) + BUG("PATHSPEC_NO_REPOSITORY is incompatible with PATHSPEC_ATTR and PATHSPEC_FROMTOP"); + /* No arguments with prefix -> prefix pathspec */ if (!entry) { if (flags & PATHSPEC_PREFER_FULL) |
