diff --git a/git-clone-related b/git-clone-related index 53d6a41..addd1da 100755 --- a/git-clone-related +++ b/git-clone-related @@ -40,7 +40,7 @@ # Do not attempt to add "--filter=blob:none" to the git command, as older git # clients (apparently including GitHub, as of 2024-01-27) do not support it. -# Fail if any command fails. +# Do not fail on error; this script handles errors explicitly. set +e if [ "$1" = "--debug" ]; then @@ -111,6 +111,7 @@ else for dir in "../plume-scripts" ".plume-scripts" "../.plume-scripts"; do if [ -d "${SCRIPT_DIR}/${dir}" ]; then PLUME_SCRIPTS="${SCRIPT_DIR}/${dir}" + break fi done if [ -z "$PLUME_SCRIPTS" ]; then diff --git a/resolve-adjacent-conflicts b/resolve-adjacent-conflicts index 0d7935b..081f0d2 100755 --- a/resolve-adjacent-conflicts +++ b/resolve-adjacent-conflicts @@ -1,9 +1,9 @@ #!/bin/bash # bash, not POSIX sh, because of "readarray". -echo "Please use the program in https://github.com/plume-lib/merging ." -echo "You are using $0," -echo "which is an obsolete version in https://github.com/plume-lib/git-scripts ." +echo "Please use the program in https://github.com/plume-lib/merging ." >&2 +echo "You are using $0," >&2 +echo "which is an obsolete version in https://github.com/plume-lib/git-scripts ." >&2 # This script edits files in place to resolve conflict markers due to edits on # adjacent lines. (This is like the behavior of SVN and darcs, but different diff --git a/resolve-conflicts.py b/resolve-conflicts.py index 3e5afd8..23ecaa0 100755 --- a/resolve-conflicts.py +++ b/resolve-conflicts.py @@ -25,7 +25,6 @@ from __future__ import annotations -import itertools import shutil import sys import tempfile @@ -64,13 +63,7 @@ def main() -> None: # pylint: disable=too-many-locals args = arg_parser.parse_args() filename = args.filename - num_options = 0 - if args.adjacent_lines: - num_options += 1 - if args.blank_lines: - num_options += 1 - if args.java_imports: - num_options += 1 + num_options = sum([args.adjacent_lines, args.blank_lines, args.java_imports]) if num_options != 1: print("resolve-conflicts.py: supply exactly one option.") sys.exit(1) @@ -268,11 +261,7 @@ def merge_edits_on_different_lines( result: list[str] | None = None if base_len == len(parent1) and base_len == len(parent2): result = [] - for base_line, parent1_line, parent2_line in itertools.zip_longest( - base, - parent1, - parent2, - ): + for base_line, parent1_line, parent2_line in zip(base, parent1, parent2, strict=True): debug_print("Considering line:", base_line, parent1_line, parent2_line) if parent1_line == parent2_line: result.append(parent1_line) @@ -395,10 +384,7 @@ def with_one_space(lines: list[str]) -> str: # TODO: This could be more efficient. Even better, I could write a loop in # merge_blank_lines that wouldn't need to create new strings at all. But this is # expedient to write and is probably fast enough. - result_lines = [] - for line in lines: - result_lines += line.split() - return " ".join(result_lines) + return " ".join(word for line in lines for word in line.split()) def debug_print(*args: object) -> None: diff --git a/resolve-import-conflicts b/resolve-import-conflicts index 7fadb5c..4691454 100755 --- a/resolve-import-conflicts +++ b/resolve-import-conflicts @@ -1,9 +1,9 @@ #!/bin/bash # bash, not POSIX sh, because of "readarray". -echo "Please use the program in https://github.com/plume-lib/merging ." -echo "You are using $0," -echo "which is an obsolete version in https://github.com/plume-lib/git-scripts ." +echo "Please use the program in https://github.com/plume-lib/merging ." >&2 +echo "You are using $0," >&2 +echo "which is an obsolete version in https://github.com/plume-lib/git-scripts ." >&2 # This script edits files in place to remove conflict markers related to Java # imports. For a given conflict that involves only `import` statements and