t / t3427-rebase-subtree.shon commit fsck: complain when .gitmodules is a symlink (b7b1fca)
   1#!/bin/sh
   2
   3test_description='git rebase tests for -Xsubtree
   4
   5This test runs git rebase and tests the subtree strategy.
   6'
   7. ./test-lib.sh
   8. "$TEST_DIRECTORY"/lib-rebase.sh
   9
  10commit_message() {
  11        git log --pretty=format:%s -1 "$1"
  12}
  13
  14test_expect_success 'setup' '
  15        test_commit README &&
  16        mkdir files &&
  17        (
  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 &&
  33        (
  34                cd files_subtree &&
  35                test_commit master4
  36        ) &&
  37        test_commit files_subtree/master5
  38'
  39
  40# FAILURE: Does not preserve master4.
  41test_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"
  48'
  49
  50# FAILURE: Does not preserve master5.
  51test_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"
  58'
  59
  60# FAILURE: Does not preserve master4.
  61test_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"
  68'
  69
  70# FAILURE: Does not preserve master5.
  71test_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"
  78'
  79
  80# FAILURE: Does not preserve Empty.
  81test_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"
  88'
  89
  90# FAILURE: fatal: Could not parse object
  91test_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"
  98'
  99
 100# FAILURE: fatal: Could not parse object
 101test_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"
 108'
 109# FAILURE: fatal: Could not parse object
 110test_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"
 117'
 118
 119test_done