t / t4014-format-patch.shon commit git-commit: partial commit of paths only removed from the index (cba8d48)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Junio C Hamano
   4#
   5
   6test_description='Format-patch skipping already incorporated patches'
   7
   8. ./test-lib.sh
   9
  10test_expect_success setup '
  11
  12        for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
  13        git add file &&
  14        git commit -m Initial &&
  15        git checkout -b side &&
  16
  17        for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file &&
  18        git update-index file &&
  19        git commit -m "Side changes #1" &&
  20
  21        for i in D E F; do echo "$i"; done >>file &&
  22        git update-index file &&
  23        git commit -m "Side changes #2" &&
  24        git tag C2 &&
  25
  26        for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file &&
  27        git update-index file &&
  28        git commit -m "Side changes #3 with \\n backslash-n in it." &&
  29
  30        git checkout master &&
  31        git diff-tree -p C2 | git apply --index &&
  32        git commit -m "Master accepts moral equivalent of #2"
  33
  34'
  35
  36test_expect_success "format-patch --ignore-if-in-upstream" '
  37
  38        git format-patch --stdout master..side >patch0 &&
  39        cnt=`grep "^From " patch0 | wc -l` &&
  40        test $cnt = 3
  41
  42'
  43
  44test_expect_success "format-patch --ignore-if-in-upstream" '
  45
  46        git format-patch --stdout \
  47                --ignore-if-in-upstream master..side >patch1 &&
  48        cnt=`grep "^From " patch1 | wc -l` &&
  49        test $cnt = 2
  50
  51'
  52
  53test_expect_success "format-patch result applies" '
  54
  55        git checkout -b rebuild-0 master &&
  56        git am -3 patch0 &&
  57        cnt=`git rev-list master.. | wc -l` &&
  58        test $cnt = 2
  59'
  60
  61test_expect_success "format-patch --ignore-if-in-upstream result applies" '
  62
  63        git checkout -b rebuild-1 master &&
  64        git am -3 patch1 &&
  65        cnt=`git rev-list master.. | wc -l` &&
  66        test $cnt = 2
  67'
  68
  69test_expect_success 'commit did not screw up the log message' '
  70
  71        git cat-file commit side | grep "^Side .* with .* backslash-n"
  72
  73'
  74
  75test_expect_success 'format-patch did not screw up the log message' '
  76
  77        grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
  78        grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
  79
  80'
  81
  82test_expect_success 'replay did not screw up the log message' '
  83
  84        git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
  85
  86'
  87
  88test_done