GIT 2 or more merge conflicts in a single file – how p4merge handles?

  1. GIT p4merge – 2 or more conflict in same file

I have integrated p4merge with GIT and i came across this situation once.

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

  • Force Git to always choose the newer version during a merge?
  • Git merge - trivial merge?
  • How to use the default git commit message after resolving merge conflicts?
  • Where's the 3-way Git merge driver for .PO (gettext) files?
  • How to resolve a conflict with git-svn?
  • git merge after file renamed
  • When i resolved the first lines of conflict (not other lines of conflict) and saved (using save button on p4merge) i guess it adds the foo.c to index, and when i commit, git allows me to commit without giving me an error or warning to resolve the other conflicting lines in the same file.

    Is this an issue with GIT or p4merge? i think GIT should warn or error out that there are other conflicting lines that file. but it just commits.

    1. Merge specific file in GIT

    The other question i have is is there a command so that i can send a developer to merge a certain file? When i run git mergetool it opens all merge conflict one by one, instead is there a way like clearcase where i can say merge this selected file?

  • How can I unit test a PHP class method that executes a command-line program?
  • Git confusion - how to revert local changes to latest remote push?
  • How to change a past git commit+push message in RubyMine?
  • Difference between 'git push -f' and 'deleting remote branch and push again'
  • Can I place .git somewhere else?
  • Rails why use capistrano when you have git post-receive hook?
  • One Solution collect form web for “GIT 2 or more merge conflicts in a single file – how p4merge handles?”

    1. My guess: when you save file in p4merge, it happilly return with code 0, file is changed, and git assumes that conflicts were resolved. There is a config parameter mergetool.<tool>.trustExitCode (mergetool.p4merge.trustExitCode in your case), which can be set to false, so git will always ask you if merge was successfull after running git mergetool (which can be quite annoying). You also might be able to write a wrapper for p4merge which will check presence of conflict markers after running p4mege, or pre-commit hook, which rejects commits containing files containing such markers, though I’ve never done something like that.

    2. Yes, you can run git mergetool <file> to resolve specified file. Learn more here.

    Git Baby is a git and github fan, let's start git clone.