Make sure that <prefix> exists when splitting.
And test cases for that check, as well as for an error if no prefix is specified at all.
This commit is contained in:
parent
349a70d5cf
commit
ec54f0d9ad
@ -105,6 +105,11 @@ esac
|
|||||||
if [ -z "$prefix" ]; then
|
if [ -z "$prefix" ]; then
|
||||||
die "You must provide the --prefix option."
|
die "You must provide the --prefix option."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$command" = "split" -a """"! -e "$prefix" ]; then
|
||||||
|
die "$prefix does not exist."
|
||||||
|
fi
|
||||||
|
|
||||||
dir="$(dirname "$prefix/.")"
|
dir="$(dirname "$prefix/.")"
|
||||||
|
|
||||||
if [ "$command" != "pull" ]; then
|
if [ "$command" != "pull" ]; then
|
||||||
|
8
test.sh
8
test.sh
@ -140,6 +140,14 @@ git subtree merge --prefix=subdir FETCH_HEAD
|
|||||||
git branch pre-split
|
git branch pre-split
|
||||||
check_equal "$(last_commit_message)" "Merge commit '$(git rev-parse sub2)' into mainline"
|
check_equal "$(last_commit_message)" "Merge commit '$(git rev-parse sub2)' into mainline"
|
||||||
|
|
||||||
|
# Check that prefix argument is required for split (exits with warning and exit status = 1)
|
||||||
|
! result=$(git subtree split 2>&1)
|
||||||
|
check_equal "You must provide the --prefix option." "$result"
|
||||||
|
|
||||||
|
# Check that the <prefix> exists for a split.
|
||||||
|
! result=$(git subtree split --prefix=non-existent-directory 2>&1)
|
||||||
|
check_equal "non-existent-directory does not exist." "$result"
|
||||||
|
|
||||||
# check if --message works for split+rejoin
|
# check if --message works for split+rejoin
|
||||||
spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)
|
spl1=$(git subtree split --annotate='*' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)
|
||||||
echo "spl1={$spl1}"
|
echo "spl1={$spl1}"
|
||||||
|
Loading…
Reference in New Issue
Block a user