Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow git cp to create destination folder automatically #1091

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/git-cp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ else
exit 40
fi

DESTINATION_DIR="$(dirname "$DESTINATION_FILENAME")"
if [ ! -d "$DESTINATION_DIR" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use mkdir -p directly as the cmd won't return error if the dir exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Removed this check.

echo "Creating destination directory: $DESTINATION_DIR"
mkdir -p "$DESTINATION_DIR"
if [ $? -ne 0 ]; then
echo 1>&2 "Failed to create destination directory: $DESTINATION_DIR"
exit 80
fi
fi

MERGE_OPT=
ff=$(git config --get merge.ff)
if [[ "$ff" == "only" ]]; then
Expand Down