From 6be4a1f218337f31e89e8aad27c30f3bd8fabefa Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Sat, 21 Sep 2024 12:24:21 -0700 Subject: [PATCH] Add diagnostics (#367) --- src/scripts/merge_tools/gitmerge.sh | 18 ++++++++++- .../merge_tools/merge_git_then_plumelib.sh | 32 +++++++++++++++++++ .../merge_tools/merge_script_then_plumelib.sh | 32 +++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/scripts/merge_tools/gitmerge.sh b/src/scripts/merge_tools/gitmerge.sh index ce27cc1161..bf373243f9 100755 --- a/src/scripts/merge_tools/gitmerge.sh +++ b/src/scripts/merge_tools/gitmerge.sh @@ -19,19 +19,35 @@ branch1=$2 branch2=$3 git_strategy=$4 +VERBOSE= +## Enable for debugging +# VERBOSE=YES + + ## Perform merge cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir"; exit 2; } +if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git checkout $branch1 in $(pwd)" +fi git checkout "$branch1" --force +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git checkout $branch1 in $(pwd)" +fi git config --local merge.conflictstyle diff3 git config --local mergetool.prompt false -echo "Running: git merge --no-edit $git_strategy $branch2" +echo "$0: about to run: git merge --no-edit $git_strategy $branch2 in $(pwd)" + # shellcheck disable=SC2086 git merge --no-edit $git_strategy "$branch2" retVal=$? +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git merge --no-edit $git_strategy $branch2 in $(pwd)" +fi + # report conflicts if [ $retVal -ne 0 ]; then echo "gitmerge.sh: Conflict after running: git merge --no-edit $git_strategy $branch2" diff --git a/src/scripts/merge_tools/merge_git_then_plumelib.sh b/src/scripts/merge_tools/merge_git_then_plumelib.sh index c06a827be3..329997dad3 100755 --- a/src/scripts/merge_tools/merge_git_then_plumelib.sh +++ b/src/scripts/merge_tools/merge_git_then_plumelib.sh @@ -19,19 +19,38 @@ branch2=$3 git_strategy=$4 #"-Xignore-space-change" plumelib_strategy=$5 #"--only-adjacent" +VERBOSE= +## Enable for debugging +# VERBOSE=YES + + ## Perform merge echo "$0: Merging $branch1 and $branch2 with git_strategy=$git_strategy and plumelib_strategy=$plumelib_strategy" cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir"; exit 2; } +if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git checkout $branch1 in $(pwd)" +fi git checkout "$branch1" --force +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git checkout $branch1 in $(pwd)" +fi git config --local merge.conflictstyle diff3 git config --local mergetool.prompt false +if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git merge --no-edit $git_strategy $branch2 in $(pwd)" +fi + # shellcheck disable=SC2086 git merge --no-edit $git_strategy "$branch2" +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git merge --no-edit $git_strategy $branch2 in $(pwd)" +fi + ## Now, run Plume-lib Merging to improve the result of `git merge`. git config --local merge.tool merge-plumelib @@ -50,15 +69,28 @@ case "$plumelib_strategy" in ;; esac +if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)" +fi git-mergetool.sh $all_arg --tool=merge-plumelib +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)" +fi # Check if there are still conflicts diffs=$(git diff --name-only --diff-filter=U) if [ -z "$diffs" ]; then git add . + if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git commit in $(pwd)" + fi git commit -m "Resolved conflicts by calling: git-mergetool.sh $all_arg --tool=merge-plumelib" + if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git commit in $(pwd)" + fi exit 0 fi +echo "$0: exiting with status 1" echo "$0: diffs=$diffs" echo "$0: Conflict after running in $(pwd):" echo " git merge --no-edit $git_strategy $branch2" diff --git a/src/scripts/merge_tools/merge_script_then_plumelib.sh b/src/scripts/merge_tools/merge_script_then_plumelib.sh index f2fa314512..0c03e8f22f 100755 --- a/src/scripts/merge_tools/merge_script_then_plumelib.sh +++ b/src/scripts/merge_tools/merge_script_then_plumelib.sh @@ -20,19 +20,38 @@ branch2=$3 merge_script=$4 #"-Xignore-space-change" plumelib_strategy=$5 #"--only-adjacent" +VERBOSE= +## Enable for debugging +# VERBOSE=YES + + ## Perform merge echo "$0: Merging $branch1 and $branch2 with merge_script=$merge_script and plumelib_strategy=$plumelib_strategy" cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir"; exit 2; } +if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git checkout $branch1 in $(pwd)" +fi git checkout "$branch1" --force +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git checkout $branch1 in $(pwd)" +fi git config --local merge.conflictstyle diff3 git config --local mergetool.prompt false +if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: $merge_script $clone_dir $branch1 $branch2 in $(pwd)" +fi + # shellcheck disable=SC2086 $merge_script "$clone_dir" "$branch1" "$branch2" +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: $merge_script $clone_dir $branch1 $branch2 in $(pwd)" +fi + ## Now, run Plume-lib Merging to improve the result of `$merge_script`. git config --local merge.tool merge-plumelib @@ -51,15 +70,28 @@ case "$plumelib_strategy" in ;; esac +if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)" +fi git-mergetool.sh $all_arg --tool=merge-plumelib +if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)" +fi # Check if there are still conflicts diffs=$(git diff --name-only --diff-filter=U) if [ -z "$diffs" ]; then git add . + if [ -n "$VERBOSE" ] ; then + echo "$0: about to run: git commit in $(pwd)" + fi git commit -m "Resolved conflicts by calling: git-mergetool.sh $all_arg --tool=merge-plumelib" + if [ -n "$VERBOSE" ] ; then + echo "$0: ran: git commit in $(pwd)" + fi exit 0 fi +echo "$0: exiting with status 1" echo "$0: diffs=$diffs" echo "$0: Conflict after running in $(pwd):" echo " $merge_script $clone_dir $branch1 $branch2"