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

Re: [PATCH] ls-files.c: add --only-object-name option

From
ZheNing Hu <adlternative@gmail.com>
Date
Jun 8, 2022, 14:38 UTC
Message-ID
<CAOLTT8Sz3q2db1fRcHp7Exnarw4sMCnUfAF6bot+pwYxmXJjiw@mail.gmail.com>
In-Reply-To
<220606.86zgipvg7e.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> 于2022年6月7日周二 01:45写道:
Show 33 quoted lines
>
>
> On Mon, Jun 06 2022, ZheNing Hu via GitGitGadget wrote:
>
> > From: ZheNing Hu <adlternative@gmail.com>
> >
> > `git ls-files --stage` default output format is:
> >
> > [<tag> ]<mode> <object> <stage> <file>
> >
> > sometime we want to find a path's corresponding objectname,
> > we will parse the output and extract objectname from it
> > again and again.
> >
> > So introduce a new option `--only-object-name` which can only
> > output objectname when giving `--stage` or `--resolve-undo`.
> >
> > Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> > ---
> >     ls-files.c: add --only-object-name option
> >
> >     Something we want to extract objectname from git ls-files --stage, but
> >     git ls-file don't support something like --format=%(objectname) (which
> >     git ls-tree have implemented)
> >
> >     So now add a new option --only-object-name which can only output
> >     objectname.
> >
> >     (Maybe we should add something like git ls-files --format ?)
>
> Yes I think that would be very useful, especially if we could see if
> some of the code could be shared (maybe not).
>
Maybe I can try to implement it :-)
> But in any case shouldn't this be called --name-only to go with "git
> ls-tree"'s version of this? Or is there some subtle difference I'm
> missing...?
>

Eh, git ls-tree --name-only will only show file paths, so maybe --only-object-name will be better than --object-name-only in git ls-files.

Show 23 quoted lines
> > +check_resolve_undo_only_object_name() {
> > +     msg=$1
> > +     shift
> > +     while case $# in
> > +     0)      break ;;
> > +     1|2|3)  die "Bug in check-resolve-undo test" ;;
>
> Use the "BUG"  helper in thaht case.
> > +     esac
> > +     do
> > +             path=$1
> > +             shift
> > +             for stage in 1 2 3
> > +             do
> > +                     sha1=$1
> > +                     shift
> > +                     case "$sha1" in
> > +                     '') continue ;;
> > +                     esac
> > +                     sha1=$(git rev-parse --verify "$sha1")
>
> missing && here when invoking "git".
>

Sorry, but this function check_resolve_undo_only_object_name() is just a mock version of check_resolve_undo(), so maybe I should fix this function first?

Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 3 of 8 in “ls-files.c: add --only-object-name option”
  1. ls-files.c: add --only-object-name optionZheNing Hu via GitGitGadget, Jun 6, 2022
  2. Ævar Arnfjörð BjarmasonJun 6, 2022
  3. ZheNing HuJun 8, 2022
  4. Junio C HamanoJun 8, 2022
  5. ls-files.c: add --object-only optionZheNing Hu via GitGitGadget, Jun 9, 2022
  6. Junio C HamanoJun 9, 2022
  7. ZheNing HuJun 12, 2022
  8. Junio C HamanoJun 13, 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.