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

Re: [PATCH v4 3/3] ls-files: add --deduplicate option

From
胡哲宁 <adlternative@gmail.com>
Date
Jan 18, 2021, 06:05 UTC
Message-ID
<CAOLTT8QnhNqnJCgiqOZnd9cjxicAuk2Js1GKdHEJD_XK15UU+Q@mail.gmail.com>
In-Reply-To
<CAOLTT8Syp2ZeTXW-m+e=dn2W773nScB_kwZLS3MjLTcFQ_bctw@mail.gmail.com>

Hi,Junio! Here I am thinking about the role of this "--deduplicate" is to suppress duplicate filenames rather than duplicate entries. Do you think I should modify this sentence?

> > OPT_BOOL(0,"deduplicate",&skipping_duplicates,N_("suppress duplicate entries")),
胡哲宁 <adlternative@gmail.com> 于2021年1月18日周一 下午12:09写道:
Show 148 quoted lines
>
> Junio C Hamano <gitster@pobox.com> 于2021年1月18日周一 上午7:34写道:
> >
> > "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
> >
> > > diff --git a/t/t3012-ls-files-dedup.sh b/t/t3012-ls-files-dedup.sh
> > > new file mode 100755
> > > index 00000000000..75877255c2c
> > > --- /dev/null
> > > +++ b/t/t3012-ls-files-dedup.sh
> > > @@ -0,0 +1,57 @@
> > > +#!/bin/sh
> > > +
> > > +test_description='git ls-files --deduplicate test'
> > > +
> > > +. ./test-lib.sh
> >
> > We should already have a ls-files test so that we can add a handful
> > new tests to it, instead of dedicating a whole new test script.
> >
> Fine,It might be easier for me to write a test file myself for the time being.
> But I will learn slowly.
> > Also, don't do everything in a single 'setup'.  There are various
> > scenarios you want to make sure ls-files to work (grep for ls-files
> > in the following you added---I count 4 of them), and when a future
> > developer touches the code, he or she may break one but not other
> > three.  The purpose you write tests is to protect your new feature
> > from such a developer *AND* help such a developer to debug and fix
> > his or her changes.  For that, it would be a lot more sensible to
> > have one set-up that is common, and then four separate tests.
> >
> > > +test_expect_success 'setup' '
> > > +     >a.txt &&
> > > +     >b.txt &&
> > > +     >delete.txt &&
> > > +     git add a.txt b.txt delete.txt &&
> > > +     git commit -m master:1 &&
> >
> > Needless use of the word "master".  Observe what is going on in the
> > project around you and avoid stepping other peoples' toes.  One of
> > the ongoing effort is to grep for the phrase master in t/ directory
> > and examine what happens when the default initial branch name
> > becomes something other than 'master', so adding a needless hit like
> > this is most unwelcome.
> >
> Well, I will try my best to use less "master".
> > > +     echo a >a.txt &&
> > > +     echo b >b.txt &&
> > > +     echo delete >delete.txt &&
> > > +     git add a.txt b.txt delete.txt &&
> > > +     git commit -m master:2 &&
> >
> > > +     git checkout HEAD~ &&
> > > +     git switch -c dev &&
> >
> > Needless mixture of checkout/switch.  If you switch branches using
> > "git checkout", for example, consistently do so, i.e.
> >
> >         git checkout -b dev HEAD~1
> >
> > It's not like these new tests are to test checkout and switch; your
> > mission is to protect "ls-files --dedup" feature here.
> >
> > > +     test_when_finished "git switch master" &&
> > > +     echo change >a.txt &&
> > > +     git add a.txt &&
> > > +     git commit -m dev:1 &&
> >
> > I'd consider all of the above to be 'setup' that is common for
> > subsequent tests.  It may make sense to actually do everything
> > on the initial branch, i.e. after creating two commits, do
> >
> I understand it now...setup is for serve as a basis for other tests.
> >         git tag tip &&
> >         git reset --hard HEAD^ &&
> >         echo change >a.txt &&
> >         git commit -a -m side &&
> >         git tag side
> >
> > You are always on the initial branch without ever switching, so
> > there is no need for the when_finished stuff.
> >
> > Then the first of your test is to show the index with conflicts.
> >
> > > +     test_must_fail git merge master &&
> >
> > This will become "git merge tip" instead of 'master'.
> >
> use tag instead of use branch name...
> > > +     git ls-files --deduplicate >actual &&
> > > +     cat >expect <<-\EOF &&
> > > +     a.txt
> > > +     b.txt
> > > +     delete.txt
> > > +     EOF
> > > +     test_cmp expect actual &&
> >
> > And up to this point is the first test after 'setup'.
> >
> > The next test should begin with:
> >
> >         git reset --hard side &&
> >         test_must_fail git merge tip &&
> >
> > so that even when the first test is skipped, or left unmerged,
> > you'll begin with a known state.
> >
> Well,I understand now that the a test_success should allow other
> programmers to skip this test,so that we should reset to a known
> state at the beginning of each test.
> > > +     rm delete.txt &&
> > > +     git ls-files -d -m --deduplicate >actual &&
> > > +     cat >expect <<-\EOF &&
> > > +     a.txt
> > > +     delete.txt
> > > +     EOF
> > > +     test_cmp expect actual &&
> > > +     git ls-files -d -m -t  --deduplicate >actual &&
> > > +     cat >expect <<-\EOF &&
> > > +     C a.txt
> > > +     C a.txt
> > > +     C a.txt
> > > +     R delete.txt
> > > +     C delete.txt
> > > +     EOF
> > > +     test_cmp expect actual &&
> > > +     git ls-files -d -m -c  --deduplicate >actual &&
> > > +     cat >expect <<-\EOF &&
> > > +     a.txt
> > > +     b.txt
> > > +     delete.txt
> > > +     EOF
> > > +     test_cmp expect actual &&
> >
> > These three can be kept in the same test_expect_success, as they are
> > exercising read-only operation on the same state but with different
> > display options.
> >
> indeed so.
> > But in this case, the preparation is not too tedious (just a failed
> > merge plus a deletion), so you probably would prefer to split it
> > into 3 independent tests---that may make it more helpful to future
> > developers.
> >
> Thanks:)
> > > +     git merge --abort
> > > +'
> > > +test_done
Previous: 胡哲宁Next: Junio C Hamano
Message 26 of 65 in “builtin/ls-files.c:add git ls-file --dedup option”
  1. builtin/ls-files.c:add git ls-file --dedup option阿德烈 via GitGitGadget, Jan 6, 2021
  2. Eric SunshineJan 7, 2021
  3. Junio C HamanoJan 7, 2021
  4. 0/2 builtin/ls-files.c:add git ls-file --dedup option阿德烈 via GitGitGadget, Jan 8, 2021
  5. 1/2 builtin/ls-files.c:add git ls-file --dedup optionZheNing Hu via GitGitGadget, Jan 8, 2021
  6. 2/2 builtin:ls-files.c:add git ls-file --dedup optionZheNing Hu via GitGitGadget, Jan 8, 2021
  7. Eric SunshineJan 14, 2021
  8. 胡哲宁Jan 14, 2021
  9. ls-files.c: add --dedup option阿德烈 via GitGitGadget, Jan 14, 2021
  10. Junio C HamanoJan 15, 2021
  11. 胡哲宁Jan 17, 2021
  12. Junio C HamanoJan 17, 2021
  13. Eric SunshineJan 16, 2021
  14. 胡哲宁Jan 17, 2021
  15. Eric SunshineJan 17, 2021
  16. Junio C HamanoJan 17, 2021
  17. Eric SunshineJan 18, 2021
  18. 0/3 builtin/ls-files.c:add git ls-file --dedup option阿德烈 via GitGitGadget, Jan 17, 2021
  19. 1/3 ls_files.c: bugfix for --deleted and --modifiedZheNing Hu via GitGitGadget, Jan 17, 2021
  20. Junio C HamanoJan 17, 2021
  21. 2/3 ls_files.c: consolidate two for loops into oneZheNing Hu via GitGitGadget, Jan 17, 2021
  22. 3/3 ls-files: add --deduplicate optionZheNing Hu via GitGitGadget, Jan 17, 2021
  23. Junio C HamanoJan 17, 2021
  24. Junio C HamanoJan 17, 2021
  25. 胡哲宁Jan 18, 2021
  26. 胡哲宁Jan 18, 2021
  27. Junio C HamanoJan 18, 2021
  28. 胡哲宁Jan 19, 2021
  29. 0/3 builtin/ls-files.c:add git ls-file --dedup option阿德烈 via GitGitGadget, Jan 19, 2021
  30. 3/3 ls-files.c: add --deduplicate optionZheNing Hu via GitGitGadget, Jan 19, 2021
  31. Junio C HamanoJan 20, 2021
  32. 胡哲宁Jan 21, 2021
  33. Junio C HamanoJan 21, 2021
  34. 胡哲宁Jan 22, 2021
  35. Johannes SchindelinJan 22, 2021
  36. Junio C HamanoJan 22, 2021
  37. GitGitGadget and `next`, was Re: [PATCH v5 3/3] ls-files.c: add --deduplicate optionJohannes Schindelin, Mar 19, 2021
  38. Junio C HamanoMar 19, 2021
  39. 胡哲宁Jan 23, 2021
  40. ls-files.c: add --deduplicate optionZheNing Hu, Jan 22, 2021
  41. Junio C HamanoJan 22, 2021
  42. 胡哲宁Jan 23, 2021
  43. 2/3 ls_files.c: consolidate two for loops into oneZheNing Hu via GitGitGadget, Jan 19, 2021
  44. Junio C HamanoJan 20, 2021
  45. 胡哲宁Jan 21, 2021
  46. 1/3 ls_files.c: bugfix for --deleted and --modifiedZheNing Hu via GitGitGadget, Jan 19, 2021
  47. Junio C HamanoJan 20, 2021
  48. 胡哲宁Jan 21, 2021
  49. 0/3 builtin/ls-files.c:add git ls-file --dedup option阿德烈 via GitGitGadget, Jan 23, 2021
  50. 1/3 ls_files.c: bugfix for --deleted and --modifiedZheNing Hu via GitGitGadget, Jan 23, 2021
  51. Junio C HamanoJan 23, 2021
  52. 2/3 ls_files.c: consolidate two for loops into oneZheNing Hu via GitGitGadget, Jan 23, 2021
  53. Junio C HamanoJan 23, 2021
  54. 3/3 ls-files.c: add --deduplicate optionZheNing Hu via GitGitGadget, Jan 23, 2021
  55. Junio C HamanoJan 23, 2021
  56. 1/3 ls_files.c: bugfix for --deleted and --modifiedJunio C Hamano, Jan 23, 2021
  57. 2/3 ls_files.c: consolidate two for loops into oneJunio C Hamano, Jan 23, 2021
  58. 3/3 ls-files.c: add --deduplicate optionJunio C Hamano, Jan 23, 2021
  59. 0/3 builtin/ls-files.c:add git ls-file --dedup option阿德烈 via GitGitGadget, Jan 24, 2021
  60. 1/3 ls_files.c: bugfix for --deleted and --modifiedZheNing Hu via GitGitGadget, Jan 24, 2021
  61. Junio C HamanoJan 24, 2021
  62. 胡哲宁Jan 25, 2021
  63. Junio C HamanoJan 25, 2021
  64. 2/3 ls_files.c: consolidate two for loops into oneZheNing Hu via GitGitGadget, Jan 24, 2021
  65. 3/3 ls-files.c: add --deduplicate optionZheNing Hu via GitGitGadget, Jan 24, 2021

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.