зеркало из https://github.com/microsoft/git.git
subtree: t7900: use consistent formatting
The formatting in t7900-subtree.sh isn't even consistent throughout the file. Fix that; make it consistent throughout the file. Signed-off-by: Luke Shumaker <lukeshu@datawire.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
f2bb7fef7a
Коммит
f700406957
|
@ -11,11 +11,9 @@ and split subcommands of git subtree.
|
||||||
|
|
||||||
TEST_DIRECTORY=$(pwd)/../../../t
|
TEST_DIRECTORY=$(pwd)/../../../t
|
||||||
export TEST_DIRECTORY
|
export TEST_DIRECTORY
|
||||||
|
. "$TEST_DIRECTORY"/test-lib.sh
|
||||||
|
|
||||||
. ../../../t/test-lib.sh
|
subtree_test_create_repo () {
|
||||||
|
|
||||||
subtree_test_create_repo()
|
|
||||||
{
|
|
||||||
test_create_repo "$1" &&
|
test_create_repo "$1" &&
|
||||||
(
|
(
|
||||||
cd "$1" &&
|
cd "$1" &&
|
||||||
|
@ -23,26 +21,24 @@ subtree_test_create_repo()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
create()
|
create () {
|
||||||
{
|
|
||||||
echo "$1" >"$1" &&
|
echo "$1" >"$1" &&
|
||||||
git add "$1"
|
git add "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_equal()
|
check_equal () {
|
||||||
{
|
|
||||||
test_debug 'echo'
|
test_debug 'echo'
|
||||||
test_debug "echo \"check a:\" \"{$1}\""
|
test_debug "echo \"check a:\" \"{$1}\""
|
||||||
test_debug "echo \" b:\" \"{$2}\""
|
test_debug "echo \" b:\" \"{$2}\""
|
||||||
if [ "$1" = "$2" ]; then
|
if test "$1" = "$2"
|
||||||
|
then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
undo()
|
undo () {
|
||||||
{
|
|
||||||
git reset --hard HEAD~
|
git reset --hard HEAD~
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +46,18 @@ undo()
|
||||||
# The original set of commits changed only one file each.
|
# The original set of commits changed only one file each.
|
||||||
# A multi-file change would imply that we pruned commits
|
# A multi-file change would imply that we pruned commits
|
||||||
# too aggressively.
|
# too aggressively.
|
||||||
join_commits()
|
join_commits () {
|
||||||
{
|
|
||||||
commit=
|
commit=
|
||||||
all=
|
all=
|
||||||
while read x y; do
|
while read x y
|
||||||
if [ -z "$x" ]; then
|
do
|
||||||
|
if test -z "$x"
|
||||||
|
then
|
||||||
continue
|
continue
|
||||||
elif [ "$x" = "commit:" ]; then
|
elif test "$x" = "commit:"
|
||||||
if [ -n "$commit" ]; then
|
then
|
||||||
|
if test -n "$commit"
|
||||||
|
then
|
||||||
echo "$commit $all"
|
echo "$commit $all"
|
||||||
all=
|
all=
|
||||||
fi
|
fi
|
||||||
|
@ -70,7 +69,7 @@ join_commits()
|
||||||
echo "$commit $all"
|
echo "$commit $all"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_create_commit() (
|
test_create_commit () (
|
||||||
repo=$1 &&
|
repo=$1 &&
|
||||||
commit=$2 &&
|
commit=$2 &&
|
||||||
cd "$repo" &&
|
cd "$repo" &&
|
||||||
|
@ -81,8 +80,7 @@ test_create_commit() (
|
||||||
git commit -m "$commit" || error "Could not commit"
|
git commit -m "$commit" || error "Could not commit"
|
||||||
)
|
)
|
||||||
|
|
||||||
last_commit_message()
|
last_commit_message () {
|
||||||
{
|
|
||||||
git log --pretty=format:%s -1
|
git log --pretty=format:%s -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +109,8 @@ test_expect_success 'no pull from non-existent subtree' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD
|
test_must_fail git subtree pull --prefix="sub dir" ./"sub proj" HEAD
|
||||||
)'
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'add subproj as subtree into sub dir/ with --prefix' '
|
test_expect_success 'add subproj as subtree into sub dir/ with --prefix' '
|
||||||
subtree_test_create_repo "$test_count" &&
|
subtree_test_create_repo "$test_count" &&
|
||||||
|
@ -274,8 +273,8 @@ test_expect_success 'split requires option --prefix' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
||||||
echo "You must provide the --prefix option." > expected &&
|
echo "You must provide the --prefix option." >expected &&
|
||||||
test_must_fail git subtree split > actual 2>&1 &&
|
test_must_fail git subtree split >actual 2>&1 &&
|
||||||
test_debug "printf '"expected: "'" &&
|
test_debug "printf '"expected: "'" &&
|
||||||
test_debug "cat expected" &&
|
test_debug "cat expected" &&
|
||||||
test_debug "printf '"actual: "'" &&
|
test_debug "printf '"actual: "'" &&
|
||||||
|
@ -293,8 +292,8 @@ test_expect_success 'split requires path given by option --prefix must exist' '
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
git subtree add --prefix="sub dir" FETCH_HEAD &&
|
||||||
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
|
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" >expected &&
|
||||||
test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
|
test_must_fail git subtree split --prefix=non-existent-directory >actual 2>&1 &&
|
||||||
test_debug "printf '"expected: "'" &&
|
test_debug "printf '"expected: "'" &&
|
||||||
test_debug "cat expected" &&
|
test_debug "cat expected" &&
|
||||||
test_debug "printf '"actual: "'" &&
|
test_debug "printf '"actual: "'" &&
|
||||||
|
@ -325,7 +324,7 @@ test_expect_success 'split sub dir/ with --rejoin' '
|
||||||
git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
|
git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
|
||||||
check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
|
check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'split sub dir/ with --rejoin from scratch' '
|
test_expect_success 'split sub dir/ with --rejoin from scratch' '
|
||||||
subtree_test_create_repo "$test_count" &&
|
subtree_test_create_repo "$test_count" &&
|
||||||
|
@ -340,7 +339,7 @@ test_expect_success 'split sub dir/ with --rejoin from scratch' '
|
||||||
git subtree split --prefix="sub dir" --rejoin &&
|
git subtree split --prefix="sub dir" --rejoin &&
|
||||||
check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
|
check_equal "$(last_commit_message)" "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'split sub dir/ with --rejoin and --message' '
|
test_expect_success 'split sub dir/ with --rejoin and --message' '
|
||||||
subtree_test_create_repo "$test_count" &&
|
subtree_test_create_repo "$test_count" &&
|
||||||
|
@ -893,7 +892,8 @@ test_expect_success 'verify one file change per commit' '
|
||||||
x= &&
|
x= &&
|
||||||
git log --pretty=format:"commit: %H" | join_commits |
|
git log --pretty=format:"commit: %H" | join_commits |
|
||||||
(
|
(
|
||||||
while read commit a b; do
|
while read commit a b
|
||||||
|
do
|
||||||
test_debug "echo Verifying commit $commit"
|
test_debug "echo Verifying commit $commit"
|
||||||
test_debug "echo a: $a"
|
test_debug "echo a: $a"
|
||||||
test_debug "echo b: $b"
|
test_debug "echo b: $b"
|
||||||
|
@ -921,18 +921,18 @@ test_expect_success 'push split to subproj' '
|
||||||
test_create_commit "$test_count" "sub dir"/main-sub2 &&
|
test_create_commit "$test_count" "sub dir"/main-sub2 &&
|
||||||
(
|
(
|
||||||
cd $test_count/"sub proj" &&
|
cd $test_count/"sub proj" &&
|
||||||
git branch sub-branch-1 &&
|
git branch sub-branch-1 &&
|
||||||
cd .. &&
|
cd .. &&
|
||||||
git fetch ./"sub proj" HEAD &&
|
git fetch ./"sub proj" HEAD &&
|
||||||
git subtree merge --prefix="sub dir" FETCH_HEAD
|
git subtree merge --prefix="sub dir" FETCH_HEAD
|
||||||
) &&
|
) &&
|
||||||
test_create_commit "$test_count" "sub dir"/main-sub3 &&
|
test_create_commit "$test_count" "sub dir"/main-sub3 &&
|
||||||
(
|
(
|
||||||
cd "$test_count" &&
|
cd "$test_count" &&
|
||||||
git subtree push ./"sub proj" --prefix "sub dir" sub-branch-1 &&
|
git subtree push ./"sub proj" --prefix "sub dir" sub-branch-1 &&
|
||||||
cd ./"sub proj" &&
|
cd ./"sub proj" &&
|
||||||
git checkout sub-branch-1 &&
|
git checkout sub-branch-1 &&
|
||||||
check_equal "$(last_commit_message)" "sub dir/main-sub3"
|
check_equal "$(last_commit_message)" "sub dir/main-sub3"
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче