Created
June 24, 2016 22:28
-
-
Save mmastrac/dc6362447b9cb6585beed7b4f9879f97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[merge "clang_format"] | |
name = clang-format merge driver | |
driver = /tmp/merge_driver.sh %O %A %B %L %P | |
recursive = binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.cpp merge=clang_format | |
*.h merge=clang_format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE="$1" | |
OURS="$2" | |
OTHERS="$3" | |
PATH_FYI="$5" | |
clang-format -i -style=file "$BASE" | |
clang-format -i -style=file "$OURS" | |
clang-format -i -style=file "$OTHERS" | |
echo "clang-format merge driver. Merging $PATH_FYI" | |
echo git merge-file -p "1:$OURS" "2:$BASE" "3:$OTHERS" \> "$OURS.tmp" | |
git merge-file -p "$OURS" "$BASE" "$OTHERS" --theirs > "$OURS.tmp" | |
clang-format -i -style=file "$OURS.tmp" # one last format | |
RET=$? | |
mv "$OURS.tmp" "$OURS" | |
exit $RET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
YOU SHOULD REMOVE THIS DRIVER AFTER REBASING YOUR PR!
First, rebase to the commit before everything goes to hell:
git rebase -i 2115e8a4a6814e32107b5205ff5c95bbd3c6e99c
Then, install the merge_driver and rebase to master, fixing any conflicts:
git rebase -i master
Finally, run a pass overtop of everything to reformat anything that didn't conflict:
git rebase -i master --exec "git reset --soft HEAD~ && git clang-format --style file && git commit -a -C ORIG_HEAD"