GIT 2 or more merge conflicts in one file - how is p4merge handled?

  • GIT p4merge - 2 or more conflicts in one file

I turned on p4merge with GIT, and one day I came across this situation.

I have a file with merge conflicts. The file says that foo.c has merge conflicts in three different lines of code (the first line with the conflict, some lines in the middle with the conflicts).

When I resolved the first lines of the conflict (not other conflicts) and saved (using the save button on p4merge), I assume that it adds foo.c for indexing, and when I do, GIT allows me to commit without giving me an error or warning to resolve other conflicting lines in one file.

Is this a problem with git or p4merge? I think GIT should warn or skip the error that there are other conflicting lines that are in the file. but he just does.


  • Merge a specific file in GIT

I have another question: is there a command so that I can send the developer to merge a specific file? When I run GIT mergetool, it opens all merge conflicts one by one, instead there is a way like clearcase, where can I say merge this selected file?

+4
source share
1 answer
  • My guess: when you save the file in p4merge, it returns with code 0, the file changes, and git assumes the conflicts have been resolved. In your case, there is a configuration parameter mergetool.<tool>.trustExitCode ( mergetool.p4merge.trustExitCode ) that can be set to false, so git will always ask you if the merge was successful after running git mergetool (which can be quite annoying) . You can also write a shell for p4merge that will check for conflict markers after running p4mege or a pre-commit hook that rejects commits containing files containing such markers, although I have never done anything like this.

  • Yes, you can run git mergetool <file> to resolve the specified file. More details here .

+4
source

All Articles