Skip to contentSkip to conversation

sequencer: fix gpg option passed to merge subcommand

PATCH Superseded Samuel Čavoj 3 participants 18 messages Oct 12, 2020 – Oct 16, 2020

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 sequencer: fix gpg option passed to merge subcommand

From: Johannes Schindelin <[email protected]>

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit. Instead of "-S%s" with the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
 sequencer.c                | 2 +-
 t/t3435-rebase-gpg-sign.sh | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
 		strvec_push(&cmd.args, "-F");
 		strvec_push(&cmd.args, git_path_merge_msg(r));
 		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
 
 		/* Add the tips to be merged */
 		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +6 -0
index b47c59c190..f70b280f5c 100755
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
 	test_must_fail git verify-commit HEAD
 '
 
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'
+
 test_done
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 2/2 sequencer: pass explicit --no-gpg-sign to merge

The merge subcommand launched for merges with non-default strategy would use its own default behaviour to decide how to sign commits, regardless of what opts->gpg_sign was set to. For example the --no-gpg-sign flag given to rebase explicitly would get ignored, if commit.gpgsign was set to true.

---
 sequencer.c | 2 ++
 1 file changed, 2 insertions(+)
sequencer.c +2 -0
index 88ccff4838..043d606829 100644
@@ -3678,6 +3678,8 @@ static int do_merge(struct repository *r,
 		strvec_push(&cmd.args, git_path_merge_msg(r));
 		if (opts->gpg_sign)
 			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
+		else
+			strvec_push(&cmd.args, "--no-gpg-sign");
 
 		/* Add the tips to be merged */
 		for (j = to_merge; j; j = j->next)
Signature · 1 line
2.28.0
#2 lore raw

Re: [PATCH v2 2/2] sequencer: pass explicit --no-gpg-sign to merge

Quoted 16 lines · Samuel Čavoj

The merge subcommand launched for merges with non-default strategy would use its own default behaviour to decide how to sign commits, regardless of what opts->gpg_sign was set to. For example the --no-gpg-sign flag given to rebase explicitly would get ignored, if commit.gpgsign was set to true.

---
 sequencer.c | 2 ++
 1 file changed, 2 insertions(+)
sequencer.c +0 -0
index 88ccff4838..043d606829 100644

sequencer.c static int do_merge(struct repository *r, · line 3685

Quoted 8 lines
sequencer.c +2 -0
@@ -3678,6 +3678,8 @@ static int do_merge(struct repository *r,
 		strvec_push(&cmd.args, git_path_merge_msg(r));
 		if (opts->gpg_sign)
 			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
+		else
+			strvec_push(&cmd.args, "--no-gpg-sign");
 
 		/* Add the tips to be merged */
 		for (j = to_merge; j; j = j->next)

A test that passes --no-gpg-sign from the command line (because commit.gpgsign is set in the repository used in these tests) would be a good thing to have, next to the test you added in [PATCH 1/2]. You'd want to make sure the command line overrides the configured default by checking that the resulting history are not signed.

Thanks.

#3 lore raw

Re: [PATCH v2 2/2] sequencer: pass explicit --no-gpg-sign to merge

In reply to Samuel Čavoj

Hi Samuel

Quoted 5 lines · Samuel Čavoj

The merge subcommand launched for merges with non-default strategy would use its own default behaviour to decide how to sign commits, regardless of what opts->gpg_sign was set to. For example the --no-gpg-sign flag given to rebase explicitly would get ignored, if commit.gpgsign was set to true.

That's a good explanation, thanks very much for adding this patch

Phillip

Quoted 20 lines
---
  sequencer.c | 2 ++
  1 file changed, 2 insertions(+)
sequencer.c +2 -0
index 88ccff4838..043d606829 100644
@@ -3678,6 +3678,8 @@ static int do_merge(struct repository *r,
  		strvec_push(&cmd.args, git_path_merge_msg(r));
  		if (opts->gpg_sign)
  			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
+		else
+			strvec_push(&cmd.args, "--no-gpg-sign");
 
  		/* Add the tips to be merged */
  		for (j = to_merge; j; j = j->next)
#4 lore raw
In reply to Samuel Čavoj
Quoted 1 line · Samuel Čavoj

From: Johannes Schindelin <[email protected]>

Oh boy, I left in a line by accident. Please remove this before applying, unless a v3 comes around. Sorry about that.

Quoted 50 lines

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit. Instead of "-S%s" with the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
 sequencer.c                | 2 +-
 t/t3435-rebase-gpg-sign.sh | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
 		strvec_push(&cmd.args, "-F");
 		strvec_push(&cmd.args, git_path_merge_msg(r));
 		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
 
 		/* Add the tips to be merged */
 		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +6 -0
index b47c59c190..f70b280f5c 100755
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
 	test_must_fail git verify-commit HEAD
 '
 
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'
+
 test_done
Signature · 1 line
2.28.0
#5 lore raw
In reply to Samuel Čavoj

Hi Samuel

Thanks for re-rolling this

Quoted 6 lines · Samuel Čavoj

From: Johannes Schindelin <[email protected]>

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit.

Small nit-pick: I think it worked fine with if commit.gpgsign was set and the user did not pass -S or --no-gpg-sign because merge would sign the commits as commit.gpgsign was set, it was only if the user passed a gpg signing option to rebase that we had problems. I'm not sure it's worth a re-roll just for that though

Best Wishes

Phillip

Quoted 44 lines

Instead of "-S%s" with
the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
  sequencer.c                | 2 +-
  t/t3435-rebase-gpg-sign.sh | 6 ++++++
  2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
  		strvec_push(&cmd.args, "-F");
  		strvec_push(&cmd.args, git_path_merge_msg(r));
  		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
 
  		/* Add the tips to be merged */
  		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +6 -0
index b47c59c190..f70b280f5c 100755
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
  	test_must_fail git verify-commit HEAD
  '
 
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'
+
  test_done
#6 lore raw

Hi Phillip,

Quoted 12 lines · Phillip Wood

Hi Samuel

Thanks for re-rolling this

Quoted 6 lines · Samuel Čavoj

From: Johannes Schindelin <[email protected]>

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit.

Quoted 5 lines

Small nit-pick: I think it worked fine with if commit.gpgsign was set and the user did not pass -S or --no-gpg-sign because merge would sign the commits as commit.gpgsign was set, it was only if the user passed a gpg signing option to rebase that we had problems. I'm not sure it's worth a re-roll just for that though

This is not the case. That's how I encountered the problem initially, I have commit.gpgsign set to true globally. I ran a rebase -ir, over an octopus merge and then it would fail with an error in the lines of 'not something we can merge'. I later found out it didn't happen on my laptop, where gpgsign is not set, so that's what gave it away. In either case, I did not pass neither -S nor --no-gpg-sign to rebase.

Yes, _if_ the merge command went through, it would have choosen the correct signing behaviour (i.e. the default), but the merge died, because an empty string was being passed to it as one of the commits to merge.

off-topic p.s.:
My mail server does not currently have a proper rDNS record (yeah yeah, I know) and for this reason, gmx.net drops my emails unconditionally. As such, I am unable to send emails directly to [email protected], without major hackery, anyway. I am dropping him from Cc, as to prevent sad mailservers. I hope these messages reach him via the mailing list.

Regards,
Samuel

Quoted 48 lines

Best Wishes

Phillip

Quoted 42 lines

Instead of "-S%s" with
the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
  sequencer.c                | 2 +-
  t/t3435-rebase-gpg-sign.sh | 6 ++++++
  2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
  		strvec_push(&cmd.args, "-F");
  		strvec_push(&cmd.args, git_path_merge_msg(r));
  		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
  		/* Add the tips to be merged */
  		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +6 -0
index b47c59c190..f70b280f5c 100755
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
  	test_must_fail git verify-commit HEAD
  '
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'
+
  test_done
 
#7 lore raw

Hi Samuel

Quoted 28 lines · Samuel Čavoj

Hi Phillip,

Quoted 12 lines · Phillip Wood

Hi Samuel

Thanks for re-rolling this

Quoted 6 lines · Samuel Čavoj

From: Johannes Schindelin <[email protected]>

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit.

Quoted 5 lines

Small nit-pick: I think it worked fine with if commit.gpgsign was set and the user did not pass -S or --no-gpg-sign because merge would sign the commits as commit.gpgsign was set, it was only if the user passed a gpg signing option to rebase that we had problems. I'm not sure it's worth a re-roll just for that though

This is not the case. That's how I encountered the problem initially, I have commit.gpgsign set to true globally. I ran a rebase -ir, over an octopus merge and then it would fail with an error in the lines of 'not something we can merge'. I later found out it didn't happen on my laptop, where gpgsign is not set, so that's what gave it away. In either case, I did not pass neither -S nor --no-gpg-sign to rebase.

Quoted 4 lines

Yes, _if_ the merge command went through, it would have choosen the correct signing behaviour (i.e. the default), but the merge died, because an empty string was being passed to it as one of the commits to merge.

Oh sorry for some reason I thought we just ignored opts->gpg_sign before your patch I'd forgotten we actually passed it without the '-S' - thanks for correcting me.

Quoted 3 lines

off-topic p.s.:
My mail server does not currently have a proper rDNS record (yeah yeah, I know) and for this reason, gmx.net drops my emails unconditionally.

It was dropping my emails sent from a gmail account a few weeks back

Quoted 4 lines

As
such, I am unable to send emails directly to [email protected], without major hackery, anyway. I am dropping him from Cc, as to prevent sad mailservers. I hope these messages reach him via the mailing list.

He's subscribed to the list so hopefully will see them that way

Best Wishes

Phillip

Quoted 51 lines

Regards,
Samuel

Quoted 48 lines

Best Wishes

Phillip

Quoted 42 lines

Instead of "-S%s" with
the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
   sequencer.c                | 2 +-
   t/t3435-rebase-gpg-sign.sh | 6 ++++++
   2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
   		strvec_push(&cmd.args, "-F");
   		strvec_push(&cmd.args, git_path_merge_msg(r));
   		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
   		/* Add the tips to be merged */
   		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +6 -0
index b47c59c190..f70b280f5c 100755
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
   	test_must_fail git verify-commit HEAD
   '
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'
+
   test_done
 
#8 lore raw
In reply to Samuel Čavoj

Hi Samuel

Quoted 38 lines · Samuel Čavoj

From: Johannes Schindelin <[email protected]>

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit. Instead of "-S%s" with the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
  sequencer.c                | 2 +-
  t/t3435-rebase-gpg-sign.sh | 6 ++++++
  2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
  		strvec_push(&cmd.args, "-F");
  		strvec_push(&cmd.args, git_path_merge_msg(r));
  		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
 
  		/* Add the tips to be merged */
  		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +0 -0
index b47c59c190..f70b280f5c 100755

t/t3435-rebase-gpg-sign.sh test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' · line 75

Quoted 8 lines
t/t3435-rebase-gpg-sign.sh +5 -0
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
  	test_must_fail git verify-commit HEAD
  '
 
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'

Unfortunately I've just noticed that the test above runs

git config commit.gpgsign true

So this test would pass anyway if merge picks up that config setting. The previous test needs to be changed to

test_config commit.gpgsign true

so that the config setting is cleared when that test finishes. That previous test would then be a good template for testing rebase -r --no-gpg-sign if you wanted to add a test for that to the next patch as Junio suggested.

Best Wishes

Phillip

Quoted 2 lines
t/t3435-rebase-gpg-sign.sh +0 -0
  test_done
#9 lore raw

Hi Phillip,

thank you very much for the feedback.

Quoted 50 lines · Phillip Wood

Hi Samuel

Quoted 37 lines · Samuel Čavoj

From: Johannes Schindelin <[email protected]>

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit. Instead of "-S%s" with the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
  sequencer.c                | 2 +-
  t/t3435-rebase-gpg-sign.sh | 6 ++++++
  2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
  		strvec_push(&cmd.args, "-F");
  		strvec_push(&cmd.args, git_path_merge_msg(r));
  		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
  		/* Add the tips to be merged */
  		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +0 -0
index b47c59c190..f70b280f5c 100755

t/t3435-rebase-gpg-sign.sh test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' · line 74

Quoted 7 lines
t/t3435-rebase-gpg-sign.sh +5 -0
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
  	test_must_fail git verify-commit HEAD
  '
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'

Unfortunately I've just noticed that the test above runs

Quoted 6 lines

git config commit.gpgsign true

So this test would pass anyway if merge picks up that config setting. The previous test needs to be changed to

test_config commit.gpgsign true

Should I do that now, maybe as a separate part of the patch series? Or just override the config with a test_config commit.gpgsign false in the test I added?

There is another usage of git config in the file, in the test_rebase_gpg_sign function.

Quoted 4 lines

so that the config setting is cleared when that test finishes. That previous test would then be a good template for testing rebase -r --no-gpg-sign if you wanted to add a test for that to the next patch as Junio suggested.

Yes, I will definitely do that in v3. Also, the previous test is expect_failure, that means its a known bug?

Regards,
Samuel

Quoted 8 lines

Best Wishes

Phillip

Quoted 2 lines
t/t3435-rebase-gpg-sign.sh +0 -0
  test_done
 
#10 lore raw

Hi Samuel

Quoted 58 lines · Samuel Čavoj

Hi Phillip,

thank you very much for the feedback.

Quoted 53 lines · Phillip Wood

Hi Samuel

Quoted 37 lines · Samuel Čavoj

From: Johannes Schindelin <[email protected]>

When performing a rebase with --rebase-merges using either a custom strategy specified with -s or an octopus merge, and at the same time having gpgsign enabled (either rebase -S or config commit.gpgsign), the operation would fail on making the merge commit. Instead of "-S%s" with the key id substituted, only the bare key id would get passed to the underlying merge command, which tried to interpret it as a ref.

Fix the issue and add a test case as suggested by Johannes Schindelin.

---
changed v1 -> v2:
added test case

---
   sequencer.c                | 2 +-
   t/t3435-rebase-gpg-sign.sh | 6 ++++++
   2 files changed, 7 insertions(+), 1 deletion(-)
sequencer.c +1 -1
index 00acb12496..88ccff4838 100644
@@ -3677,7 +3677,7 @@ static int do_merge(struct repository *r,
   		strvec_push(&cmd.args, "-F");
   		strvec_push(&cmd.args, git_path_merge_msg(r));
   		if (opts->gpg_sign)
-			strvec_push(&cmd.args, opts->gpg_sign);
+			strvec_pushf(&cmd.args, "-S%s", opts->gpg_sign);
   		/* Add the tips to be merged */
   		for (j = to_merge; j; j = j->next)
t/t3435-rebase-gpg-sign.sh +0 -0
index b47c59c190..f70b280f5c 100755

t/t3435-rebase-gpg-sign.sh test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' · line 74

Quoted 7 lines
t/t3435-rebase-gpg-sign.sh +5 -0
@@ -68,4 +68,10 @@ test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
   	test_must_fail git verify-commit HEAD
   '
+test_expect_success 'rebase -r, GPG and merge strategies' '
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'

Unfortunately I've just noticed that the test above runs

git config commit.gpgsign true

So this test would pass anyway if merge picks up that config setting.

That's predicated on my misunderstanding of the behavior without your patch but it would be good to fix the test anyway

Quoted 8 lines
Quoted 4 lines

The
previous test needs to be changed to

test_config commit.gpgsign true

Should I do that now, maybe as a separate part of the patch series? Or just override the config with a test_config commit.gpgsign false in the test I added?

As you've found another instance that needs changing it would probably be better as a separate patch

Quoted 2 lines

There is another usage of git config in the file, in the test_rebase_gpg_sign function.

Well spotted, that should be changed as well

Quoted 5 lines
Quoted 3 lines

so that the config setting is cleared when that test finishes. That previous test would then be a good template for testing rebase -r --no-gpg-sign if you wanted to add a test for that to the next patch as Junio suggested.

Yes, I will definitely do that in v3.

Thanks

Quoted 2 lines

Also, the previous test is expect_failure,
that means its a known bug?

Yes, rebase -p is deprecated and it looks like it was skipped by the recent fix for rebase --no-gpg-sign in c241371c04 ("rebase.c: honour --no-gpg-sign", 2020-04-03)

Best Wishes

Phillip

Quoted 11 lines

Regards,
Samuel

Quoted 8 lines

Best Wishes

Phillip

Quoted 2 lines
t/t3435-rebase-gpg-sign.sh +0 -0
   test_done
 
#11 lore raw
In reply to Phillip Wood
Quoted 8 lines · Phillip Wood

t/t3435-rebase-gpg-sign.sh test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' · line 75

Quoted 5 lines

+test_expect_success 'rebase -r, GPG and merge strategies' '

t/t3435-rebase-gpg-sign.sh +4 -0
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'

Unfortunately I've just noticed that the test above runs

Quoted 8 lines

git config commit.gpgsign true

So this test would pass anyway if merge picks up that config setting. The previous test needs to be changed to

test_config commit.gpgsign true

so that the config setting is cleared when that test finishes.

Thanks for a review, but I do not think that is a right way to go.

test_config has an inherent assumption that not having the config at all is somehow the "natural" state, and if that holds true, that would be OK. But what is "natural" is subjective X-<.

The way each test is run by calling test_rebase_gpg_sign repeatedly uses a different and more robust approach to ensure that previous test does not affect the current one. Each invocation of test explicitly sets the configuration to the state the test wants to, cancelling what the previous test did.

To blend in better with existing tests and match their robustness expectations, the right fix is for this new test to explicitly use "git config --set" or "git config --unset" to make the variable into the desired state, regardless of what the previous tests did.

If the test quoted at the beginning of this message wants to make sure that --gpg-sign from the command line takes effect without commit.gpgsign set, it should unset the variable explicitly. Another combination worth testing is to ensure that --gpg-sign takes effect when commit.gpgsign is explicitly set to false (not "left unset").

Thanks.

#12 lore raw

Hi,

Quoted 31 lines · Junio C Hamano
Quoted 8 lines · Phillip Wood

t/t3435-rebase-gpg-sign.sh test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' · line 75

Quoted 5 lines

+test_expect_success 'rebase -r, GPG and merge strategies' '

t/t3435-rebase-gpg-sign.sh +4 -0
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'

Unfortunately I've just noticed that the test above runs

Quoted 8 lines

git config commit.gpgsign true

So this test would pass anyway if merge picks up that config setting. The previous test needs to be changed to

test_config commit.gpgsign true

so that the config setting is cleared when that test finishes.

Thanks for a review, but I do not think that is a right way to go.

test_config has an inherent assumption that not having the config at all is somehow the "natural" state, and if that holds true, that would be OK. But what is "natural" is subjective X-<.

The way each test is run by calling test_rebase_gpg_sign repeatedly uses a different and more robust approach to ensure that previous test does not affect the current one. Each invocation of test explicitly sets the configuration to the state the test wants to, cancelling what the previous test did.

Quoted 4 lines

To blend in better with existing tests and match their robustness expectations, the right fix is for this new test to explicitly use "git config --set" or "git config --unset" to make the variable into the desired state, regardless of what the previous tests did.

This is more or less what I did in v3, although not completely comprehensively. Of course, the test_rebase_gpg_sign function could be either duplicated or modified to be more generic in order to accommodate all combinations for the new tests, though I considered this not worth doing. I am open to it, however.

I'm unfamiliar with the git codebase and the testing practices, so a little hand-holding might be needed, I hope that's not a bother for you.

In addition, I have replaced git config usages with test_config, not sure if that should be reverted -- I see no harm in using it, and I guess it is slightly more explicit.

Speaking of v3, I pulled the trigger a little too fast on that one, should have waited a little longer for feedback. Sorry about that.

Though, I am not sure what has happened to it. I sent it out in the usual manner, but it hasn't appeared in any of the mailing list archives. Can you please confirm (or deny) that you have received it? In case not, should I just send it again, with the same Message-Id's? All the recipient mail servers responded with a 250 Ok from my postfix logs.

Thank you for all the help.

Regards,
Samuel

Quoted 10 lines

If the test quoted at the beginning of this message wants to make sure that --gpg-sign from the command line takes effect without commit.gpgsign set, it should unset the variable explicitly. Another combination worth testing is to ensure that --gpg-sign takes effect when commit.gpgsign is explicitly set to false (not "left unset").

Thanks.

#13 lore raw
Quoted 2 lines · Samuel Čavoj

Speaking of v3, I pulled the trigger a little too fast on that one, should have waited a little longer for feedback. Sorry about that.

Nothing to be sorry about---working asynchronously, mails crossing and timings not coinciding are just expected parts of life. It is the kind of thing participants need to learn to adjust, as "normal latency" is different from community to community.

Quoted 6 lines

Though, I am not sure what has happened to it. I sent it out in the usual manner, but it hasn't appeared in any of the mailing list archives. Can you please confirm (or deny) that you have received it? In case not, should I just send it again, with the same Message-Id's? All the recipient mail servers responded with a 250 Ok from my postfix logs.

I see the message I am responding to has a timestamp that is about 16 hours ago (relative to the time I am typing this response), but I am fairly sure that I didn't see it ten hours ago (i.e. my last night's final e-mail scanning).

Perhaps there was congestion somewhere that held some messages.

#14 lore raw
In reply to Junio C Hamano

Hi Junio

It seems to be that the config handling here is another example an interdependence between tests that makes life harder for contributors and reviewers.

Quoted 17 lines · Junio C Hamano
Quoted 15 lines · Phillip Wood

t/t3435-rebase-gpg-sign.sh test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' ' · line 75

Quoted 5 lines

+test_expect_success 'rebase -r, GPG and merge strategies' '

t/t3435-rebase-gpg-sign.sh +4 -0
+	git reset --hard merged &&
+	git rebase -fr --gpg-sign -s resolve --root &&
+	git verify-commit HEAD
+'

Unfortunately I've just noticed that the test above runs

git config commit.gpgsign true

So this test would pass anyway if merge picks up that config setting. The previous test needs to be changed to

test_config commit.gpgsign true

Quoted 7 lines
Quoted 1 line

so that the config setting is cleared when that test finishes.

Thanks for a review, but I do not think that is a right way to go.

test_config has an inherent assumption that not having the config at all is somehow the "natural" state, and if that holds true, that would be OK. But what is "natural" is subjective X-<.

What is "natural" is subjective but what is the default config is not. If test scripts set random config variables and assumes that they will be cleared in later tests if they don't want them it makes it very hard for contributors and reviewers to check that new tests are sound as they have to analyze each existing test in the script. In this example I believe the new test was contributed by dscho who is an experienced contributor with an interest in the test suite. However the test did not clear the relevant config variable - if an experienced contributor did not realize that the variable needed to be cleared how are new contributors supposed to figure it out? If each test starts with the default config it is much easier to reason about it.

Quoted 5 lines

The way each test is run by calling test_rebase_gpg_sign repeatedly uses a different and more robust approach to ensure that previous test does not affect the current one. Each invocation of test explicitly sets the configuration to the state the test wants to, cancelling what the previous test did.

It is only robust if contributors and reviewers realize that is what is expected. Reviewers that only read the patch without loading up the test file in their editor have no indication that the test should be clearing the config variable.

Best Wishes

Phillip

Quoted 16 lines

To blend in better with existing tests and match their robustness expectations, the right fix is for this new test to explicitly use "git config --set" or "git config --unset" to make the variable into the desired state, regardless of what the previous tests did.

If the test quoted at the beginning of this message wants to make sure that --gpg-sign from the command line takes effect without commit.gpgsign set, it should unset the variable explicitly. Another combination worth testing is to ensure that --gpg-sign takes effect when commit.gpgsign is explicitly set to false (not "left unset").

Thanks.

#15 lore raw
Quoted 3 lines · Phillip Wood

... Reviewers that only read the patch without loading up the test file in their editor have no indication that the test should be clearing the config variable.

It is not a review if the code being updated is not checked for sanity in its own context, is it?

#16 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · Phillip Wood

... Reviewers that only read the patch without loading up the test file in their editor have no indication that the test should be clearing the config variable.

It is not a review if the code being updated is not checked for sanity in its own context, is it?

It is disappointing that you have chosen to cut the original to those few lines and reply just to them. The original message made the broader point that having to check the previous tests in a file to figure out what the state is at the beginning of any new test that gets added makes life harder than it needs to be both for contributors and reviewers.

Phillip

#17 lore raw
In reply to Phillip Wood
Quoted 6 lines · Phillip Wood

What is "natural" is subjective but what is the default config is not. If test scripts set random config variables and assumes that they will be ...
... cleared how are new contributors supposed to figure it out? If each test starts with the default config it is much easier to reason about it.

If this were a test script with many tests, all of which depend on starting from clean slate wrt the configuration variable space, and if you are adding just one or two tests that wants to run with configuration variable in effect, the story would be quite different. For example, I would think it would make a lot of sense in <[email protected]> to use test_config instead of "git config" as it is clear that leading 100+ lines of tests run with the default configuration, and it is sane to expact that later tests that may be added in the future would be the same.

Look at the test script in question again and notice that it is about seeing behaviour with the single configuration variable set to true or false. Using test_config would still signal the test pieces that use it do depend on the shown setting of the variable, but it does not help at all the test pieces that wants to see what happens when there is no configuration. Explicitly using "git config" and "test_unconfig" actually would _help_ reviewers who only looks between the pre- and post- context lines that are affected by the patch, as they do not have to know or assume that "normal state is nothing configured" (which needs to be verified by seeing all the existing tests that are not shown in the patch use test_config to clear the setting when they are done).

All of the above would be obvious once you think about it, I'd think.

Thanks.