Skip to content

Commit

Permalink
Add diagnostics (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Sep 21, 2024
1 parent 2635b2a commit 6be4a1f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/scripts/merge_tools/gitmerge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
32 changes: 32 additions & 0 deletions src/scripts/merge_tools/merge_git_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
32 changes: 32 additions & 0 deletions src/scripts/merge_tools/merge_script_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 6be4a1f

Please sign in to comment.