diff --git a/Makefile b/Makefile index b3ddc25880..cecedbd5e5 100644 --- a/Makefile +++ b/Makefile @@ -166,8 +166,7 @@ check-merges-reproducibility: echo "Running replay_merge for idx $$idx"; \ src/python/replay_merge.py --testing --merges_csv $(CSV_RESULTS) -skip_build -delete_workdir --idx $$idx || FAILED_IDXES="$$FAILED_IDXES $$idx"; \ done; \ - echo "$$FAILED_IDXES"; \ - test -z "$$FAILED_IDXES" + test -z "$$FAILED_IDXES" || { echo "Failed indexes = $$FAILED_IDXES"; false; } protect-repos: find repos -mindepth 1 -type d -exec chmod a-w {} + diff --git a/README.md b/README.md index f7887f805e..01415643a4 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,14 @@ If `make small-test` fails in a branch that you wish to merge into the main branch, run `make small-test` in the main branch (which should succeed) and also in your branch, and investigate the differences. +#### Updating the goal files + +If you make a change to the mergers that changes merge results, you need to +update the goal files or else reproducibility checks will fail. +Copy certain files from `results/small/` to `test/small-goal-files/`. + +To update the reproducibility tests, run `make run-all`. + ### Load the stored cache To decompress the cache run `make decompress-cache`. This is done automatically in `run_combined.sh` if `cache/` does not exist. @@ -238,6 +246,8 @@ To investigate differences between two mergers: * Set `DELETE_WORKDIRS` to `false` in `src/python/variables.py`. * run `src/python/replay_merge.py --idx INDEX` (maybe add `-test`) for the index of the merge you are interested in. +If the merge is in the small test, you may need to add `--merges_csv ./test/small-goal-files/result.csv`. + ## Overwriting results manually In some cases it might be worth to overwrite the computed results. To do that you should modify the `results/manual_override.csv` file. In that file for the merge you want to overwrite a result of you should include at least the information `repository,merge,left,right` and a new column for the result you want to overwrite. You can overwrite anything you want but if there is a column you don't want to overwrite either do not include that column or leave the entry blanck i.e. `,,`. See the file for an example. diff --git a/run.sh b/run.sh index ec7bf82c64..1732764d59 100755 --- a/run.sh +++ b/run.sh @@ -129,7 +129,7 @@ fi cd ./src/scripts/merge_tools/merging export JAVA_HOME=$JAVA17_HOME export PATH="$JAVA_HOME/bin:$PATH" - ./gradlew shadowJar + ./gradlew -q nativeCompile ) echo "Machine ID: $machine_id" diff --git a/src/python/replay_merge.py b/src/python/replay_merge.py index 321472e87e..d7a12b6b96 100755 --- a/src/python/replay_merge.py +++ b/src/python/replay_merge.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """Replay merges and their test results. -The output appears in the .workdirs/ directory. +The output appears in the `.workdirs`/ directory. +Logs appear in the `replay_logs/merges/` directory. Command-line arguments are listed just after the line: if __name__ == "__main__": @@ -268,11 +269,11 @@ def merge_replay( stderr=subprocess.PIPE, ) if len(process.stderr.decode("utf-8")) == 0: - conflict_files = process.stdout.decode("utf-8") - is_conflict = len(conflict_files) > 0 + git_conflict_files = process.stdout.decode("utf-8") + is_conflict = len(git_conflict_files) > 0 assert ( is_conflict == (merge_result == MERGE_STATE.Merge_failed) - ), f"merge_replay: tool{merge_tool} merge_result {merge_result} does not match conflict_files {conflict_files} at path {repo.local_repo_path}" + ), f"merge_replay: tool merge result is inconsistent with `git diff --diff-filter=U`: tool={merge_tool} merge_result={merge_result} git_conflict_files={git_conflict_files} path={repo.local_repo_path}" result_df.loc[ merge_tool.name, @@ -308,10 +309,11 @@ def merge_replay( store_artifacts(result_df) if delete_workdir: delete_workdirs(result_df) - print("=====================================\n") + print("fingerprints differ; details follow.") + print(f"=================== start of {log_path}:") with open(log_path, "r", encoding="utf-8") as f: print(f.read()) - print("=====================================\n") + print(f"=================== end of {log_path}.") raise Exception( f"fingerprints differ: after merge of {workdir} with {merge_tool}, found" + f" {merge_fingerprint} but expected " diff --git a/src/python/repo.py b/src/python/repo.py index 1289b28223..e50b95c422 100755 --- a/src/python/repo.py +++ b/src/python/repo.py @@ -152,11 +152,20 @@ def stdout_and_stderr( source: Union[subprocess.TimeoutExpired, subprocess.CompletedProcess], ) -> str: """Produces the standard output and standard error of a timedout process.""" - explanation = "Run Command: " + " ".join(command) + "\nTimed out" + explanation = "Here is the output from: " + " ".join(command) if source.stdout: - explanation += "\nstdout:\n" + source.stdout.decode("utf-8", "replace") + explanation += ( + "\nstdout:\n" + + source.stdout.decode("utf-8", "replace") + + "\nEnd of stdout." + ) if source.stderr: - explanation += "\nstderr:\n" + source.stderr.decode("utf-8", "replace") + explanation += ( + "\nstderr:\n" + + source.stderr.decode("utf-8", "replace") + + "\nEnd of stderr." + ) + explanation += "\nEnd of output from: " + " ".join(command) return explanation @@ -549,13 +558,18 @@ def merge( str(timeout), f"src/scripts/merge_tools/{tool.name}.sh {self.local_repo_path.resolve()} {LEFT_BRANCH_NAME} {RIGHT_BRANCH_NAME}", ] + logger.debug( + f"merge: Merging {self.repo_slug} {left_commit} {right_commit} with {tool.name}" + ) p = subprocess.run( command, capture_output=True, check=False, ) + std_streams = stdout_and_stderr(command, p) + logger.debug(std_streams) if p.returncode == 124: # Timeout - explanation = explanation + "\n" + stdout_and_stderr(command, p) + explanation = explanation + "\n" + std_streams if use_cache: cache_entry["merge status"] = MERGE_STATE.Merge_timedout.name cache_entry["explanation"] = explanation @@ -574,7 +588,7 @@ def merge( -1, ) run_time = time.time() - start_time - explanation = explanation + "\n" + stdout_and_stderr(command, p) + explanation = explanation + "\n" + std_streams merge_status = ( MERGE_STATE.Merge_success if p.returncode == 0 else MERGE_STATE.Merge_failed ) diff --git a/src/scripts/merge_tools/adjacent.sh b/src/scripts/merge_tools/adjacent.sh index a66d6eff43..116661bb3b 100755 --- a/src/scripts/merge_tools/adjacent.sh +++ b/src/scripts/merge_tools/adjacent.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./adjacent.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/adjacent_ignorespace.sh b/src/scripts/merge_tools/adjacent_ignorespace.sh index 0baf960fc1..947334cc5c 100755 --- a/src/scripts/merge_tools/adjacent_ignorespace.sh +++ b/src/scripts/merge_tools/adjacent_ignorespace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./adjacent_ignorespace.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/adjacent_plus.sh b/src/scripts/merge_tools/adjacent_plus.sh index adb0478df2..f246994a9d 100755 --- a/src/scripts/merge_tools/adjacent_plus.sh +++ b/src/scripts/merge_tools/adjacent_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./adjacent.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/git_hires_merge.sh b/src/scripts/merge_tools/git_hires_merge.sh index ef1795eb9c..e15431ee96 100755 --- a/src/scripts/merge_tools/git_hires_merge.sh +++ b/src/scripts/merge_tools/git_hires_merge.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./git_hires_merge.sh +# usage: set -o nounset @@ -13,8 +13,10 @@ clone_dir=$1 branch1=$2 branch2=$3 +SCRIPTDIR="$(cd "$(dirname "$0")" && pwd -P)" + # Print the current PATH -echo "PATH: $PATH" +echo "$0 PATH: $PATH" cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir from $(pwd)"; exit 2; } @@ -25,7 +27,7 @@ attributes_file=".git/info/attributes" echo "* merge=git-hires-merge" >> "$attributes_file" git config --local merge.git-hires-merge.name "An interactive merge driver for resolving conflicts on individual or adjacent lines" -git config --local merge.git-hires-merge.driver "git-hires-merge %O %A %B %L %P" +git config --local merge.git-hires-merge.driver "${SCRIPTDIR}/git-hires-merge %O %A %B %L %P" git config --local merge.git-hires-merge.recursive "binary" git config --local merge.conflictstyle diff3 diff --git a/src/scripts/merge_tools/git_hires_merge_plus.sh b/src/scripts/merge_tools/git_hires_merge_plus.sh index 38f01be17a..ed8ed5b86d 100755 --- a/src/scripts/merge_tools/git_hires_merge_plus.sh +++ b/src/scripts/merge_tools/git_hires_merge_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./git_hires_merge_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 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/gitmerge_ort.sh b/src/scripts/merge_tools/gitmerge_ort.sh index 2f74883e68..8d736ef802 100755 --- a/src/scripts/merge_tools/gitmerge_ort.sh +++ b/src/scripts/merge_tools/gitmerge_ort.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_ort.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh b/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh index 70b6ab3f80..5b58d1679c 100755 --- a/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh +++ b/src/scripts/merge_tools/gitmerge_ort_ignorespace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_ort_ignorespace.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_histogram.sh b/src/scripts/merge_tools/gitmerge_recursive_histogram.sh index e7a8677144..2d6acab8d5 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_histogram.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_histogram.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_histogram.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_histogram_plus.sh b/src/scripts/merge_tools/gitmerge_recursive_histogram_plus.sh index 0ecfb0d6b3..aaf9c13609 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_histogram_plus.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_histogram_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_histogram_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh b/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh index ac78d10e16..1d735e8362 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_ignorespace.sh +# usage: MERGE_DIR="$(dirname "$0")" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_ignorespace_plus.sh b/src/scripts/merge_tools/gitmerge_recursive_ignorespace_plus.sh index a49b82bc12..e9bdd0e77f 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_ignorespace_plus.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_ignorespace_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_ignorespace_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_minimal.sh b/src/scripts/merge_tools/gitmerge_recursive_minimal.sh index e1a4f4f4db..6efc432059 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_minimal.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_minimal.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_minimal.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_minimal_plus.sh b/src/scripts/merge_tools/gitmerge_recursive_minimal_plus.sh index f9457f945d..c8151126c6 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_minimal_plus.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_minimal_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_minimal_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_myers.sh b/src/scripts/merge_tools/gitmerge_recursive_myers.sh index 07c5c06328..dd0c432487 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_myers.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_myers.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_myers.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_myers_plus.sh b/src/scripts/merge_tools/gitmerge_recursive_myers_plus.sh index 712c3c0c76..dea5c5dac0 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_myers_plus.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_myers_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_myers_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_patience.sh b/src/scripts/merge_tools/gitmerge_recursive_patience.sh index 5a4e0782d8..f5fe3f76ee 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_patience.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_patience.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_patience.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_recursive_patience_plus.sh b/src/scripts/merge_tools/gitmerge_recursive_patience_plus.sh index de31d1d26c..51b28505b2 100755 --- a/src/scripts/merge_tools/gitmerge_recursive_patience_plus.sh +++ b/src/scripts/merge_tools/gitmerge_recursive_patience_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_recursive_patience_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_resolve.sh b/src/scripts/merge_tools/gitmerge_resolve.sh index 3287584a16..56bf5db8d9 100755 --- a/src/scripts/merge_tools/gitmerge_resolve.sh +++ b/src/scripts/merge_tools/gitmerge_resolve.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# usage: ./gitmerge_resolve.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/gitmerge_resolve_plus.sh b/src/scripts/merge_tools/gitmerge_resolve_plus.sh index f910795811..e78198a189 100755 --- a/src/scripts/merge_tools/gitmerge_resolve_plus.sh +++ b/src/scripts/merge_tools/gitmerge_resolve_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./gitmerge_resolve_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/imports.sh b/src/scripts/merge_tools/imports.sh index 74808cffac..4850621e23 100755 --- a/src/scripts/merge_tools/imports.sh +++ b/src/scripts/merge_tools/imports.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./imports.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/imports_ignorespace.sh b/src/scripts/merge_tools/imports_ignorespace.sh index 5ab81c26b4..c263ca4829 100755 --- a/src/scripts/merge_tools/imports_ignorespace.sh +++ b/src/scripts/merge_tools/imports_ignorespace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./imports_ignorespace.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/intellimerge.sh b/src/scripts/merge_tools/intellimerge.sh index 3ddd822427..5641d4f16a 100755 --- a/src/scripts/merge_tools/intellimerge.sh +++ b/src/scripts/merge_tools/intellimerge.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./intellimerge.sh +# usage: # must contain a clone of a repository. # Merges branch2 into branch1, in . # Return code is 0 for merge success, 1 for merge failure, 2 for script failure. @@ -44,13 +44,13 @@ git checkout "$branch1" --force git merge --no-edit "$branch2" # List conflicitng files -conflict_files=$(git diff --name-only --diff-filter=U) +git_conflict_files=$(git diff --name-only --diff-filter=U) # Initialize a flag to track conflict resolution conflicts_resolved=true # Iterate through conflicting files -for file in $conflict_files; do +for file in $git_conflict_files; do # Check if the conflicting file exists in the temp_out_dir if [ ! -f "$temp_out_dir$file" ]; then echo "Conflict not resolved for file: $file" @@ -62,7 +62,7 @@ done if [ "$conflicts_resolved" = false ]; then echo "Conflict detected. Aborting the merge. Please resolve the conflicts." echo "All conflicting files:" - echo "$conflict_files" + echo "$git_conflict_files" rm -rf $temp_out_dir $temp_intellimerge_dir exit 1 fi diff --git a/src/scripts/merge_tools/intellimerge_plus.sh b/src/scripts/merge_tools/intellimerge_plus.sh index bccff7d4fd..044e290166 100755 --- a/src/scripts/merge_tools/intellimerge_plus.sh +++ b/src/scripts/merge_tools/intellimerge_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./intellimerge_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/ivn.sh b/src/scripts/merge_tools/ivn.sh index 162976a74f..15a395c7a0 100755 --- a/src/scripts/merge_tools/ivn.sh +++ b/src/scripts/merge_tools/ivn.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./ivn.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/ivn_ignorespace.sh b/src/scripts/merge_tools/ivn_ignorespace.sh index e6d4d5aa31..af3a3009f4 100755 --- a/src/scripts/merge_tools/ivn_ignorespace.sh +++ b/src/scripts/merge_tools/ivn_ignorespace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./ivn_ignorespace.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/merge_git_then_plumelib.sh b/src/scripts/merge_tools/merge_git_then_plumelib.sh index c06a827be3..abe746fc20 100755 --- a/src/scripts/merge_tools/merge_git_then_plumelib.sh +++ b/src/scripts/merge_tools/merge_git_then_plumelib.sh @@ -19,24 +19,45 @@ branch2=$3 git_strategy=$4 #"-Xignore-space-change" plumelib_strategy=$5 #"--only-adjacent" +SCRIPTDIR="$(cd "$(dirname "$0")" && pwd -P)" + +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 # shellcheck disable=SC2016 -git config --local mergetool.merge-plumelib.cmd 'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' +git config --local mergetool.merge-plumelib.cmd "$SCRIPTDIR"/'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' git config --local mergetool.merge-plumelib.trustExitCode true case "$plumelib_strategy" in @@ -50,15 +71,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) +diffs=$(git diff --name-only --diff-filter=U | sort) 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..b63d643fb5 100755 --- a/src/scripts/merge_tools/merge_script_then_plumelib.sh +++ b/src/scripts/merge_tools/merge_script_then_plumelib.sh @@ -20,24 +20,45 @@ branch2=$3 merge_script=$4 #"-Xignore-space-change" plumelib_strategy=$5 #"--only-adjacent" +SCRIPTDIR="$(cd "$(dirname "$0")" && pwd -P)" + +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 # shellcheck disable=SC2016 -git config --local mergetool.merge-plumelib.cmd 'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' +git config --local mergetool.merge-plumelib.cmd "$SCRIPTDIR"/'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' git config --local mergetool.merge-plumelib.trustExitCode true case "$plumelib_strategy" in @@ -51,15 +72,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) +diffs=$(git diff --name-only --diff-filter=U | sort) 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" diff --git a/src/scripts/merge_tools/spork.sh b/src/scripts/merge_tools/spork.sh index 595cee1473..fcc7386d24 100755 --- a/src/scripts/merge_tools/spork.sh +++ b/src/scripts/merge_tools/spork.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./spork.sh +# usage: # must contain a clone of a repository. # Merges branch2 into branch1, in . # Return code is 0 for merge success, 1 for merge failure, 2 for script failure. diff --git a/src/scripts/merge_tools/spork_plus.sh b/src/scripts/merge_tools/spork_plus.sh index 44f67a1046..12633ade4f 100755 --- a/src/scripts/merge_tools/spork_plus.sh +++ b/src/scripts/merge_tools/spork_plus.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./spork_plus.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/version_numbers.sh b/src/scripts/merge_tools/version_numbers.sh index 9eb28511a9..1166b146cd 100755 --- a/src/scripts/merge_tools/version_numbers.sh +++ b/src/scripts/merge_tools/version_numbers.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./version_numbers.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1 diff --git a/src/scripts/merge_tools/version_numbers_ignorespace.sh b/src/scripts/merge_tools/version_numbers_ignorespace.sh index c902f8e03a..9fca1f26ed 100755 --- a/src/scripts/merge_tools/version_numbers_ignorespace.sh +++ b/src/scripts/merge_tools/version_numbers_ignorespace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# usage: ./version_numbers_ignorespace.sh +# usage: MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)" clone_dir=$1