4

I am trying to build a custom mergetool for git that knows more about specific files than git does.

This program will analyze the files that pop up during a merge conflict and for some of them, in some specific cases, it will know how to handle them successfully.

I execute this tool like this:

git mergetool --tool=auto

This successfully runs my program.

However, if the program fails to merge a file, and thus exits with a non-zero exit code I get this prompt from git:

Continue merging other unresolved paths [y/n]? n

Is there a way for me to configure git, or return a specific exit code, that tells git to just keep trying the rest of the files without user intervention?

ie. something like:

git mergetool --tool=auto --continue-always

or some magic exit code that means the same (or any other way to do the same)?

I've configured my mergetool with "trustExitCode = true" if that matters.

The ultimate goal would be that if a merge conflict occurs, I would first run the automagic program, and then use a normal mergetool, like KDiff3 or Beyond Compare, to merge the rest of the files manually.

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825

1 Answers1

0

something like git mergetool --tool=auto --continue-always, or some magic exit code that means the same (or any other way to do the same)?

No, unless you would consider modify git-mergetool.sh directly.

The only improvement on the prompt comes with Git 2.19 (Q3 2018): before, "git mergetool" stopped and gave an extra prompt to continue after the last path has been handled, which did not make much sense.

See commit d651a54 (13 Aug 2018) by Nicholas Guriev (mymedia2). (Merged by Junio C Hamano -- gitster -- in commit 03e904c, 20 Aug 2018)

mergetool: don't suggest to continue after last file

Eliminate an unnecessary prompt to continue after failed merger, by not calling the prompt_after_failed_merge function when only one iteration remains.

Uses positional parameters to count files in the list to make it easier to see if we have any more paths to process from within the loop.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250