Message ID | cover-v5-0.2-00000000000-20220602T131858Z-avarab@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | hook API: connect hooks to the TTY again, fixes a v2.36.0 regression | expand |
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes: > This series fixes a v2.36.0 regression[1]. See [2] for the v4. The > reasons for why a regression needs this relatively large change to > move forward is discussed in past rounds, e.g. around [3]. CI at > https://github.com/avar/git/actions/runs/2428475773 > > Changes since v4, mainly to address comments by Johannes (thanks for > the review!): This version looks good to me. > @@ run-command.c: static void pp_init(struct parallel_processes *pp, > for (i = 0; i < n; i++) { > strbuf_init(&pp->children[i].err, 0); > child_process_init(&pp->children[i].process); > -+ if (!pp->pfd) > -+ continue; > - pp->pfd[i].events = POLLIN | POLLHUP; > - pp->pfd[i].fd = -1; > +- pp->pfd[i].events = POLLIN | POLLHUP; > +- pp->pfd[i].fd = -1; > ++ if (pp->pfd) { > ++ pp->pfd[i].events = POLLIN | POLLHUP; > ++ pp->pfd[i].fd = -1; > ++ } > } This change is merely a personal taste---it does not match mine but that is Meh ;-) > -@@ run-command.c: static void pp_cleanup(struct parallel_processes *pp) > - */ > - static int pp_start_one(struct parallel_processes *pp) > - { > -+ const int ungroup = pp->ungroup; It may have made the resulting code easier to read if the local variable was kept as a synonym as "pp->" is short enough but is repeated often, but what is written is good enough and I do not see a need to flip-flop. > -+static void pp_mark_ungrouped_for_cleanup(struct parallel_processes *pp) > -+{ > -+ int i; > -+ > -+ if (!pp->ungroup) > -+ BUG("only reachable if 'ungrouped'"); > -+ > -+ for (i = 0; i < pp->max_processes; i++) > -+ pp->children[i].state = GIT_CP_WAIT_CLEANUP; > -+} Good to see this inlined. I find the caller easier to follow without it. Thanks for a quick succession of rerolling. Will queue.
Hi Ævar On 02/06/2022 15:07, Ævar Arnfjörð Bjarmason wrote: > This series fixes a v2.36.0 regression[1]. See [2] for the v4. The > reasons for why a regression needs this relatively large change to > move forward is discussed in past rounds, e.g. around [3]. CI at > https://github.com/avar/git/actions/runs/2428475773 > > Changes since v4, mainly to address comments by Johannes (thanks for > the review!): > > * First, some things like renaming "ungroup" to something else & > rewriting the tests I didn't do because I thought keeping the > inter/range-diff down in size outweighed re-arranging or changing > the code at this late stage. > > In the case of the suggested shorter test in > https://lore.kernel.org/git/nycvar.QRO.7.76.6.2206011827300.349@tvgsbejvaqbjf.bet/ > the replacement wasn't testing the same thing. I.e. we don't see > what's connected to a TTY if we redirect one of stdout or stderr > anymore, which is important to get right. I'm a bit confused by this, the proposed test uses this hook script write_script .git/hooks/pre-commit <<-EOF test -t 1 && echo "stdout is a TTY" >out test -t 2 && echo "stderr is a TTY" >>out EOF if either of stderr or stdout is redirected then the corresponding "test -t" should fail and so we will detect that it is not a tty. Best Wishes Phillip
On Fri, Jun 03 2022, Phillip Wood wrote: > Hi Ævar > > On 02/06/2022 15:07, Ævar Arnfjörð Bjarmason wrote: >> This series fixes a v2.36.0 regression[1]. See [2] for the v4. The >> reasons for why a regression needs this relatively large change to >> move forward is discussed in past rounds, e.g. around [3]. CI at >> https://github.com/avar/git/actions/runs/2428475773 >> Changes since v4, mainly to address comments by Johannes (thanks for >> the review!): >> * First, some things like renaming "ungroup" to something else & >> rewriting the tests I didn't do because I thought keeping the >> inter/range-diff down in size outweighed re-arranging or changing >> the code at this late stage. >> In the case of the suggested shorter test in >> https://lore.kernel.org/git/nycvar.QRO.7.76.6.2206011827300.349@tvgsbejvaqbjf.bet/ >> the replacement wasn't testing the same thing. I.e. we don't see >> what's connected to a TTY if we redirect one of stdout or stderr >> anymore, which is important to get right. > > I'm a bit confused by this, the proposed test uses this hook script > > write_script .git/hooks/pre-commit <<-EOF > test -t 1 && echo "stdout is a TTY" >out > test -t 2 && echo "stderr is a TTY" >>out > EOF > > if either of stderr or stdout is redirected then the corresponding > "test -t" should fail and so we will detect that it is not a tty. Yes, exactly, but the proposed test doesn't test that, in that case both of them are connected, the test in 2/2 does test that case. Can that snippet bebe made to work? Sure, but I know the test I have works, and that proposed replacement didn't even pass chainlint (i.e. hasn't been run even once in our test suite). So I didn't think that trying to micro-optimize the test length was worth it in this case. It's also getting much of that length reduction e.g. by not cleaning up after itself, which the test in 2/2 does.
Hi Ævar On 03/06/2022 10:20, Ævar Arnfjörð Bjarmason wrote: > > On Fri, Jun 03 2022, Phillip Wood wrote: > >> Hi Ævar >> >> On 02/06/2022 15:07, Ævar Arnfjörð Bjarmason wrote: >>> This series fixes a v2.36.0 regression[1]. See [2] for the v4. The >>> reasons for why a regression needs this relatively large change to >>> move forward is discussed in past rounds, e.g. around [3]. CI at >>> https://github.com/avar/git/actions/runs/2428475773 >>> Changes since v4, mainly to address comments by Johannes (thanks for >>> the review!): >>> * First, some things like renaming "ungroup" to something else & >>> rewriting the tests I didn't do because I thought keeping the >>> inter/range-diff down in size outweighed re-arranging or changing >>> the code at this late stage. >>> In the case of the suggested shorter test in >>> https://lore.kernel.org/git/nycvar.QRO.7.76.6.2206011827300.349@tvgsbejvaqbjf.bet/ >>> the replacement wasn't testing the same thing. I.e. we don't see >>> what's connected to a TTY if we redirect one of stdout or stderr >>> anymore, which is important to get right. >> >> I'm a bit confused by this, the proposed test uses this hook script >> >> write_script .git/hooks/pre-commit <<-EOF >> test -t 1 && echo "stdout is a TTY" >out >> test -t 2 && echo "stderr is a TTY" >>out >> EOF >> >> if either of stderr or stdout is redirected then the corresponding >> "test -t" should fail and so we will detect that it is not a tty. > > Yes, exactly, but the proposed test doesn't test that, in that case both > of them are connected, the test in 2/2 does test that case. I think I must be missing something. As I understand it we want to check that the hook can see a tty on stdout and stderr. In the test above we'll get a line printed for each fd that is a tty. Your test always redirects one of stdout and stderr - why is it important to test that? - it feels like it is testing the shell's redirection code rather than git. I was concerned that we had also regressed the handling of stdin but looking at (the now deleted) run_hook_ve() it used to set .no_stdin = 1 so that is unchanged in the new code. Best Wishes Phillip > Can that snippet bebe made to work? Sure, but I know the test I have > works, and that proposed replacement didn't even pass chainlint > (i.e. hasn't been run even once in our test suite). So I didn't think > that trying to micro-optimize the test length was worth it in this case. > > It's also getting much of that length reduction e.g. by not cleaning up > after itself, which the test in 2/2 does. >
On Fri, Jun 03 2022, Phillip Wood wrote: > Hi Ævar > > On 03/06/2022 10:20, Ævar Arnfjörð Bjarmason wrote: >> On Fri, Jun 03 2022, Phillip Wood wrote: >> >>> Hi Ævar >>> >>> On 02/06/2022 15:07, Ævar Arnfjörð Bjarmason wrote: >>>> This series fixes a v2.36.0 regression[1]. See [2] for the v4. The >>>> reasons for why a regression needs this relatively large change to >>>> move forward is discussed in past rounds, e.g. around [3]. CI at >>>> https://github.com/avar/git/actions/runs/2428475773 >>>> Changes since v4, mainly to address comments by Johannes (thanks for >>>> the review!): >>>> * First, some things like renaming "ungroup" to something else & >>>> rewriting the tests I didn't do because I thought keeping the >>>> inter/range-diff down in size outweighed re-arranging or changing >>>> the code at this late stage. >>>> In the case of the suggested shorter test in >>>> https://lore.kernel.org/git/nycvar.QRO.7.76.6.2206011827300.349@tvgsbejvaqbjf.bet/ >>>> the replacement wasn't testing the same thing. I.e. we don't see >>>> what's connected to a TTY if we redirect one of stdout or stderr >>>> anymore, which is important to get right. >>> >>> I'm a bit confused by this, the proposed test uses this hook script >>> >>> write_script .git/hooks/pre-commit <<-EOF >>> test -t 1 && echo "stdout is a TTY" >out >>> test -t 2 && echo "stderr is a TTY" >>out >>> EOF >>> >>> if either of stderr or stdout is redirected then the corresponding >>> "test -t" should fail and so we will detect that it is not a tty. >> Yes, exactly, but the proposed test doesn't test that, in that case >> both >> of them are connected, the test in 2/2 does test that case. > > I think I must be missing something. As I understand it we want to > check that the hook can see a tty on stdout and stderr. In the test > above we'll get a line printed for each fd that is a tty. Your test > always redirects one of stdout and stderr - why is it important to > test that? - it feels like it is testing the shell's redirection code > rather than git. Yes, I think I'm the one who was missing something. I looked at this again and I thought I'd been testing that e.g. one of the two not returning true from isatty() wasn't making both "not TTY", i.e. that run-command.c wasn't performing some shenanigans. But that was probably too paranoid, and in any case I couldn't find a good way to test it. > I was concerned that we had also regressed the handling of stdin but > looking at (the now deleted) run_hook_ve() it used to set .no_stdin = > 1 so that is unchanged in the new code. *nod* I re-rolled a v6 just now which I think should address your comments here: https://lore.kernel.org/git/cover-v6-0.2-00000000000-20220606T170356Z-avarab@gmail.com/ I've still kept the "clean up after yourself" etc. behavior in the test, and since it was easy we now test both "git hook run" and "git commit". Thanks a lot for the careful review.