diff mbox series

[v2] subtree: force merge commit

Message ID pull.1139.v2.git.git.1636926322423.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit 9158a3564a970def3375a79e8f3f90927cd8e793
Headers show
Series [v2] subtree: force merge commit | expand

Commit Message

Thomas Koutcher Nov. 14, 2021, 9:45 p.m. UTC
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(-)


base-commit: 5fbd2fc5997dfa4d4593a862fe729b1e7a89bcf8

Comments

Junio C Hamano Nov. 18, 2021, 4:53 a.m. UTC | #1
"Thomas Koutcher via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.

> 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, 6:06 a.m. UTC | #2
Le 18/11/2021 à 05:53, Junio C Hamano a écrit :

> 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.
diff mbox series

Patch

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
 }