git-cp: continue to merge when merge.ff is only (#1070)

Signed-off-by: spacewander <spacewanderlzx@gmail.com>
This commit is contained in:
罗泽轩 2023-09-13 13:02:06 +08:00 committed by GitHub
parent db71be578e
commit f95e339c03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}"