diff --git a/snowblocks/git/gitconfig b/snowblocks/git/gitconfig index 43b36a1..c8dbbff 100755 --- a/snowblocks/git/gitconfig +++ b/snowblocks/git/gitconfig @@ -503,3 +503,10 @@ # Usage: # git ft ft = ! git describe --tags --contains $1 + +# NOTE: The following "include" statements/blocks must be applied last in order to override their initial +# blocks above, otherwise the configurations won't be overridden when placed at the top of this file! + +# Apply workaround to fix exit code handling for IntelliJ as merge tool when running on macOS. +[include] + path = ~/.gitconfig-macos-mergetool-exit-code diff --git a/snowblocks/git/includes/gitconfig-macos-mergetool-exit-code b/snowblocks/git/includes/gitconfig-macos-mergetool-exit-code new file mode 100644 index 0000000..eaf2d53 --- /dev/null +++ b/snowblocks/git/includes/gitconfig-macos-mergetool-exit-code @@ -0,0 +1,36 @@ +# Copyright (C) 2016-present Arctic Ice Studio +# Copyright (C) 2016-present Sven Greb + +# Project: igloo +# Repository: https://github.com/arcticicestudio/igloo +# License: MIT +# References: +# https://git-scm.com/docs/git-mergetool + +# When using IntelliJ as `mergetool` and setting `mergetool.intellij.trustExitCode` to `true`, +# the `mergetool.intellij.cmd` gets called for all files immediately. +# After IntelliJ gets closed for the first processed file, all other calls will error because +# the temporary files passed to `idea merge`as parameters are not valid anymore causing the app +# to exit. +# +# The problem is that Git is not able to interpret or track started IntelliJ process and fails +# to listen for the exit code, causing the calls to be fired immediately. +# This problem can be narrowed down to macOS while it works fine for Linux systems. +# See https://git-scm.com/docs/git-mergetool for more details. +# +# To fix the problem `trustExitCode` option is set to `false` an `prompt` to `true` to force Git +# to wait for the user to confirm the merge is completed and the app window has been closed before +# continuing with the next queued file. +# The only impact is that it requires to press `y` or `n` after solving a conflict instead of only +# closing the app window and waiting for it to reopen again for the next file. +# This is also limited to macOS so the impact is very small compared to the broken state when not +# applying the fix. +# +# In order to dynamically apply the configuration file only for macOS systems , this file is loaded +# through a `[include]` block in the main Git configuration file and only linked by "snowsaw" for +# macOS based hosts. +# +# See https://github.com/arcticicestudio/igloo/issues/206 for more details. +[mergetool "intellij"] + prompt = true + trustExitCode = false diff --git a/snowblocks/git/snowblock.json b/snowblocks/git/snowblock.json index 9a802a7..12c5fc6 100644 --- a/snowblocks/git/snowblock.json +++ b/snowblocks/git/snowblock.json @@ -30,7 +30,12 @@ "igloo": "gitconfig-auth-job.igloocrypt" } }, - "~/.gitignore": null + "~/.gitignore": null, + "~/.gitconfig-macos-mergetool-exit-code": { + "hosts": { + "iceowl": "includes/gitconfig-macos-mergetool-exit-code" + } + } } } ]