diff --git a/src/scripts/merge_tools/gitmerge.sh b/src/scripts/merge_tools/gitmerge.sh index bbf3e293f2..1c2032d58a 100755 --- a/src/scripts/merge_tools/gitmerge.sh +++ b/src/scripts/merge_tools/gitmerge.sh @@ -1,19 +1,16 @@ #!/usr/bin/env sh -# usage: ./gitmerge.sh [no-git-merge-abort] +# usage: ./gitmerge.sh # must contain a clone of a repository. # is arguments to `git merge`, including -s and possibly -X. # Merges branch2 into branch1, in , using merge strategy . -# For merge success, return code is 0. -# For merge failure: -# * return code is 1. -# * outputs "Conflict" and aborts the merge, -# unless a non-empty 5th command-line argument is provided. +# 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 ] && [ "$#" -ne 5 ]; then - echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2 STRATEGY [no-git-merge-abort]" >&2 +if [ "$#" -ne 4 ]; then + echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2 STRATEGY" >&2 exit 1 fi @@ -21,8 +18,6 @@ clone_dir=$1 branch1=$2 branch2=$3 strategy=$4 -# If this variable is non-empty, don't output "Conflict" or run `git merge --abort`. -no_git_merge_abort=$5 # perform merge cd "$clone_dir" || exit 1 @@ -34,10 +29,8 @@ retVal=$? # report conflicts if [ $retVal -ne 0 ]; then - if [ -z "$no_git_merge_abort" ] ; then - echo "Conflict" - git merge --abort - fi + echo "Conflict" + git merge --abort fi exit $retVal diff --git a/src/scripts/merge_tools/gitmerge_ort.sh b/src/scripts/merge_tools/gitmerge_ort.sh index d8a695734b..5870c56a91 100755 --- a/src/scripts/merge_tools/gitmerge_ort.sh +++ b/src/scripts/merge_tools/gitmerge_ort.sh @@ -8,3 +8,6 @@ branch1=$2 branch2=$3 strategy="-s ort" "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -ne 0 ] ; then + exit 1 +fi diff --git a/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh b/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh index ef1a5df5f8..53805e7418 100755 --- a/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh +++ b/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh @@ -8,3 +8,6 @@ branch1=$2 branch2=$3 strategy="-s ort -Xignore-space-change" "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -ne 0 ] ; then + exit 1 +fi diff --git a/src/scripts/merge_tools/gitmerge_ort_imports.sh b/src/scripts/merge_tools/gitmerge_ort_imports.sh index 87bfb15c05..b9ba8315f2 100755 --- a/src/scripts/merge_tools/gitmerge_ort_imports.sh +++ b/src/scripts/merge_tools/gitmerge_ort_imports.sh @@ -7,8 +7,14 @@ clone_dir=$1 branch1=$2 branch2=$3 strategy="-s ort" -if "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" "no-git-merge-abort" ; then - exit +"$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -e 0 ] ; then + exit 0 +fi + +cd "$clone_dir" +"$MERGE_SCRIPTS_DIR"/resolve-import-conflicts +if [ $? -ne 0 ] ; then + exit 1 fi -(cd "$clone_dir" && "$MERGE_SCRIPTS_DIR"/resolve-import-conflicts) diff --git a/src/scripts/merge_tools/gitmerge_ort_imports_ignorespace.sh b/src/scripts/merge_tools/gitmerge_ort_imports_ignorespace.sh index 5151e81037..d8118fa3e3 100755 --- a/src/scripts/merge_tools/gitmerge_ort_imports_ignorespace.sh +++ b/src/scripts/merge_tools/gitmerge_ort_imports_ignorespace.sh @@ -7,8 +7,13 @@ clone_dir=$1 branch1=$2 branch2=$3 strategy="-s ort -Xignore-space-change" -if "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" "no-git-merge-abort" ; then - exit +"$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -e 0 ] ; then + exit 0 fi -(cd "$clone_dir" && "$MERGE_SCRIPTS_DIR"/resolve-import-conflicts) +cd "$clone_dir" +"$MERGE_SCRIPTS_DIR"/resolve-import-conflicts +if [ $? -ne 0 ] ; then + exit 1 +fi diff --git a/src/scripts/merge_tools/gitmerge_recursive_histogram.sh b/src/scripts/merge_tools/gitmerge_recursive_histogram.sh index 6453c6e00e..afddba1160 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_histogram.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_histogram.sh @@ -8,3 +8,6 @@ branch1=$2 branch2=$3 strategy="-s recursive -Xdiff-algorithm=histogram" "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -ne 0 ] ; then + exit 1 +fi diff --git a/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh b/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh index 812d2dcd18..44de249969 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh @@ -8,3 +8,6 @@ branch1=$2 branch2=$3 strategy="-s recursive -Xignore-space-change" "$MERGE_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -ne 0 ] ; then + exit 1 +fi diff --git a/src/scripts/merge_tools/gitmerge_recursive_minimal.sh b/src/scripts/merge_tools/gitmerge_recursive_minimal.sh index e7d916539a..7cf08a7dc3 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_minimal.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_minimal.sh @@ -8,3 +8,6 @@ branch1=$2 branch2=$3 strategy="-s recursive -Xdiff-algorithm=minimal" "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -ne 0 ] ; then + exit 1 +fi diff --git a/src/scripts/merge_tools/gitmerge_recursive_myers.sh b/src/scripts/merge_tools/gitmerge_recursive_myers.sh index f95f093ba7..035864ba4c 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_myers.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_myers.sh @@ -8,3 +8,6 @@ branch1=$2 branch2=$3 strategy="-s recursive -Xdiff-algorithm=myers" "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -ne 0 ] ; then + exit 1 +fi diff --git a/src/scripts/merge_tools/gitmerge_recursive_patience.sh b/src/scripts/merge_tools/gitmerge_recursive_patience.sh index 77e5a8e449..619c0830a9 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_patience.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_patience.sh @@ -8,3 +8,6 @@ branch1=$2 branch2=$3 strategy="-s recursive -Xdiff-algorithm=patience" "$MERGE_SCRIPTS_DIR"/gitmerge.sh "$clone_dir" "$branch1" "$branch2" "$strategy" +if [ $? -ne 0 ] ; then + exit 1 +fi