Skip to content

RFC diff: introduce scope option

ZheNing Hu via GitGitGadget git 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 RFC Latest2 patches 0 repliesNew
  2. v2 RFC1 patch 0 repliesSuperseded
  3. v1 RFC1 patch 6 repliesSuperseded

v1 from the cover letter

1. add --restrict option to git diff, which restrict diff filespec in sparse-checkout specification. [4]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2diff: introduce --scope optionDocumentation/diff-options.txt builtin/diff-index.c builtin/diff-tree.c +10 more+488 -60 replies
2/2grep: introduce --scope optionDocumentation/git-grep.txt builtin/grep.c grep.h +1 more+63 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/2] [RFC] diff: introduce scope option

In [1], we discovered that users working on different sparse-checkout specification may download unnecessary blobs from each other's specification in collaboration. In [2] Junio suggested that maybe we can restrict some git command's filespec in sparse-checkout specification to elegantly solve this problem above. In [3]: Newren and Derrick Stolee prefer to name the option --scope={sparse, all}.

So this patch is attempt to do this thing on git diff:

v1:

1. add --restrict option to git diff, which restrict diff filespec in sparse-checkout specification. [4]

v2.

1. rename --restrict to --scope={sparse, all}, support --no-scope.
2. add config: diff.scope={sparse,all}.

v3.

1. with the help of newren's review, fix the wrong --scope behavior, its previous meaning was misrepresented as sparse patterns, and now it is fixed to match sparse specification. [5]
2. remove wrong diff.scope config.
3. apply --scope to git diff, git diff-index, git diff-tree.

v4.

1. create a OPT_SPARSE_SCOPE macro for easier add --scope option to other git commands later.
2. introduce --scope option to "git grep ".

Since I split --scope into a separate option, this option will not be directly inherited by git commands such as git log, git format-patch, etc. If necessary, we can add it to git log or other commands in a similar way later.

Global scope config haven’t implement yet... Since we haven't decided on an appropriate name for scope config. [6]

Note why I don't add --scope to "git grep --cached", because we can't use "" with "--cached", whether we use --scope=sparse or not , the resulting set of files it gets is the same.

[1]:
https://lore.kernel.org/git/CAOLTT8SHo66kGbvWr=+LQ9UVd1NHgqGGEYK2qq6==QgRCgLZqQ@mail.gmail.com/
[2]: https://lore.kernel.org/git/[email protected]/ [3]:
https://lore.kernel.org/git/[email protected]/
[4]:
https://lore.kernel.org/git/[email protected]/
[5]:
https://lore.kernel.org/git/CAOLTT8TceM-NpV2_hUCZj2Dx=W30f_9SHW8CcRH-pw32BRd-oA@mail.gmail.com/
[6]:
https://lore.kernel.org/git/CABPp-BGHMsMxP6e7p0HAZA=ugk+GY3XW6_EaTN=HzaLQYAzQYA@mail.gmail.com/

ZheNing Hu (2):
[RFC] diff: introduce --scope option
[RPC] grep: introduce --scope option

 Documentation/diff-options.txt   |  33 ++++
 Documentation/git-grep.txt       |  24 +++
 builtin/diff-index.c             |  24 ++-
 builtin/diff-tree.c              |  11 ++
 builtin/diff.c                   |  23 ++-
 builtin/grep.c                   |  10 +
 cache.h                          |   5 +
 diff-lib.c                       |  43 +++++
 diff.c                           |   2 +
 diff.h                           |   7 +
 dir.c                            |  52 ++++++
 dir.h                            |   4 +
 grep.h                           |   2 +
 parse-options.h                  |   7 +
 t/t1090-sparse-checkout-scope.sh | 303 +++++++++++++++++++++++++++++++
 tree-diff.c                      |   7 +
 16 files changed, 551 insertions(+), 6 deletions(-)

base-commit: 815c1e82021edbd99a2c423cf27f28863f28cef3
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1398%2Fadlternative%2Fzh%2Fdiff-scope-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1398/adlternative/zh/diff-scope-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1398

Contributor requested no range-diff. You can review it using these commands:
git fetch https://github.com/gitgitgadget/git c000d916 1d1b6618 git range-diff <options> c000d916..471a0691 083e0127..1d1b6618

Signature · 1 line
gitgitgadget