threads / patch / 56895

patchsubtree: ignore merge.ff setting

Subject: [PATCH] subtree: ignore merge.ff setting

## tl;dr

10 messages between Nov 14, 2021 and Feb 1, 2022. Diffs are folded; open one to read it.

replies: 9people: 4as markdown or json

Thomas Koutcher via GitGitGadget· Nov 14, 2021, 15:07 UTC · lore
From: Thomas Koutcher <thomas.koutcher@online.fr>

When `merge.ff` is set to `only` in .gitconfig, `git subtree pull` will fail with error `fatal: Not possible to fast-forward, aborting.`. This fix ignores the `merge.ff` setting when using `git merge` within subtree.

Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
---
    subtree: ignore merge.ff setting
    
    When merge.ff is set to only in .gitconfig, git subtree pull will fail
    with error fatal: Not possible to fast-forward, aborting.. This fix
    ignores the merge.ff setting when using git merge within subtree.
    
    Signed-off-by: Thomas Koutcher thomas.koutcher@online.fr
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1139%2Fkoutcher%2Fsubtree-merge-ff-fix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1139/koutcher/subtree-merge-ff-fix-v1
Pull-Request: https://github.com/git/git/pull/1139
 contrib/subtree/git-subtree.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to contrib/subtree/git-subtree.sh +2 −2
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 7f767b5c38f..de918d9fb05 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -976,10 +976,10 @@ cmd_merge () {
 
 	if test -n "$arg_addmerge_message"
 	then
-		git merge -Xsubtree="$arg_prefix" \
+		git -c merge.ff= merge -Xsubtree="$arg_prefix" \
 			--message="$arg_addmerge_message" "$rev"
 	else
-		git merge -Xsubtree="$arg_prefix" $rev
+		git -c merge.ff= merge -Xsubtree="$arg_prefix" $rev
 	fi
 }
 

base-commit: 5fbd2fc5997dfa4d4593a862fe729b1e7a89bcf8
-- 
gitgitgadget
Ævar Arnfjörð Bjarmason· Nov 14, 2021, 17:54 UTC · re: Thomas Koutcher via GitGitGadget · lore

Re: [PATCH] subtree: ignore merge.ff setting

On Sun, Nov 14 2021, Thomas Koutcher via GitGitGadget wrote:
Show 39 quoted lines
> From: Thomas Koutcher <thomas.koutcher@online.fr>
>
> When `merge.ff` is set to `only` in .gitconfig, `git subtree pull` will
> fail with error `fatal: Not possible to fast-forward, aborting.`. This
> fix ignores the `merge.ff` setting when using `git merge` within subtree.
>
> Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
> ---
>     subtree: ignore merge.ff setting
>     
>     When merge.ff is set to only in .gitconfig, git subtree pull will fail
>     with error fatal: Not possible to fast-forward, aborting.. This fix
>     ignores the merge.ff setting when using git merge within subtree.
>     
>     Signed-off-by: Thomas Koutcher thomas.koutcher@online.fr
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1139%2Fkoutcher%2Fsubtree-merge-ff-fix-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1139/koutcher/subtree-merge-ff-fix-v1
> Pull-Request: https://github.com/git/git/pull/1139
>
>  contrib/subtree/git-subtree.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 7f767b5c38f..de918d9fb05 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -976,10 +976,10 @@ cmd_merge () {
>  
>  	if test -n "$arg_addmerge_message"
>  	then
> -		git merge -Xsubtree="$arg_prefix" \
> +		git -c merge.ff= merge -Xsubtree="$arg_prefix" \
>  			--message="$arg_addmerge_message" "$rev"
>  	else
> -		git merge -Xsubtree="$arg_prefix" $rev
> +		git -c merge.ff= merge -Xsubtree="$arg_prefix" $rev
>  	fi
>  }

"-c merge.ff=" works, it's lesser known syntax. I'd tihnk "-c merge.ff=false" would be better here, i.e. what matches "git config"'s description of "merge.ff".

Junio C Hamano· Nov 14, 2021, 18:38 UTC · re: Thomas Koutcher via GitGitGadget · lore

Re: [PATCH] subtree: ignore merge.ff setting

"Thomas Koutcher via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> From: Thomas Koutcher <thomas.koutcher@online.fr>
>
> When `merge.ff` is set to `only` in .gitconfig, `git subtree pull` will
> fail with error `fatal: Not possible to fast-forward, aborting.`. This
> fix ignores the `merge.ff` setting when using `git merge` within subtree.

The first sentence is understandasble as a statement of fact. There is a small logic gap between it and the second sentence, calling the change in the patch a "fix". I think ", but the command does want to make merges in these places." added after the first sentence would fix it.

Show 21 quoted lines
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1139%2Fkoutcher%2Fsubtree-merge-ff-fix-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1139/koutcher/subtree-merge-ff-fix-v1
> Pull-Request: https://github.com/git/git/pull/1139
>
>  contrib/subtree/git-subtree.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 7f767b5c38f..de918d9fb05 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -976,10 +976,10 @@ cmd_merge () {
>  
>  	if test -n "$arg_addmerge_message"
>  	then
> -		git merge -Xsubtree="$arg_prefix" \
> +		git -c merge.ff= merge -Xsubtree="$arg_prefix" \
>  			--message="$arg_addmerge_message" "$rev"
>  	else
> -		git merge -Xsubtree="$arg_prefix" $rev
> +		git -c merge.ff= merge -Xsubtree="$arg_prefix" $rev

And the natural way to override what is configured is to pass a countermanding command line option, e.g. "git merge --ff" (or "git merge --no-ff", if it wants to always create a merge even when taking a change that is a descendant---I do not know the need of "git subtree" well enough to tell), and that is easier to read than "git -c ...".

Thomas Koutcher via GitGitGadget· Nov 14, 2021, 21:45 UTC · re: Thomas Koutcher via GitGitGadget · lore

[PATCH v2] subtree: force merge commit

From: Thomas Koutcher <thomas.koutcher@online.fr>

When `merge.ff` is set to `only` in .gitconfig, `git subtree pull` will fail with error `fatal: Not possible to fast-forward, aborting.`, but the command does want to make merges in these places. Add `--no-ff` argument to `git merge` to enforce this behaviour.

Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
---
    subtree: ignore merge.ff setting
    
    When merge.ff is set to only in .gitconfig, git subtree pull will fail
    with error fatal: Not possible to fast-forward, aborting.. This fix
    ignores the merge.ff setting when using git merge within subtree.
    
    Signed-off-by: Thomas Koutcher thomas.koutcher@online.fr
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1139%2Fkoutcher%2Fsubtree-merge-ff-fix-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1139/koutcher/subtree-merge-ff-fix-v2
Pull-Request: https://github.com/git/git/pull/1139
Range-diff vs v1:
 1:  b03749fda76 ! 1:  765fea3e26c subtree: ignore merge.ff setting
     @@ Metadata
      Author: Thomas Koutcher <thomas.koutcher@online.fr>
      
       ## Commit message ##
     -    subtree: ignore merge.ff setting
     +    subtree: force merge commit
      
          When `merge.ff` is set to `only` in .gitconfig, `git subtree pull` will
     -    fail with error `fatal: Not possible to fast-forward, aborting.`. This
     -    fix ignores the `merge.ff` setting when using `git merge` within subtree.
     +    fail with error `fatal: Not possible to fast-forward, aborting.`, but
     +    the command does want to make merges in these places. Add `--no-ff`
     +    argument to `git merge` to enforce this behaviour.
      
     +    Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     +    Reviewed-by: Junio C Hamano <gitster@pobox.com>
          Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
      
       ## contrib/subtree/git-subtree.sh ##
     @@ contrib/subtree/git-subtree.sh: cmd_merge () {
       	if test -n "$arg_addmerge_message"
       	then
      -		git merge -Xsubtree="$arg_prefix" \
     -+		git -c merge.ff= merge -Xsubtree="$arg_prefix" \
     ++		git merge --no-ff -Xsubtree="$arg_prefix" \
       			--message="$arg_addmerge_message" "$rev"
       	else
      -		git merge -Xsubtree="$arg_prefix" $rev
     -+		git -c merge.ff= merge -Xsubtree="$arg_prefix" $rev
     ++		git merge --no-ff -Xsubtree="$arg_prefix" $rev
       	fi
       }
       
 contrib/subtree/git-subtree.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to contrib/subtree/git-subtree.sh +2 −2
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 7f767b5c38f..cb51aee4cbf 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -976,10 +976,10 @@ cmd_merge () {
 
 	if test -n "$arg_addmerge_message"
 	then
-		git merge -Xsubtree="$arg_prefix" \
+		git merge --no-ff -Xsubtree="$arg_prefix" \
 			--message="$arg_addmerge_message" "$rev"
 	else
-		git merge -Xsubtree="$arg_prefix" $rev
+		git merge --no-ff -Xsubtree="$arg_prefix" $rev
 	fi
 }
 

base-commit: 5fbd2fc5997dfa4d4593a862fe729b1e7a89bcf8
-- 
gitgitgadget
Junio C Hamano· Nov 18, 2021, 04:53 UTC · re: Thomas Koutcher via GitGitGadget · lore

Re: [PATCH v2] subtree: force merge commit

"Thomas Koutcher via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> From: Thomas Koutcher <thomas.koutcher@online.fr>
>
> When `merge.ff` is set to `only` in .gitconfig, `git subtree pull` will
> fail with error `fatal: Not possible to fast-forward, aborting.`, but
> the command does want to make merges in these places. Add `--no-ff`
> argument to `git merge` to enforce this behaviour.
>
> Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Reviewed-by: Junio C Hamano <gitster@pobox.com>
Reviewed-by: is a bit tricky.  If you are sending a corrected
version after other people just took a look at a previous iteration,
you cannot generally have them for two reasons.  First of all, they
haven't said that you can have Reviewed-by: under there name (which
means that they are completely satisfied after giving a thorough
analysis).  Also, the version you are sending is different from what
they reviewed, so even if they were happy with the previous iteration,
it does not mean they would be with this version.
Show 16 quoted lines
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index 7f767b5c38f..cb51aee4cbf 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -976,10 +976,10 @@ cmd_merge () {
>  
>  	if test -n "$arg_addmerge_message"
>  	then
> -		git merge -Xsubtree="$arg_prefix" \
> +		git merge --no-ff -Xsubtree="$arg_prefix" \
>  			--message="$arg_addmerge_message" "$rev"
>  	else
> -		git merge -Xsubtree="$arg_prefix" $rev
> +		git merge --no-ff -Xsubtree="$arg_prefix" $rev
>  	fi
>  }
Thanks.  I'll drop these two reviewed-by lines while queuing.
Thomas Koutcher· Nov 18, 2021, 06:06 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] subtree: force merge commit

Le 18/11/2021 à 05:53, Junio C Hamano a écrit :
Show 8 quoted lines
> Reviewed-by: is a bit tricky.  If you are sending a corrected
> version after other people just took a look at a previous iteration,
> you cannot generally have them for two reasons.  First of all, they
> haven't said that you can have Reviewed-by: under there name (which
> means that they are completely satisfied after giving a thorough
> analysis).  Also, the version you are sending is different from what
> they reviewed, so even if they were happy with the previous iteration,
> it does not mean they would be with this version.
Thanks for the clarification and sorry for the confusion I created.
Johannes Altmanninger· Feb 1, 2022, 17:26 UTC · re: Junio C Hamano · lore

[PATCH RESEND] subtree: force merge commit

From: Thomas Koutcher <thomas.koutcher@online.fr>

When `merge.ff` is set to `only` in .gitconfig, `git subtree pull` will fail with error `fatal: Not possible to fast-forward, aborting.`, but the command does want to make merges in these places. Add `--no-ff` argument to `git merge` to enforce this behaviour.

Signed-off-by: Thomas Koutcher <thomas.koutcher@online.fr>
Reviewed-by: Johannes Altmanninger <aclopte@gmail.com>
---
I think this was meant to be queued but forgotten.
Junio C Hamano <gitster@pobox.com> writes:
> Thanks.  I'll drop these two reviewed-by lines while queuing.
Changes since v2: removed/added reviewed-by trailer

BTW is there a good way to tell "git send-email --in-reply-to" to prefill "To:" and "Cc:" based on the message I'm replying to?

 contrib/subtree/git-subtree.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to contrib/subtree/git-subtree.sh +2 −2
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 71f1fd94bd..1af1d9653e 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -975,10 +975,10 @@ cmd_merge () {
 
 	if test -n "$arg_addmerge_message"
 	then
-		git merge -Xsubtree="$arg_prefix" \
+		git merge --no-ff -Xsubtree="$arg_prefix" \
 			--message="$arg_addmerge_message" "$rev"
 	else
-		git merge -Xsubtree="$arg_prefix" $rev
+		git merge --no-ff -Xsubtree="$arg_prefix" $rev
 	fi
 }
 
-- 
2.35.0.295.gee0e44bcb6
Junio C Hamano· Feb 1, 2022, 19:19 UTC · re: Johannes Altmanninger · lore

Re: [PATCH RESEND] subtree: force merge commit

Johannes Altmanninger <aclopte@gmail.com> writes:
> BTW is there a good way to tell "git send-email --in-reply-to"
> to prefill "To:" and "Cc:" based on the message I'm replying to?

I do not think there is, and I do not think it is readily feasible. Given a message ID, how would you figure out these two values? Hardcode the URL of mailing list archive and the rules to find these values given a message ID? What if you have a local mail archive that you'd rather use instead of going to the public internet?

Johannes Altmanninger· Feb 1, 2022, 19:53 UTC · re: Junio C Hamano · lore

Re: [PATCH RESEND] subtree: force merge commit

On Tue, Feb 01, 2022 at 11:19:45AM -0800, Junio C Hamano wrote:
Show 10 quoted lines
> Johannes Altmanninger <aclopte@gmail.com> writes:
> 
> > BTW is there a good way to tell "git send-email --in-reply-to"
> > to prefill "To:" and "Cc:" based on the message I'm replying to?
> 
> I do not think there is, and I do not think it is readily feasible.
> Given a message ID, how would you figure out these two values?
> Hardcode the URL of mailing list archive and the rules to find these
> values given a message ID?  What if you have a local mail archive
> that you'd rather use instead of going to the public internet?

The "b4" tool accepts message IDs and allows to configure how to look up message contents. This is the default:

	[b4]
	# Where to look up threads by message id
	midmask = https://lore.kernel.org/r/%s

b4 has some powerful features but I think I just want something that reads an email on stdin and outputs the appropriate "send-email --in-reply-to" command. I'll probably parse the mail headers myself.

Junio C Hamano· Feb 1, 2022, 23:20 UTC · re: Johannes Altmanninger · lore

Re: [PATCH RESEND] subtree: force merge commit

Johannes Altmanninger <aclopte@gmail.com> writes:
Show 22 quoted lines
> On Tue, Feb 01, 2022 at 11:19:45AM -0800, Junio C Hamano wrote:
>> Johannes Altmanninger <aclopte@gmail.com> writes:
>> 
>> > BTW is there a good way to tell "git send-email --in-reply-to"
>> > to prefill "To:" and "Cc:" based on the message I'm replying to?
>> 
>> I do not think there is, and I do not think it is readily feasible.
>> Given a message ID, how would you figure out these two values?
>> Hardcode the URL of mailing list archive and the rules to find these
>> values given a message ID?  What if you have a local mail archive
>> that you'd rather use instead of going to the public internet?
>
> The "b4" tool accepts message IDs and allows to configure how to look up
> message contents. This is the default:
>
> 	[b4]
> 	# Where to look up threads by message id
> 	midmask = https://lore.kernel.org/r/%s
>
> b4 has some powerful features but I think I just want something that reads an
> email on stdin and outputs the appropriate "send-email --in-reply-to" command.
> I'll probably parse the mail headers myself.

I know about "b4" and use it myself, but so what? "git" is used by a lot wider audience than those who can fetch patches from k.org.

So, I think it still is correct to say that it is not readily feasible, without telling the command ways to turn a message-ID into to/cc addresses.

← back to recent threads