-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
24 additions
and
24 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
#!/usr/bin/env sh | ||
|
||
# usage: ./gitmerge.sh <clone_dir> <branch-1> <branch-2> <strategy> | ||
# usage: ./gitmerge.sh <clone_dir> <branch-1> <branch-2> <git_strategy> | ||
# <clone_dir> must contain a clone of a repository. | ||
# <strategy> is arguments to `git merge`, including -s and possibly -X. | ||
# Merges branch2 into branch1, in <clone_dir>, using merge strategy <strategy>. | ||
# <git_strategy> is arguments to `git merge`, including -s and possibly -X. | ||
# Merges branch2 into branch1, in <clone_dir>, using merge strategy <git_strategy>. | ||
# Return code is 0 for merge success, 1 for merge failure. | ||
# For merge failure, also outputs "Conflict" and aborts the merge. | ||
|
||
set -o nounset | ||
|
||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2 STRATEGY" >&2 | ||
echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2 GIT_STRATEGY" >&2 | ||
exit 1 | ||
fi | ||
|
||
clone_dir=$1 | ||
branch1=$2 | ||
branch2=$3 | ||
strategy=$4 | ||
git_strategy=$4 | ||
|
||
# perform merge | ||
cd "$clone_dir" || (echo "$0: cannot cd to $clone_dir" ; exit 1) | ||
|
||
git checkout "$branch1" --force | ||
git config merge.conflictstyle zdiff3 | ||
|
||
echo "Running: git merge --no-edit $strategy $branch2" | ||
echo "Running: git merge --no-edit $git_strategy $branch2" | ||
# shellcheck disable=SC2086 | ||
git merge --no-edit $strategy "$branch2" | ||
git merge --no-edit $git_strategy "$branch2" | ||
retVal=$? | ||
|
||
# report conflicts | ||
if [ $retVal -ne 0 ]; then | ||
echo "gitmerge.sh: Conflict after running: git merge --no-edit $strategy $branch2" | ||
echo "gitmerge.sh: Conflict after running: git merge --no-edit $git_strategy $branch2" | ||
fi | ||
|
||
exit $retVal |
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
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
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
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
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
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
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
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