t / t4005-diff-rename-2.shon commit [PATCH] git-commit-script fix for degenerated merge (eca35ec)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='Same rename detection as t4003 but testing diff-raw.
   7
   8'
   9. ./test-lib.sh
  10. ../diff-lib.sh ;# test-lib chdir's into trash
  11
  12test_expect_success \
  13    'prepare reference tree' \
  14    'cat ../../COPYING >COPYING &&
  15     echo frotz >rezrov &&
  16    git-update-cache --add COPYING rezrov &&
  17    tree=$(git-write-tree) &&
  18    echo $tree'
  19
  20test_expect_success \
  21    'prepare work tree' \
  22    'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
  23    sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
  24    rm -f COPYING &&
  25    git-update-cache --add --remove COPYING COPYING.?'
  26
  27# tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
  28# both are slightly edited, and unchanged rezrov.  We say COPYING.1
  29# and COPYING.2 are based on COPYING, and do not say anything about
  30# rezrov.
  31
  32git-diff-cache -M $tree >current
  33
  34cat >expected <<\EOF
  35:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234  COPYING COPYING.1
  36:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234  COPYING COPYING.2
  37EOF
  38
  39test_expect_success \
  40    'validate output from rename/copy detection (#1)' \
  41    'compare_diff_raw current expected'
  42
  43# make sure diff-helper can grok it.
  44mv expected diff-raw
  45GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
  46cat >expected <<\EOF
  47diff --git a/COPYING b/COPYING.1
  48copy from COPYING
  49copy to COPYING.1
  50--- a/COPYING
  51+++ b/COPYING.1
  52@@ -6 +6 @@
  53- HOWEVER, in order to allow a migration to GPLv3 if that seems like
  54+ However, in order to allow a migration to GPLv3 if that seems like
  55diff --git a/COPYING b/COPYING.2
  56rename from COPYING
  57rename to COPYING.2
  58--- a/COPYING
  59+++ b/COPYING.2
  60@@ -2 +2 @@
  61- Note that the only valid version of the GPL as far as this project
  62+ Note that the only valid version of the G.P.L as far as this project
  63@@ -6 +6 @@
  64- HOWEVER, in order to allow a migration to GPLv3 if that seems like
  65+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
  66@@ -12 +12 @@
  67-       This file is licensed under the GPL v2, or a later version
  68+       This file is licensed under the G.P.L v2, or a later version
  69EOF
  70
  71test_expect_success \
  72    'validate output from diff-helper (#1)' \
  73    'compare_diff_patch current expected'
  74
  75################################################################
  76
  77test_expect_success \
  78    'prepare work tree again' \
  79    'mv COPYING.2 COPYING &&
  80     git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
  81
  82# tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
  83# both are slightly edited, and unchanged rezrov.  We say COPYING.1
  84# is based on COPYING and COPYING is still there, and do not say anything
  85# about rezrov.
  86
  87git-diff-cache -C $tree >current
  88cat >expected <<\EOF
  89:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M      COPYING
  90:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234  COPYING COPYING.1
  91EOF
  92
  93test_expect_success \
  94    'validate output from rename/copy detection (#2)' \
  95    'compare_diff_raw current expected'
  96
  97# make sure diff-helper can grok it.
  98mv expected diff-raw
  99GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
 100cat >expected <<\EOF
 101diff --git a/COPYING b/COPYING
 102--- a/COPYING
 103+++ b/COPYING
 104@@ -2 +2 @@
 105- Note that the only valid version of the GPL as far as this project
 106+ Note that the only valid version of the G.P.L as far as this project
 107@@ -6 +6 @@
 108- HOWEVER, in order to allow a migration to GPLv3 if that seems like
 109+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
 110@@ -12 +12 @@
 111-       This file is licensed under the GPL v2, or a later version
 112+       This file is licensed under the G.P.L v2, or a later version
 113diff --git a/COPYING b/COPYING.1
 114copy from COPYING
 115copy to COPYING.1
 116--- a/COPYING
 117+++ b/COPYING.1
 118@@ -6 +6 @@
 119- HOWEVER, in order to allow a migration to GPLv3 if that seems like
 120+ However, in order to allow a migration to GPLv3 if that seems like
 121EOF
 122
 123test_expect_success \
 124    'validate output from diff-helper (#2)' \
 125    'compare_diff_patch current expected'
 126
 127################################################################
 128
 129# tree has COPYING and rezrov.  work tree has the same COPYING and
 130# copy-edited COPYING.1, and unchanged rezrov.  We should not say
 131# anything about rezrov nor COPYING, since the revised again diff-raw
 132# nows how to say Copy.
 133
 134test_expect_success \
 135    'prepare work tree once again' \
 136    'cat ../../COPYING >COPYING &&
 137     git-update-cache --add --remove COPYING COPYING.1'
 138
 139git-diff-cache -C --find-copies-harder $tree >current
 140cat >expected <<\EOF
 141:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234  COPYING COPYING.1
 142EOF
 143
 144test_expect_success \
 145    'validate output from rename/copy detection (#3)' \
 146    'compare_diff_raw current expected'
 147
 148# make sure diff-helper can grok it.
 149mv expected diff-raw
 150GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
 151cat >expected <<\EOF
 152diff --git a/COPYING b/COPYING.1
 153copy from COPYING
 154copy to COPYING.1
 155--- a/COPYING
 156+++ b/COPYING.1
 157@@ -6 +6 @@
 158- HOWEVER, in order to allow a migration to GPLv3 if that seems like
 159+ However, in order to allow a migration to GPLv3 if that seems like
 160EOF
 161
 162test_expect_success \
 163    'validate output from diff-helper (#3)' \
 164    'compare_diff_patch current expected'
 165
 166test_done