From b85fc019ca0468ba1cc0c816f1042b1e47db7c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 20 Mar 2020 09:41:43 +0100 Subject: [PATCH] Signal if the destination already exists. --- bin/git-cp | 9 ++++++++- bin/git-psykorebase | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/git-cp b/bin/git-cp index 4c6f7d2..ff23b20 100755 --- a/bin/git-cp +++ b/bin/git-cp @@ -1,4 +1,6 @@ #!/usr/bin/env bash +set -euo pipefail + PROGRAM=$0 CURRENT_FILENAME="" DESTINATION_FILENAME="" @@ -30,6 +32,12 @@ elif [[ "$CURRENT_FILENAME" == "" ]]; then usage exit 10 # Missing arguments CURRENT_FILENAME else + if [ ! -e "$DESTINATION_FILENAME" ]; then + echo 1>&2 "$DESTINATION_FILENAME already exists." + echo 1>&2 "Make sure to remove the destination first." + exit 40 + fi + echo "Coping $CURRENT_FILENAME into $DESTINATION_FILENAME" INTERMEDIATE_FILENAME="${CURRENT_FILENAME//\//__}-move-to-${DESTINATION_FILENAME//\//__}" @@ -47,7 +55,6 @@ else git commit -nm "Copy $CURRENT_FILENAME into $DESTINATION_FILENAME" # We get back our copy - rm -f "${DESTINATION_FILENAME}" # Make sure the file doesn't exists somehow git merge "${SAVED}" git commit -a -m "Duplicate ${CURRENT_FILENAME} history." # Keeping both files diff --git a/bin/git-psykorebase b/bin/git-psykorebase index 995ad92..e0ebaa3 100755 --- a/bin/git-psykorebase +++ b/bin/git-psykorebase @@ -1,6 +1,4 @@ #!/usr/bin/env bash -set -euo pipefail - PROGRAM=$0 PRIMARY_BRANCH="" SECONDARY_BRANCH=""