-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jl/submodule-tests: revert: add t3513 for submodule updates stash: add t3906 for submodule updates am: add t4255 for submodule updates cherry-pick: add t3512 for submodule updates pull: add t5572 for submodule updates rebase: add t3426 for submodule updates merge: add t7613 for submodule updates bisect: add t6041 for submodule updates reset: add t7112 for submodule updates read-tree: add t1013 for submodule updates apply: add t4137 for submodule updates checkout: call the new submodule update test framework submodules: add the lib-submodule-update.sh test library test-lib: add test_dir_is_empty()
- Loading branch information
Showing
14 changed files
with
974 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
test_description='read-tree can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
test_submodule_switch "git read-tree -u -m" | ||
|
||
test_submodule_forced_switch "git read-tree -u --reset" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
|
||
test_description='rebase can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
. "$TEST_DIRECTORY"/lib-rebase.sh | ||
|
||
git_rebase () { | ||
git status -su >expect && | ||
ls -1pR * >>expect && | ||
git checkout -b ours HEAD && | ||
echo x >>file1 && | ||
git add file1 && | ||
git commit -m add_x && | ||
git revert HEAD && | ||
git status -su >actual && | ||
ls -1pR * >>actual && | ||
test_cmp expect actual && | ||
git rebase "$1" | ||
} | ||
|
||
test_submodule_switch "git_rebase" | ||
|
||
git_rebase_interactive () { | ||
git status -su >expect && | ||
ls -1pR * >>expect && | ||
git checkout -b ours HEAD && | ||
echo x >>file1 && | ||
git add file1 && | ||
git commit -m add_x && | ||
git revert HEAD && | ||
git status -su >actual && | ||
ls -1pR * >>actual && | ||
test_cmp expect actual && | ||
set_fake_editor && | ||
echo "fake-editor.sh" >.git/info/exclude && | ||
git rebase -i "$1" | ||
} | ||
|
||
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 | ||
# The real reason "replace directory with submodule" fails is because a | ||
# directory "sub1" exists, but we reuse the suppression added for merge here | ||
test_submodule_switch "git_rebase_interactive" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
test_description='cherry-pick can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1 | ||
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 | ||
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 | ||
test_submodule_switch "git cherry-pick" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
test_description='revert can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
# Create a revert that moves from HEAD (including any test modifications to | ||
# the work tree) to $1 by first checking out $1 and reverting it. Reverting | ||
# the revert is the transition we test for. We tar the current work tree | ||
# first so we can restore the work tree test setup after doing the checkout | ||
# and revert. We test here that the restored work tree content is identical | ||
# to that at the beginning. The last revert is then tested by the framework. | ||
git_revert () { | ||
git status -su >expect && | ||
ls -1pR * >>expect && | ||
tar czf "$TRASH_DIRECTORY/tmp.tgz" * && | ||
git checkout "$1" && | ||
git revert HEAD && | ||
rm -rf * && | ||
tar xzf "$TRASH_DIRECTORY/tmp.tgz" && | ||
git status -su >actual && | ||
ls -1pR * >>actual && | ||
test_cmp expect actual && | ||
git revert HEAD | ||
} | ||
|
||
KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1 | ||
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 | ||
test_submodule_switch "git_revert" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
test_description='stash apply can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
git_stash () { | ||
git status -su >expect && | ||
ls -1pR * >>expect && | ||
git read-tree -u -m "$1" && | ||
git stash && | ||
git status -su >actual && | ||
ls -1pR * >>actual && | ||
test_cmp expect actual && | ||
git stash apply | ||
} | ||
|
||
KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES=1 | ||
KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1 | ||
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 | ||
test_submodule_switch "git_stash" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
test_description='git apply handling submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
apply_index () { | ||
git diff --ignore-submodules=dirty "..$1" | git apply --index - | ||
} | ||
|
||
test_submodule_switch "apply_index" | ||
|
||
apply_3way () { | ||
git diff --ignore-submodules=dirty "..$1" | git apply --3way - | ||
} | ||
|
||
test_submodule_switch "apply_3way" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
test_description='git am handling submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
am () { | ||
git format-patch --stdout --ignore-submodules=dirty "..$1" | git am - | ||
} | ||
|
||
test_submodule_switch "am" | ||
|
||
am_3way () { | ||
git format-patch --stdout --ignore-submodules=dirty "..$1" | git am --3way - | ||
} | ||
|
||
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 | ||
test_submodule_switch "am_3way" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
test_description='pull can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
reset_branch_to_HEAD () { | ||
git branch -D "$1" && | ||
git checkout -b "$1" HEAD && | ||
git branch --set-upstream-to="origin/$1" "$1" | ||
} | ||
|
||
git_pull () { | ||
reset_branch_to_HEAD "$1" && | ||
git pull | ||
} | ||
|
||
# pulls without conflicts | ||
test_submodule_switch "git_pull" | ||
|
||
git_pull_ff () { | ||
reset_branch_to_HEAD "$1" && | ||
git pull --ff | ||
} | ||
|
||
test_submodule_switch "git_pull_ff" | ||
|
||
git_pull_ff_only () { | ||
reset_branch_to_HEAD "$1" && | ||
git pull --ff-only | ||
} | ||
|
||
test_submodule_switch "git_pull_ff_only" | ||
|
||
git_pull_noff () { | ||
reset_branch_to_HEAD "$1" && | ||
git pull --no-ff | ||
} | ||
|
||
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 | ||
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 | ||
test_submodule_switch "git_pull_noff" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
test_description='bisect can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
git_bisect () { | ||
git status -su >expect && | ||
ls -1pR * >>expect && | ||
tar czf "$TRASH_DIRECTORY/tmp.tgz" * && | ||
GOOD=$(git rev-parse --verify HEAD) && | ||
git checkout "$1" && | ||
echo "foo" >bar && | ||
git add bar && | ||
git commit -m "bisect bad" && | ||
BAD=$(git rev-parse --verify HEAD) && | ||
git reset --hard HEAD^^ && | ||
git submodule update && | ||
git bisect start && | ||
git bisect good $GOOD && | ||
rm -rf * && | ||
tar xzf "$TRASH_DIRECTORY/tmp.tgz" && | ||
git status -su >actual && | ||
ls -1pR * >>actual && | ||
test_cmp expect actual && | ||
git bisect bad $BAD | ||
} | ||
|
||
test_submodule_switch "git_bisect" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
test_description='reset can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
test_submodule_switch "git reset --keep" | ||
|
||
test_submodule_switch "git reset --merge" | ||
|
||
test_submodule_forced_switch "git reset --hard" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
test_description='merge can handle submodules' | ||
|
||
. ./test-lib.sh | ||
. "$TEST_DIRECTORY"/lib-submodule-update.sh | ||
|
||
# merges without conflicts | ||
test_submodule_switch "git merge" | ||
|
||
test_submodule_switch "git merge --ff" | ||
|
||
test_submodule_switch "git merge --ff-only" | ||
|
||
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1 | ||
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1 | ||
test_submodule_switch "git merge --no-ff" | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters