t / t4114-apply-typechange.shon commit cvsserver: Add some useful commandline options (693b632)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Eric Wong
   4#
   5
   6test_description='git-apply should not get confused with type changes.
   7
   8'
   9
  10. ./test-lib.sh
  11
  12test_expect_success 'setup repository and commits' '
  13        echo "hello world" > foo &&
  14        echo "hi planet" > bar &&
  15        git update-index --add foo bar &&
  16        git commit -m initial &&
  17        git branch initial &&
  18        rm -f foo &&
  19        ln -s bar foo &&
  20        git update-index foo &&
  21        git commit -m "foo symlinked to bar" &&
  22        git branch foo-symlinked-to-bar &&
  23        rm -f foo &&
  24        echo "how far is the sun?" > foo &&
  25        git update-index foo &&
  26        git commit -m "foo back to file" &&
  27        git branch foo-back-to-file &&
  28        rm -f foo &&
  29        git update-index --remove foo &&
  30        mkdir foo &&
  31        echo "if only I knew" > foo/baz &&
  32        git update-index --add foo/baz &&
  33        git commit -m "foo becomes a directory" &&
  34        git branch "foo-becomes-a-directory" &&
  35        echo "hello world" > foo/baz &&
  36        git update-index foo/baz &&
  37        git commit -m "foo/baz is the original foo" &&
  38        git branch foo-baz-renamed-from-foo
  39        '
  40
  41test_expect_success 'file renamed from foo to foo/baz' '
  42        git checkout -f initial &&
  43        git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
  44        git apply --index < patch
  45        '
  46test_debug 'cat patch'
  47
  48
  49test_expect_success 'file renamed from foo/baz to foo' '
  50        git checkout -f foo-baz-renamed-from-foo &&
  51        git diff-tree -M -p HEAD initial > patch &&
  52        git apply --index < patch
  53        '
  54test_debug 'cat patch'
  55
  56
  57test_expect_success 'directory becomes file' '
  58        git checkout -f foo-becomes-a-directory &&
  59        git diff-tree -p HEAD initial > patch &&
  60        git apply --index < patch
  61        '
  62test_debug 'cat patch'
  63
  64
  65test_expect_success 'file becomes directory' '
  66        git checkout -f initial &&
  67        git diff-tree -p HEAD foo-becomes-a-directory > patch &&
  68        git apply --index < patch
  69        '
  70test_debug 'cat patch'
  71
  72
  73test_expect_success 'file becomes symlink' '
  74        git checkout -f initial &&
  75        git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
  76        git apply --index < patch
  77        '
  78test_debug 'cat patch'
  79
  80
  81test_expect_success 'symlink becomes file' '
  82        git checkout -f foo-symlinked-to-bar &&
  83        git diff-tree -p HEAD foo-back-to-file > patch &&
  84        git apply --index < patch
  85        '
  86test_debug 'cat patch'
  87
  88
  89test_expect_success 'symlink becomes directory' '
  90        git checkout -f foo-symlinked-to-bar &&
  91        git diff-tree -p HEAD foo-becomes-a-directory > patch &&
  92        git apply --index < patch
  93        '
  94test_debug 'cat patch'
  95
  96
  97test_expect_success 'directory becomes symlink' '
  98        git checkout -f foo-becomes-a-directory &&
  99        git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
 100        git apply --index < patch
 101        '
 102test_debug 'cat patch'
 103
 104
 105test_done