Merge branch 'js/misc-git-gui-stuff' of ../git-gui
[alt-git.git] / t / t3427-rebase-subtree.sh
blob3780877e4e838d6bba8c016b0ecb7ec69a1359a2
1 #!/bin/sh
3 test_description='git rebase tests for -Xsubtree
5 This test runs git rebase and tests the subtree strategy.
7 . ./test-lib.sh
8 . "$TEST_DIRECTORY"/lib-rebase.sh
10 commit_message() {
11 git log --pretty=format:%s -1 "$1"
14 test_expect_success 'setup' '
15 test_commit README &&
16 mkdir files &&
18 cd files &&
19 git init &&
20 test_commit master1 &&
21 test_commit master2 &&
22 test_commit master3
23 ) &&
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 &&
34 cd files_subtree &&
35 test_commit master4
36 ) &&
37 test_commit files_subtree/master5
40 # FAILURE: Does not preserve master4.
41 test_expect_failure 'Rebase -Xsubtree --preserve-merges --onto commit 4' '
42 reset_rebase &&
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' '
52 reset_rebase &&
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' '
62 reset_rebase &&
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' '
72 reset_rebase &&
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' '
82 reset_rebase &&
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' '
92 reset_rebase &&
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' '
102 reset_rebase &&
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' '
111 reset_rebase &&
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"
119 test_done