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

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

From
ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 29, 2022, 12:00 UTC
Message-ID
<pull.1398.v3.git.1669723221.gitgitgadget@gmail.com>
In-Reply-To
<pull.1398.v2.git.1669344333627.gitgitgadget@gmail.com>

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/xmqqzgeqw0sy.fsf@gitster.g/ [3]: https://lore.kernel.org/git/07a25d48-e364-0d9b-6ffa-41a5984eb5db@github.com/ [4]: https://lore.kernel.org/git/pull.1368.git.1664036052741.gitgitgadget@gmail.com/ [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
-- 
gitgitgadget
Previous: ZheNing Hu via GitGitGadgetNext: ZheNing Hu via GitGitGadget
Message 9 of 11 in “[RFC] diff: introduce scope option”
  1. [RFC] diff: introduce scope optionZheNing Hu via GitGitGadget, Oct 31, 2022
  2. Taylor BlauNov 1, 2022
  3. ZheNing HuNov 1, 2022
  4. Elijah NewrenNov 1, 2022
  5. ZheNing HuNov 6, 2022
  6. Elijah NewrenNov 6, 2022
  7. ZheNing HuNov 14, 2022
  8. [RFC] diff: introduce --scope optionZheNing Hu via GitGitGadget, Nov 25, 2022
  9. 0/2 [RFC] diff: introduce scope optionZheNing Hu via GitGitGadget, Nov 29, 2022
  10. 2/2 [RPC] grep: introduce --scope optionZheNing Hu via GitGitGadget, Nov 29, 2022
  11. 1/2 [RFC] diff: introduce --scope optionZheNing Hu via GitGitGadget, Nov 29, 2022

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.