On Tue, Jul 05, 2022 at 06:32:40AM +0000, ZheNing Hu via GitGitGadget wrote: > From: ZheNing Hu <adlternative@xxxxxxxxx> > > 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 > +----------- > +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 > +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.