From: 胡哲宁 <adlternative@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>,
Git List <git@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] builtin:ls-files.c:add git ls-file --dedup option
Date: Thu, 14 Jan 2021 16:17:21 +0800 [thread overview]
Message-ID: <CAOLTT8SPMA5hNF2GrbjWzQusjq1tCz1SC2842ApcYAVE9tYHew@mail.gmail.com> (raw)
In-Reply-To: <CAPig+cT+1XZbg3Nv15Hfsmc0qLTku0iMvp0dOjuebv_55D1OSQ@mail.gmail.com>
You can see that the coding and documentation of GIT community are really very
standard, which may be one of the things I lack and need to improve ;)
Thanks for patiently correct my errors.
Eric Sunshine <sunshine@sunshineco.com> 于2021年1月14日周四 下午2:39写道:
>
> On Fri, Jan 8, 2021 at 9:36 AM ZheNing Hu via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > builtin:ls-files.c:add git ls-file --dedup option
>
> This subject concisely explains the purpose of the patch. That's good.
> A more typical way to write it would be:
>
> ls-files: add --dedup option
>
OK.I will correct it more specification.
> > This commit standardizes the code format.
>
> Fixing problems pointed out by reviewers is good. Normally, however,
> when you submit a new version of your patch or patch series, you
> should apply these fixes directly to the patch(es) which introduced
> the problems in the first place rather than adding one or more
> additional patches to fix problems introduced in earlier patches. To
> do this, you typically would use `git rebase -i` or `git commit
> --amend` to squash the fixes into the problematic patches. Thus, when
> you re-submit the patches, they will appear to be "perfect".
>
> For this particular two-patch series, patch [2/2] is doing two things:
> (1) fixing style problems from patch [1/2], and (2) adding
> documentation and tests which logically belong with the feature added
> by patch [1/2]. Taking the above advice into account, a better
> presentation when you re-submit this series would be to squash these
> two patches into a single patch.
>
I thought before this was gitgitgadget would sent duplicate patch
over and over again. It seems like I really should go straight ahead
and squash my commits , so I know what I should do.
> > Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> > ---
> > diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
> > @@ -81,6 +82,9 @@ OPTIONS
> > +--dedup::
> > + Suppress duplicates entries when conflicts happen or
> > + specify -d -m at the same time.
>
> For consistency with typesetting elsewhere in this file, use backticks
> around the command-line options. It also often is a good idea to spell
> the options using long form since it is typically easier to search for
> the long form of an option in documentation. So, perhaps the above can
> be written like this:
>
> Suppress duplicate entries when `--deleted` and `--modified` are
> combined.
>
> > diff --git a/builtin/ls-files.c b/builtin/ls-files.c
> > - const struct cache_entry *last_stage=NULL;
> > + const struct cache_entry *last_stage = NULL;
> > - if(show_cached && delete_dup){
> > + if (show_cached && delete_dup) {
> > - last_stage=ce;
> > + last_stage = ce;
> > - if(delete_dup){
> > + if (delete_dup) {
> > - if(delete_dup && show_deleted && show_modified && err)
> > + if (delete_dup && show_deleted && show_modified && err)
> > - else{
> > - if (show_deleted && err)/* you can't find it,so it's actually removed at all! */
> > + else {
> > + if (show_deleted && err)
>
> As mentioned above, these style fixes should be squashed into the
> first patch, rather than being done in a separate patch, so that
> reviewers see a nicely polished patch rather than a patch which
> requires later fixing up.
>
> > diff --git a/t/t3012-ls-files-dedup.sh b/t/t3012-ls-files-dedup.sh
> > @@ -0,0 +1,63 @@
> > +test_expect_success 'master branch setup and write expect1 expect2 and commit' '
>
> We usually give this test a simple title such as "setup" so that we
> don't have to worry about the title becoming outdated as people make
> changes to the test itself.
>
> > + touch a.txt &&
> > + touch b.txt &&
> > + touch delete.txt &&
>
> On this project, we use `touch` when the timestamp of the empty files
> is important to the test. If the timestamp is not important, then we
> just use `>`, like this:
>
> >a.txt &&
> >b.txt &&
> >delete.txt &&
>
OK,maybe because I always use touch to generate files.
> > + cat <<-EOF >expect1 &&
> > + M a.txt
> > + H b.txt
> > + H delete.txt
> > + H expect1
> > + H expect2
> > + EOF
> > + cat <<-EOF >expect2 &&
> > + C a.txt
> > + R delete.txt
> > + EOF
>
> When no variables are being interpolated in the here-doc content, we
> use -\EOF to let readers know that the here-doc body is literal. So:
>
> cat >expect1 <<-\EOF &&
> ...
> EOF
>
> > + git add a.txt b.txt delete.txt expect1 expect2 &&
> > + git commit -m master:1
> > +'
> > +
> > +test_expect_success 'main commit again' '
> > + 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
> > +'
> > +
> > +test_expect_success 'dev commit' '
> > + git checkout HEAD~ &&
> > + git switch -c dev &&
> > + echo change>a.txt &&
> > + git add a.txt &&
> > + git commit -m dev:1
> > +'
>
> These two tests following the "setup" test also seem to be doing setup
> tasks rather than testing the new --dedup functionality. If this is
> the case, then it probably would make sense to combine all three tests
> into a single "setup" test.
>
> > +test_expect_success 'dev merge master' '
> > + test_must_fail git merge master &&
> > + git ls-files -t --dedup >actual1 &&
> > + test_cmp expect1 actual1 &&
> > + rm delete.txt &&
> > + git ls-files -d -m -t --dedup >actual2 &&
> > + test_cmp expect2 actual2
> > +'
>
> Do you foresee that people will add more tests to this file which will
> use the files and branches set up by the "setup" test(s)? If not, if
> those branches and files are only ever going to be used by this one
> test, then it probably would be better to combine all the above code
> into a single test.
No,the test file may just need only one.
next prev parent reply other threads:[~2021-01-14 8:16 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 8:53 [PATCH] builtin/ls-files.c:add git ls-file --dedup option 阿德烈 via GitGitGadget
2021-01-07 6:10 ` Eric Sunshine
2021-01-07 6:40 ` Junio C Hamano
2021-01-08 14:36 ` [PATCH v2 0/2] " 阿德烈 via GitGitGadget
2021-01-08 14:36 ` [PATCH v2 1/2] " ZheNing Hu via GitGitGadget
2021-01-08 14:36 ` [PATCH v2 2/2] builtin:ls-files.c:add " ZheNing Hu via GitGitGadget
2021-01-14 6:38 ` Eric Sunshine
2021-01-14 8:17 ` 胡哲宁 [this message]
2021-01-14 12:22 ` [PATCH v3] ls-files.c: add " 阿德烈 via GitGitGadget
2021-01-15 0:59 ` Junio C Hamano
2021-01-17 3:45 ` 胡哲宁
2021-01-17 4:37 ` Junio C Hamano
2021-01-16 7:13 ` Eric Sunshine
2021-01-17 3:49 ` 胡哲宁
2021-01-17 5:11 ` Eric Sunshine
2021-01-17 23:04 ` Junio C Hamano
2021-01-18 14:59 ` Eric Sunshine
2021-01-17 4:02 ` [PATCH v4 0/3] builtin/ls-files.c:add git ls-file " 阿德烈 via GitGitGadget
2021-01-17 4:02 ` [PATCH v4 1/3] ls_files.c: bugfix for --deleted and --modified ZheNing Hu via GitGitGadget
2021-01-17 6:22 ` Junio C Hamano
2021-01-17 4:02 ` [PATCH v4 2/3] ls_files.c: consolidate two for loops into one ZheNing Hu via GitGitGadget
2021-01-17 4:02 ` [PATCH v4 3/3] ls-files: add --deduplicate option ZheNing Hu via GitGitGadget
2021-01-17 6:25 ` Junio C Hamano
2021-01-17 23:34 ` Junio C Hamano
2021-01-18 4:09 ` 胡哲宁
2021-01-18 6:05 ` 胡哲宁
2021-01-18 21:31 ` Junio C Hamano
2021-01-19 2:56 ` 胡哲宁
2021-01-19 6:30 ` [PATCH v5 0/3] builtin/ls-files.c:add git ls-file --dedup option 阿德烈 via GitGitGadget
2021-01-19 6:30 ` [PATCH v5 1/3] ls_files.c: bugfix for --deleted and --modified ZheNing Hu via GitGitGadget
2021-01-20 20:26 ` Junio C Hamano
2021-01-21 10:02 ` 胡哲宁
2021-01-19 6:30 ` [PATCH v5 2/3] ls_files.c: consolidate two for loops into one ZheNing Hu via GitGitGadget
2021-01-20 20:27 ` Junio C Hamano
2021-01-21 11:05 ` 胡哲宁
2021-01-19 6:30 ` [PATCH v5 3/3] ls-files.c: add --deduplicate option ZheNing Hu via GitGitGadget
2021-01-20 21:26 ` Junio C Hamano
2021-01-21 11:00 ` 胡哲宁
2021-01-21 20:45 ` Junio C Hamano
2021-01-22 9:50 ` 胡哲宁
2021-01-22 16:04 ` Johannes Schindelin
2021-01-22 18:02 ` Junio C Hamano
2021-03-19 13:54 ` GitGitGadget and `next`, was " Johannes Schindelin
2021-03-19 18:11 ` Junio C Hamano
2021-01-23 8:20 ` 胡哲宁
2021-01-22 15:46 ` [PATCH v6] " ZheNing Hu
2021-01-22 20:52 ` Junio C Hamano
2021-01-23 8:27 ` 胡哲宁
2021-01-23 10:20 ` [PATCH v6 0/3] builtin/ls-files.c:add git ls-file --dedup option 阿德烈 via GitGitGadget
2021-01-23 10:20 ` [PATCH v6 1/3] ls_files.c: bugfix for --deleted and --modified ZheNing Hu via GitGitGadget
2021-01-23 17:55 ` Junio C Hamano
2021-01-23 10:20 ` [PATCH v6 2/3] ls_files.c: consolidate two for loops into one ZheNing Hu via GitGitGadget
2021-01-23 19:50 ` Junio C Hamano
2021-01-23 10:20 ` [PATCH v6 3/3] ls-files.c: add --deduplicate option ZheNing Hu via GitGitGadget
2021-01-23 19:51 ` Junio C Hamano
2021-01-23 19:53 ` [PATCH v7 1/3] ls_files.c: bugfix for --deleted and --modified Junio C Hamano
2021-01-23 19:53 ` [PATCH v7 2/3] ls_files.c: consolidate two for loops into one Junio C Hamano
2021-01-23 19:53 ` [PATCH v7 3/3] ls-files.c: add --deduplicate option Junio C Hamano
2021-01-24 10:54 ` [PATCH v7 0/3] builtin/ls-files.c:add git ls-file --dedup option 阿德烈 via GitGitGadget
2021-01-24 10:54 ` [PATCH v7 1/3] ls_files.c: bugfix for --deleted and --modified ZheNing Hu via GitGitGadget
2021-01-24 22:04 ` Junio C Hamano
2021-01-25 6:05 ` 胡哲宁
2021-01-25 19:05 ` Junio C Hamano
2021-01-24 10:54 ` [PATCH v7 2/3] ls_files.c: consolidate two for loops into one ZheNing Hu via GitGitGadget
2021-01-24 10:54 ` [PATCH v7 3/3] ls-files.c: add --deduplicate option ZheNing Hu via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOLTT8SPMA5hNF2GrbjWzQusjq1tCz1SC2842ApcYAVE9tYHew@mail.gmail.com \
--to=adlternative@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).