From f95e339c03703a87a4ec62274c98d710295f9f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Wed, 13 Sep 2023 13:02:06 +0800 Subject: [PATCH] git-cp: continue to merge when merge.ff is only (#1070) Signed-off-by: spacewander --- bin/git-cp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/git-cp b/bin/git-cp index 5b8468cf8..f703148eb 100755 --- a/bin/git-cp +++ b/bin/git-cp @@ -38,6 +38,12 @@ else exit 40 fi + MERGE_OPT= + ff=$(git config --get merge.ff) + if [[ "$ff" == "only" ]]; then + MERGE_OPT="--ff" + fi + echo "Copying $CURRENT_FILENAME into $DESTINATION_FILENAME" INTERMEDIATE_FILENAME="${CURRENT_FILENAME//\//__}-move-to-${DESTINATION_FILENAME//\//__}" @@ -59,7 +65,8 @@ else git reset --hard HEAD^ # We keep both files - git merge "${DESTINATION_SAVED}" "${INTERMEDIATE_SAVED}" -m "Duplicate ${CURRENT_FILENAME} history." + # shellcheck disable=SC2086 + git merge $MERGE_OPT "${DESTINATION_SAVED}" "${INTERMEDIATE_SAVED}" -m "Duplicate ${CURRENT_FILENAME} history." # We get back our original name git mv "${INTERMEDIATE_FILENAME}" "${CURRENT_FILENAME}"