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 -Xsubtree --preserve-merges --onto commit 4' '
43 git checkout -b rebase-preserve-merges-4 master &&
44 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
45 git commit -m "Empty commit" --allow-empty &&
46 git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master &&
47 verbose test "$(commit_message HEAD~)" = "files_subtree/master4"
50 # FAILURE: Does not preserve master5.
51 test_expect_failure 'Rebase -Xsubtree --preserve-merges --onto commit 5' '
53 git checkout -b rebase-preserve-merges-5 master &&
54 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
55 git commit -m "Empty commit" --allow-empty &&
56 git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master &&
57 verbose test "$(commit_message HEAD)" = "files_subtree/master5"
60 # FAILURE: Does not preserve master4.
61 test_expect_failure 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 4' '
63 git checkout -b rebase-keep-empty-4 master &&
64 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
65 git commit -m "Empty commit" --allow-empty &&
66 git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
67 verbose test "$(commit_message HEAD~2)" = "files_subtree/master4"
70 # FAILURE: Does not preserve master5.
71 test_expect_failure 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit 5' '
73 git checkout -b rebase-keep-empty-5 master &&
74 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
75 git commit -m "Empty commit" --allow-empty &&
76 git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
77 verbose test "$(commit_message HEAD~)" = "files_subtree/master5"
80 # FAILURE: Does not preserve Empty.
81 test_expect_failure 'Rebase -Xsubtree --keep-empty --preserve-merges --onto empty commit' '
83 git checkout -b rebase-keep-empty-empty master &&
84 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
85 git commit -m "Empty commit" --allow-empty &&
86 git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
87 verbose test "$(commit_message HEAD)" = "Empty commit"
90 # FAILURE: fatal: Could not parse object
91 test_expect_failure 'Rebase -Xsubtree --onto commit 4' '
93 git checkout -b rebase-onto-4 master &&
94 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
95 git commit -m "Empty commit" --allow-empty &&
96 git rebase -Xsubtree=files_subtree --onto files-master master &&
97 verbose test "$(commit_message HEAD~2)" = "files_subtree/master4"
100 # FAILURE: fatal: Could not parse object
101 test_expect_failure 'Rebase -Xsubtree --onto commit 5' '
103 git checkout -b rebase-onto-5 master &&
104 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
105 git commit -m "Empty commit" --allow-empty &&
106 git rebase -Xsubtree=files_subtree --onto files-master master &&
107 verbose test "$(commit_message HEAD~)" = "files_subtree/master5"
109 # FAILURE: fatal: Could not parse object
110 test_expect_failure 'Rebase -Xsubtree --onto empty commit' '
112 git checkout -b rebase-onto-empty master &&
113 git filter-branch --prune-empty -f --subdirectory-filter files_subtree &&
114 git commit -m "Empty commit" --allow-empty &&
115 git rebase -Xsubtree=files_subtree --onto files-master master &&
116 verbose test "$(commit_message HEAD)" = "Empty commit"