git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] bisect--helper: use BISECT_TERMS in 'bisect skip' command
@ 2021-04-25  0:18 Ramsay Jones
  2021-04-25  8:16 ` Bagas Sanjaya
  0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2021-04-25  0:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GIT Mailing-list, Bagas Sanjaya, Trygve Aaberge


Commit e4c7b33747 ("bisect--helper: reimplement `bisect_skip` shell
function in C", 2021-02-03), as part of the shell-to-C conversion,
forgot to read the 'terms' file (.git/BISECT_TERMS) during the new
'bisect skip' command implementation. As a result, the 'bisect skip'
command will use the default 'bad'/'good' terms. If the bisection
terms have been set to non-default values (for example by the
'bisect start' command), then the 'bisect skip' command will fail.

In order to correct this problem, we insert a call to the get_terms()
function, which reads the non-default terms from that file (if set),
in the '--bisect-skip' command implementation of 'bisect--helper'.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---

Hi Junio,

This patch was created directly on top of commit e4c7b33747 and tested
with the test from Bagas Sanjaya [1] (ie the second version of the
stand-alone test file t6031-*.sh, rather than the newer patch that
adds the test to t6030-*.sh). I applied this patch to the current
master branch (@311531c9de55) and it also passed the test in [1].

[I created the patch on top of e4c7b33747 so that it would, hopefully,
easily backport to the relevant 'maint' branches, should you feel the
need. ;-) ]

At this point, I would normally have looked to see if there were other
examples of forgetting to call 'get_terms()' (which seems possible).
However, I am a bit busy, so I will have to add that to my TODO list ...
:(

ATB,
Ramsay Jones

[1] https://lore.kernel.org/git/20210421040808.14185-1-bagasdotme@gmail.com/

 builtin/bisect--helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 7ad9b4d55b..49c07f0710 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -1129,6 +1129,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 		break;
 	case BISECT_SKIP:
 		set_terms(&terms, "bad", "good");
+		get_terms(&terms);
 		res = bisect_skip(&terms, argv, argc);
 		break;
 	default:
-- 
2.31.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] bisect--helper: use BISECT_TERMS in 'bisect skip' command
  2021-04-25  0:18 [PATCH] bisect--helper: use BISECT_TERMS in 'bisect skip' command Ramsay Jones
@ 2021-04-25  8:16 ` Bagas Sanjaya
  2021-04-26  7:06   ` Christian Couder
  0 siblings, 1 reply; 4+ messages in thread
From: Bagas Sanjaya @ 2021-04-25  8:16 UTC (permalink / raw)
  To: Ramsay Jones, Junio C Hamano; +Cc: GIT Mailing-list, Trygve Aaberge

On 25/04/21 07.18, Ramsay Jones wrote:
> 
> This patch was created directly on top of commit e4c7b33747 and tested
> with the test from Bagas Sanjaya [1] (ie the second version of the
> stand-alone test file t6031-*.sh, rather than the newer patch that
> adds the test to t6030-*.sh). I applied this patch to the current
> master branch (@311531c9de55) and it also passed the test in [1].

I have just sent v2 of t6030 version of my test [1]. Please test
this patch against that v2 test. And if the test passes (breakage vanished),
please update the test by do instructions in the FIXME comment lines of [1].

> @@ -1129,6 +1129,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>   		break;
>   	case BISECT_SKIP:
>   		set_terms(&terms, "bad", "good");
> +		get_terms(&terms);

I'm not fluent in C, but I read these lines above as "ok, we set terms from
&terms, bad and good as fallback in case the reference is empty; then we get these
terms from the reference". Wouldn't it makes sense if we can say "get the terms
from &terms" first, then "set the terms from the reference, if empty use bad
and good as fallback"?

[1]: https://lore.kernel.org/git/20210425080508.154159-1-bagasdotme@gmail.com/
-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bisect--helper: use BISECT_TERMS in 'bisect skip' command
  2021-04-25  8:16 ` Bagas Sanjaya
@ 2021-04-26  7:06   ` Christian Couder
  2021-04-28  4:09     ` Bagas Sanjaya
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Couder @ 2021-04-26  7:06 UTC (permalink / raw)
  To: Bagas Sanjaya, Ramsay Jones
  Cc: Junio C Hamano, GIT Mailing-list, Trygve Aaberge

On Sun, Apr 25, 2021 at 10:18 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote:
>
> On 25/04/21 07.18, Ramsay Jones wrote:
> >
> > This patch was created directly on top of commit e4c7b33747 and tested
> > with the test from Bagas Sanjaya [1] (ie the second version of the
> > stand-alone test file t6031-*.sh, rather than the newer patch that
> > adds the test to t6030-*.sh). I applied this patch to the current
> > master branch (@311531c9de55) and it also passed the test in [1].

Thanks Ramsay for your patch, it looks good to me!

> I have just sent v2 of t6030 version of my test [1]. Please test
> this patch against that v2 test. And if the test passes (breakage vanished),
> please update the test by do instructions in the FIXME comment lines of [1].

Thanks Bagas for your test! I will take a look at it soon.

My opinion is that it would be best if both patches (Ramsay's and
Bagas') were in the same patch series or even perhaps in the same
commit. If you prefer separate patches, maybe the first one could be
Ramsay's, and the second one Bagas' where indeed the instructions to
replace test_expect_failure with test_expect_success have been
followed.

> > @@ -1129,6 +1129,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >               break;
> >       case BISECT_SKIP:
> >               set_terms(&terms, "bad", "good");
> > +             get_terms(&terms);
>
> I'm not fluent in C, but I read these lines above as "ok, we set terms from
> &terms, bad and good as fallback in case the reference is empty; then we get these
> terms from the reference". Wouldn't it makes sense if we can say "get the terms
> from &terms" first, then "set the terms from the reference, if empty use bad
> and good as fallback"?

It might not be the best API for this (or the set_terms() and
get_terms() function could perhaps have better names), but anyway the
current situation is that set_terms(&terms, "bad", "good") is setting
the current terms to "bad"/"good" which is the default, and then
get_terms(&terms) is reading the terms stored in the BISECT_TERMS file
and using that to set the current terms. Also if the BISECT_TERMS file
doesn't exist, then get_terms(&terms) is doing nothing. So it seems to
me that Ramsay's patch is doing the right thing.

If get_terms(&terms) was used before set_terms(&terms, "bad", "good"),
then the current terms would always be "bad"/"good" even if the
BISECT_TERMS file contains valid terms different from "bad"/"good".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bisect--helper: use BISECT_TERMS in 'bisect skip' command
  2021-04-26  7:06   ` Christian Couder
@ 2021-04-28  4:09     ` Bagas Sanjaya
  0 siblings, 0 replies; 4+ messages in thread
From: Bagas Sanjaya @ 2021-04-28  4:09 UTC (permalink / raw)
  To: Christian Couder, Ramsay Jones
  Cc: Junio C Hamano, GIT Mailing-list, Trygve Aaberge

On 26/04/21 14.06, Christian Couder wrote:
> Thanks Bagas for your test! I will take a look at it soon.
> 
> My opinion is that it would be best if both patches (Ramsay's and
> Bagas') were in the same patch series or even perhaps in the same
> commit. If you prefer separate patches, maybe the first one could be
> Ramsay's, and the second one Bagas' where indeed the instructions to
> replace test_expect_failure with test_expect_success have been
> followed.
> 

OK. Review ping

> It might not be the best API for this (or the set_terms() and
> get_terms() function could perhaps have better names), but anyway the
> current situation is that set_terms(&terms, "bad", "good") is setting
> the current terms to "bad"/"good" which is the default, and then
> get_terms(&terms) is reading the terms stored in the BISECT_TERMS file
> and using that to set the current terms. Also if the BISECT_TERMS file
> doesn't exist, then get_terms(&terms) is doing nothing. So it seems to
> me that Ramsay's patch is doing the right thing.
> 
> If get_terms(&terms) was used before set_terms(&terms, "bad", "good"),
> then the current terms would always be "bad"/"good" even if the
> BISECT_TERMS file contains valid terms different from "bad"/"good".
> 

OK, thanks for the explanation.

-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-28  4:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-25  0:18 [PATCH] bisect--helper: use BISECT_TERMS in 'bisect skip' command Ramsay Jones
2021-04-25  8:16 ` Bagas Sanjaya
2021-04-26  7:06   ` Christian Couder
2021-04-28  4:09     ` Bagas Sanjaya

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).