4

I used react-native-git-upgrade to upgrade React Native on my project, the process left some conflict delimiters I have to solve now:

                DEAD_CODE_STRIPPING = NO;
<<<<<<< ours
            HEADER_SEARCH_PATHS = (
                "$(inherited)",
                /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
                "$(SRCROOT)/../node_modules/react-native/React/**",
                "$(SRCROOT)/../node_modules/react-native-vector-icons/RNVectorIconsManager",
                "$(SRCROOT)/../node_modules/react-native-video",
            );
            INFOPLIST_FILE = "MyAwesomeApp/Info.plist";
=======
                INFOPLIST_FILE = MyAwesomeApp/Info.plist;
>>>>>>> theirs
            LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
            OTHER_LDFLAGS = (
                "$(inherited)",
                "-ObjC",
                "-lc++",
            );

But these conflicts are not seen by Git: git status doesn't show any "Unmerged paths". And git mergetool fails with the message "No files need merging"

So I had to figure them out manually by removing/keeping lines. Is there a way to use a Git merge tool here ?

Sid
  • 4,893
  • 14
  • 55
  • 110
ncuillery
  • 14,308
  • 2
  • 22
  • 31

2 Answers2

5

react-native-git-upgrade is non-intrusive and creates a temporary Git repository instead of using the existing one. So the files are seen conflicted by this temporary repository, not yours.

This temporary local Git repository is located in the system temp dir. You can read the path when running react-native-git-upgrade --verbose: enter image description here

If you want to be able to use a merge tool, you had to use the temporary repository. Use the env var to point out the Git repo inside this folder, just like react-native-git-upgrade does.

For a CLI merge tool:

$ GIT_DIR=/var/folders/vx/jg1x1gd532167rd6ts8y8d2dgp5w7m/T/react-native-git-upgrade/.gitrn git mergetool

Don't forget to append the repo directory named .gitrn !

Note that the path of the temporary directory is machine-specific, that's why you had to run react-native-git-upgrade --verbose first to get yours.

ncuillery
  • 14,308
  • 2
  • 22
  • 31
  • When I run the command with proper path, I get the following error ------------------------ This message is displayed because 'merge.tool' is not configured. See 'git mergetool --tool-help' or 'git help config' for more details. 'git mergetool' will now attempt to use one of the following tools: tortoisemerge emerge vimdiff No files need merging ------------------------ – rex Jan 12 '17 at 16:21
  • That's a general problem. See [this question](http://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git) about how to resolve merge conflicts. – ncuillery Jan 13 '17 at 16:29
0

I ran into the same mess after doing an upgrade. Then I found out that Visual Studio Code has an extension called GitLens which allows you to resolve merge conflicts regardless of the status of the repo.

mvandillen
  • 904
  • 10
  • 17