Re: [PATCH v5] ls-files: introduce "--format" option
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- Jul 5, 2022, 19:28 UTC
- Message-ID
- <20220705192839.irfrfx4z6jwimcmu@tb-raspi4>
- In-Reply-To
- <pull.1262.v5.git.1657002760815.gitgitgadget@gmail.com>
On Tue, Jul 05, 2022 at 06:32:40AM +0000, ZheNing Hu via GitGitGadget wrote:
Show 6 quoted lines
> From: ZheNing Hu <adlternative@gmail.com> > > Add a new option --format that output index enties > informations with custom format, taking inspiration > from the option with the same name in the `git ls-tree` > command.
[]
> +FIELD NAMES
Nice
Show 18 quoted lines
> +----------- > +Various values from structured fields can be used to interpolate > +into the resulting output. For each outputting line, the following > +names can be used: > + > +objectmode:: > + The mode of the file which is recorded in the index. > +objectname:: > + The name of the file which is recorded in the index. > +stage:: > + The stage of the file which is recorded in the index. > +eolinfo:index:: > +eolinfo:worktree:: > + The <eolinfo> (see the description of the `--eol` option) of > + the contents in the index or in the worktree for the path. > +eolattr:: > + The <eolattr> (see the description of the `--eol` option) > + that applies to the path.
This may be a matter of taste, looking at the eol-stuff: Should the ':' be dropped and we have 3 fieldnames like this:
eolindex eolworktree eolattr
Show 24 quoted lines
> +test_expect_success 'git ls-files --format eolinfo:index' ' > + cat >expect <<-\EOF && > + lf > + lf > + EOF > + git ls-files --format="%(eolinfo:index)" >actual && > + test_cmp expect actual > +' > + > +test_expect_success 'git ls-files --format eolinfo:worktree' ' > + cat >expect <<-\EOF && > + lf > + lf > + EOF > + git ls-files --format="%(eolinfo:worktree)" >actual && > + test_cmp expect actual > +' > + > +test_expect_success 'git ls-files --format eolattr' ' > + printf "\n\n" >expect && > + git ls-files --format="%(eolattr)" >actual && > + test_cmp expect actual > +' > +
What exactly should this testcases test ? Does it make sense to set up a combination of index, worktree, attr, which are happening in real live ?
There are some tests in t0025, t0027 and t0028 that do more realistic tests of different combinations.