Skip to content

Commit

Permalink
git-cp: continue to merge when merge.ff is only (tj#1070)
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander authored Sep 13, 2023
1 parent db71be5 commit f95e339
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bin/git-cp
Original file line number Diff line number Diff line change
Expand Up @@ -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//\//__}"
Expand All @@ -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}"
Expand Down

0 comments on commit f95e339

Please sign in to comment.