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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 于2022年6月7日周二 01:45写道:
>
>
> On Mon, Jun 06 2022, ZheNing Hu via GitGitGadget wrote:
>
> > From: ZheNing Hu <adlternative@xxxxxxxxx>
> >
> > `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@xxxxxxxxx>
> > ---
> >     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.

> > +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?




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux