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

Re: [PATCH] ls-files: add %(skipworktree) atom to format option

From
ZheNing Hu <adlternative@gmail.com>
Date
Jan 13, 2023, 16:59 UTC
Message-ID
<CAOLTT8SEBG+cgVsX5n2Vww=M0PCOwH0JxWY3dG9_nsRnRf6+fA@mail.gmail.com>
In-Reply-To
<230112.86tu0w12kc.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> 于2023年1月12日周四 18:15写道:
Show 17 quoted lines
>
>
> On Wed, Jan 11 2023, ZheNing Hu via GitGitGadget wrote:
>
> > From: ZheNing Hu <adlternative@gmail.com>
> >
> > Because sometimes we want to check if the files in the
> > index match the sparse specification by using
> > `git ls-files -t`, but `-t` option have semi-deprecated,
> >
> > So introduce "%(skipworktree)" atom to git ls-files
> > `--format` option. When we use this option, if the file
> > match the sparse specification and removed from working
> > tree, it will output "yes", othewise, output "no".
>
> Your code says "true" and "false", not "yes" or "no". Which is it ?:)
>
true/false. This is a typo.
Show 10 quoted lines
> More generally it's unfortanute that we don't support the ref-filter.c
> formats more generally, then we could just make this 1 or the empty
> string, and you'd do:
>
>         %(if)%(skipworktree)%(then)true%(else)false%(end)
>
> Now, I don't think your change needs to be blocked by generalizing that
> if/else stuff in ref-filter, that would probably be some thousand-line
> series if we're lucky, even though it's a good eventual goal.
>

Aha, if we were to introduce %(if) %(else) in the ref-filter I'm sure that would be a very complicated situation.

Show 5 quoted lines
> But I feel strongly that you should not pick "true", or "false", or
> "yes" or "no", but rather "1" or "", here, as doing so will be
> future-proof when it comes to this format being compatible with using
> the ref-filter.c conditional support.
> >
Good point.
Show 49 quoted lines
> > Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> > ---
> >     ls-files: add %(skipworktree) atom to format option
> >
> >     git ls-files -t is semi-deprecated, but in face we need to use -t option
> >     to check if a file in the index match the sparse specification.
> >
> >     So I think this feature can be migrated to git ls-files --format, add a
> >     %(skipworktree) atom to indicate whether the file in the index match the
> >     sparse specification and is removed from the working tree.
> >
> >     v1: add %(skipworktree) atom to git ls-files format option.
> >
> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1458%2Fadlternative%2Fzh%2Fls-file-format-skipworktree-v1
> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1458/adlternative/zh/ls-file-format-skipworktree-v1
> > Pull-Request: https://github.com/gitgitgadget/git/pull/1458
> >
> >  Documentation/git-ls-files.txt |  6 ++++++
> >  builtin/ls-files.c             |  3 +++
> >  t/t3013-ls-files-format.sh     | 22 ++++++++++++++++++++++
> >  3 files changed, 31 insertions(+)
> >
> > diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
> > index 440043cdb8e..0e50307121d 100644
> > --- a/Documentation/git-ls-files.txt
> > +++ b/Documentation/git-ls-files.txt
> > @@ -260,6 +260,12 @@ eolattr::
> >       that applies to the path.
> >  path::
> >       The pathname of the file which is recorded in the index.
> > +skipworktree::
> > +     If the file in the index marked with SKIP_WORKTREE bit.
> > +     It means the file do not match the sparse specification
> > +     and removed from working tree.
> > +     See link:technical/sparse-checkout.txt[sparse-checkout]
> > +     for more information.
>
> I likewise think this won't need to be blocked, but this is a sign that
> we should probably move these to the main doc namespace. See 1e2320161d2
> (docs: move http-protocol docs to man section 5, 2022-08-04) (and
> commits before that) for prior art.
>
> But what we should fix here is that this ling is wrong, as you can see
> in that commit we need to link to the HTML docs for these (confusing as
> that is).
>
> Or (and I didn't check) if we never generate the *.html either for this
> particular one this link will always be broken. I.e. we won't install
> this, nor the HTML docs.

Yeah, you should be right: there may be a problem with the link here, maybe this needs a patch to migrate technical/sparse-checkout.txt.

Thanks, ZheNing Hu

Previous: Ævar Arnfjörð BjarmasonNext: ZheNing Hu via GitGitGadget
Message 9 of 24 in “ls-files: add %(skipworktree) atom to format option”
  1. ls-files: add %(skipworktree) atom to format optionZheNing Hu via GitGitGadget, Jan 11, 2023
  2. Elijah NewrenJan 12, 2023
  3. Junio C HamanoJan 12, 2023
  4. Elijah NewrenJan 13, 2023
  5. ZheNing HuJan 13, 2023
  6. ZheNing HuJan 13, 2023
  7. Elijah NewrenJan 14, 2023
  8. Ævar Arnfjörð BjarmasonJan 12, 2023
  9. ZheNing HuJan 13, 2023
  10. 0/2 ls-files: add %(skipworktree) atom to format optionZheNing Hu via GitGitGadget, Jan 19, 2023
  11. 1/2 docs: fix sparse-checkout docs linkZheNing Hu via GitGitGadget, Jan 19, 2023
  12. Elijah NewrenJan 20, 2023
  13. Martin ÅgrenJan 20, 2023
  14. ZheNing HuJan 23, 2023
  15. ZheNing HuJan 23, 2023
  16. 2/2 ls-files: add %(skipworktree) atom to format optionZheNing Hu via GitGitGadget, Jan 19, 2023
  17. Elijah NewrenJan 20, 2023
  18. Junio C HamanoJan 20, 2023
  19. ZheNing HuJan 23, 2023
  20. Junio C HamanoJan 23, 2023
  21. ZheNing HuJan 23, 2023
  22. 0/2 ls-files: add %(skipworktree) atom to format optionZheNing Hu via GitGitGadget, Feb 4, 2023
  23. 1/2 docs: fix sparse-checkout docs linkZheNing Hu via GitGitGadget, Feb 4, 2023
  24. 2/2 ls-files: add %(skipworktree) atom to format optionZheNing Hu via GitGitGadget, Feb 4, 2023

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.