3 test_description='git rebase tests for -Xsubtree
5 This test runs git rebase and tests the subtree strategy.
8 . "$TEST_DIRECTORY"/lib-rebase.sh
11 git log --pretty=format:%s -1 "$1"
14 test_expect_success 'setup' '
20 test_commit master1 &&
21 test_commit master2 &&
24 git fetch files master &&
25 git branch files-master FETCH_HEAD &&
26 git read-tree --prefix=files_subtree files-master &&
27 git checkout -- files_subtree &&
28 tree=$(git write-tree) &&
29 head=$(git rev-parse HEAD) &&
30 rev=$(git rev-parse --verify files-master^0) &&
31 commit=$(git commit-tree -p $head -p $rev -m "Add subproject master" $tree) &&
32 git update-ref HEAD $commit &&
37 test_commit files_subtree/master5
40 # FAILURE: Does not preserve master4.
41 test_expect_failure REBASE_P \
42 'Rebase -Xsubtree --preserve-merges --onto commit 4' '
44 git checkout -b rebase-preserve-merges-4 master &&
45 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
46 git commit -m "Empty commit" --allow-empty &&
47 git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master &&
48 verbose test "$(commit_message HEAD~)" = "files_subtree/master4"
51 # FAILURE: Does not preserve master5.
52 test_expect_failure REBASE_P \
53 'Rebase -Xsubtree --preserve-merges --onto commit 5' '
55 git checkout -b rebase-preserve-merges-5 master &&
56 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
57 git commit -m "Empty commit" --allow-empty &&
58 git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master &&
59 verbose test "$(commit_message HEAD)" = "files_subtree/master5"
62 # FAILURE: Does not preserve master4.
63 test_expect_failure REBASE_P \
64 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 4' '
66 git checkout -b rebase-keep-empty-4 master &&
67 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
68 git commit -m "Empty commit" --allow-empty &&
69 git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
70 verbose test "$(commit_message HEAD~2)" = "files_subtree/master4"
73 # FAILURE: Does not preserve master5.
74 test_expect_failure REBASE_P \
75 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 5' '
77 git checkout -b rebase-keep-empty-5 master &&
78 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
79 git commit -m "Empty commit" --allow-empty &&
80 git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
81 verbose test "$(commit_message HEAD~)" = "files_subtree/master5"
84 # FAILURE: Does not preserve Empty.
85 test_expect_failure REBASE_P \
86 'Rebase -Xsubtree --keep-empty --preserve-merges --onto empty commit' '
88 git checkout -b rebase-keep-empty-empty master &&
89 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
90 git commit -m "Empty commit" --allow-empty &&
91 git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
92 verbose test "$(commit_message HEAD)" = "Empty commit"
95 # FAILURE: fatal: Could not parse object
96 test_expect_failure 'Rebase -Xsubtree --onto commit 4' '
98 git checkout -b rebase-onto-4 master &&
99 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
100 git commit -m "Empty commit" --allow-empty &&
101 git rebase -Xsubtree=files_subtree --onto files-master master &&
102 verbose test "$(commit_message HEAD~2)" = "files_subtree/master4"
105 # FAILURE: fatal: Could not parse object
106 test_expect_failure 'Rebase -Xsubtree --onto commit 5' '
108 git checkout -b rebase-onto-5 master &&
109 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
110 git commit -m "Empty commit" --allow-empty &&
111 git rebase -Xsubtree=files_subtree --onto files-master master &&
112 verbose test "$(commit_message HEAD~)" = "files_subtree/master5"
114 # FAILURE: fatal: Could not parse object
115 test_expect_failure 'Rebase -Xsubtree --onto empty commit' '
117 git checkout -b rebase-onto-empty master &&
118 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
119 git commit -m "Empty commit" --allow-empty &&
120 git rebase -Xsubtree=files_subtree --onto files-master master &&
121 verbose test "$(commit_message HEAD)" = "Empty commit"