# [PATCH] feature request: git-mergetool --force

6 messages from 2008-10-17 to 2008-10-19. Participants: William Pursell, Jeff King, Charles Bailey.
Thread: https://gitlist.dev/t/15941

## William Pursell, 2008-10-17 23:23

Subject: [PATCH] feature request: git-mergetool --force
Message-ID: <48F91E59.50202@gmail.com>
URL: https://gitlist.dev/e/48F91E59.50202%40gmail.com

```
I occasionally use commands like 'cp $REMOTE $MERGED' with
mergetool, and would prefer to not be prompted to start
the tool on each file.  A --force option would be handy.

-- 
William Pursell


diff --git a/git-mergetool.sh b/git-mergetool.sh
index 94187c3..5c9ce09 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -8,7 +8,7 @@
  # at the discretion of Junio C Hamano.
  #

-USAGE='[--tool=tool] [file to merge] ...'
+USAGE='[--tool=tool] [--force] [file to merge] ...'
  SUBDIRECTORY_OK=Yes
  OPTIONS_SPEC=
  . git-sh-setup
@@ -176,8 +176,10 @@ merge_file () {
      echo "Normal merge conflict for '$MERGED':"
      describe_file "$local_mode" "local" "$LOCAL"
      describe_file "$remote_mode" "remote" "$REMOTE"
-    printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
-    read ans
+    if test x"$force_option" != xyes; then
+	printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
+	read ans
+    fi

      case "$merge_tool" in
  	kdiff3)
@@ -283,6 +285,9 @@ merge_file () {
  while test $# != 0
  do
      case "$1" in
+	-f|--fo|--for|--forc|--force)
+	    force_option=yes
+	    ;;
  	-t|--tool*)
  	    case "$#,$1" in
  		*,*=*)

```

## Jeff King, 2008-10-18 15:48

Subject: Re: [PATCH] feature request: git-mergetool --force
Message-ID: <20081018154824.GA20185@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20081018154824.GA20185%40coredump.intra.peff.net
In-Reply-To: <48F91E59.50202@gmail.com>

```
On Sat, Oct 18, 2008 at 12:23:05AM +0100, William Pursell wrote:

> I occasionally use commands like 'cp $REMOTE $MERGED' with
> mergetool, and would prefer to not be prompted to start
> the tool on each file.  A --force option would be handy.

I think it is reasonable to want to skip this prompt, but I am not sure
"--force" is the right name for such an option. Usually we reserve
--force for "the tool is trying to prevent something destructive or
unusual, and the user wants to override it".

Something like --no-prompt makes more sense to me, though probably
something a little easier to type would be nice (or maybe alias "-n").

-Peff

```

## William Pursell, 2008-10-18 18:44

Subject: Re: [PATCH] feature request: git-mergetool --force
Message-ID: <48FA2E9F.3090305@gmail.com>
URL: https://gitlist.dev/e/48FA2E9F.3090305%40gmail.com
In-Reply-To: <20081018154824.GA20185@coredump.intra.peff.net>

```
Jeff King wrote:
> On Sat, Oct 18, 2008 at 12:23:05AM +0100, William Pursell wrote:
> 
>> I occasionally use commands like 'cp $REMOTE $MERGED' with
>> mergetool, and would prefer to not be prompted to start
>> the tool on each file.  A --force option would be handy.
> 
> I think it is reasonable to want to skip this prompt, but I am not sure
> "--force" is the right name for such an option. Usually we reserve
> --force for "the tool is trying to prevent something destructive or
> unusual, and the user wants to override it".
> 
> Something like --no-prompt makes more sense to me, though probably
> something a little easier to type would be nice (or maybe alias "-n").

Actually, perhaps an "interactive=no" configuration setting,
which might imply trustExitCode = true.

-- 
William Pursell

```

## Jeff King, 2008-10-18 20:54

Subject: Re: [PATCH] feature request: git-mergetool --force
Message-ID: <20081018205443.GA29534@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20081018205443.GA29534%40coredump.intra.peff.net
In-Reply-To: <48FA2E9F.3090305@gmail.com>

```
On Sat, Oct 18, 2008 at 07:44:47PM +0100, William Pursell wrote:

>> Something like --no-prompt makes more sense to me, though probably
>> something a little easier to type would be nice (or maybe alias "-n").
>
> Actually, perhaps an "interactive=no" configuration setting,
> which might imply trustExitCode = true.

That sounds reasonable to me.

-Peff

```

## Charles Bailey, 2008-10-18 23:16

Subject: Re: [PATCH] feature request: git-mergetool --force
Message-ID: <48FA6E55.9030101@hashpling.org>
URL: https://gitlist.dev/e/48FA6E55.9030101%40hashpling.org
In-Reply-To: <20081018205443.GA29534@coredump.intra.peff.net>

```
Jeff King wrote:
> On Sat, Oct 18, 2008 at 07:44:47PM +0100, William Pursell wrote:
> 
>>> Something like --no-prompt makes more sense to me, though probably
>>> something a little easier to type would be nice (or maybe alias "-n").
>> Actually, perhaps an "interactive=no" configuration setting,
>> which might imply trustExitCode = true.
> 
> That sounds reasonable to me.
> 
> -Peff

I've recently been using git mergetool quite a bit and I'm currently
cooking a couple of patches. The first, by coincidence, was a "-n"
option which disabled the hit-return-to-actually-do-anything prompt. I,
also, used the variable "NOPROMPT" to describe this behaviour.

The other change that I am working was more of an issue for me. When I
have a fair number of files to merge I sometimes want to skip a merge.
Perhaps it's a tricky one and I want do the easy wins first.

The current behaviour of mergetool is a little annoying for this as the
first 'failed' merge aborts the process and if you restart it will
always pick up from where it left off. If you want to do some of the
later files, you have to specify the full paths to mergetool which can
be a lot more typing.

The change I am implementing just continues after a failed merge (no git
add or anything, so the file stays unmerged) and allows you to merge
subsequent files. I think that this will work reasonably well allowing
you to do your merges in a number of passes, picking off the easy merges
first and doing the tricky ones later. You can also do a quick pass
through all the merges, not actually resolving everything just to see if
there are any show stoppers.

The only gotcha is that this may interact less well with a --no-prompt
option. With the prompt you can always abort the mergetool process with
a SIGINT at the prompt, even if mergetool now wants to offer you the
opportunity to merge subsequent files after aborting one particular file
merge. Without the prompt mergetool is going to spawn your merge tool
for every conflict even if you've changed your mind and want to abort.

Thoughts?

Charles.

```

## Jeff King, 2008-10-19 11:47

Subject: Re: [PATCH] feature request: git-mergetool --force
Message-ID: <20081019114722.GA30412@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20081019114722.GA30412%40coredump.intra.peff.net
In-Reply-To: <48FA6E55.9030101@hashpling.org>

```
On Sun, Oct 19, 2008 at 12:16:37AM +0100, Charles Bailey wrote:

> I've recently been using git mergetool quite a bit and I'm currently
> cooking a couple of patches. The first, by coincidence, was a "-n"
> option which disabled the hit-return-to-actually-do-anything prompt. I,
> also, used the variable "NOPROMPT" to describe this behaviour.
> 
> The other change that I am working was more of an issue for me. When I
> have a fair number of files to merge I sometimes want to skip a merge.
> Perhaps it's a tricky one and I want do the easy wins first.
> [...]
> Thoughts?

I think those are both reasonable behaviors. I also thought instantly of
the issue you mentioned, that people who really did want to abort would
get stuck in a loop of spawning the merge resolver. For that reason, I
think it makes sense to have both of them as options (either config,
command-line, or both). And if you do "git mergetool --no-prompt
--keep-going", then you are accepting the fact that you won't have a
chance to ask it to stop.

And I would suggest "-k, --keep-going" for the second option, as it
reminds me of the similar "make" option.

-Peff

```
