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

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

From
ZheNing Hu <adlternative@gmail.com>
Date
Jan 23, 2023, 15:35 UTC
Message-ID
<CAOLTT8TztbirR9FmD0s_5iPQ9+NETfecXHE8xeJDNXQUNojSJA@mail.gmail.com>
In-Reply-To
<xmqqcz79xizc.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2023年1月21日周六 00:34写道:
Show 36 quoted lines
>
> Elijah Newren <newren@gmail.com> writes:
>
> > On Thu, Jan 19, 2023 at 9:34 AM ZheNing Hu via GitGitGadget
> > <gitgitgadget@gmail.com> wrote:
> >>
> >> From: ZheNing Hu <adlternative@gmail.com>
> >>
> >> Because sometimes we want to check if the files in the
> >> index match the sparse specification, so introduce
> >> "%(skipworktree)" atom to git ls-files `--format` option.
> >> When we use this option, if the file match the sparse
> >> specification, it will output "1", otherwise, output
> >> empty string "".
> >
> > Why is that output format useful?  It seems like it'll just lead to
> > bugs, or someone re-implementing the same field with a different name
> > to make it useful in the future.  In particular, if there are multiple
> > boolean fields and someone specifies e.g.
> >    git ls-files --format="%(path) %(skipworktree) %(intentToAdd)"
> > and both boolean fields are displayed the same way (either a "1" or a
> > blank string), and we see something like:
> >    foo.c 1
> >    bar.c 1
> > Then how do we know if foo.c and bar.c are SKIP_WORKTREE or
> > INTENT_TO_ADD?  The "1" could have come from either field.
>
> Perhaps it becomes useful in conjunction with %(if) and friends,
> when they become avaiable?
>
> Until then, I agree that the output format looks pretty klunky.
> The calling scripts still can do
>
>         --format='%(path) A=%(A) B=%(B) C=%(C)'
>
> and take an empty value as false, though.

Can this strange design be considered as a bad design of %(if) and %(else) in ref-filter?

Previous: Junio C HamanoNext: Junio C Hamano
Message 19 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.