1#! /bin/sh 2# 3# @(#)asym-context.sh 1.2 16/06/16 2015-2016 J. Schilling 4# 5 6# asym-context.sh: Testing matching offsets and asymmetic 7# context around the delta. 8 9# Import common functions & definitions. 10. ../common/test-common 11 12LC_ALL=C 13 14 15# 16# Create a patch with asymmetric context 17# 18cat > x.diff <<EOF 19--- x 20+++ x 21@@ -1,3 +1,4 @@ 22 2 23+insert 24 3 25 4 26EOF 27 28# 29# Starting at one causes one line offset 30# 31seq 1 5 > x 32docommand ASC1 "${patch} < x.diff" 0 IGNORE "Hmm... Looks like a unified diff to me... 33The text leading up to this was: 34-------------------------- 35|--- x 36|+++ x 37-------------------------- 38Patching file x using Plan A... 39Hunk #1 succeeded at 2 (offset 1 line). 40done 41" 42 43# 44# Starting at two, now it fits the patch 45# 46seq 2 5 > x 47docommand ASC2 "${patch} < x.diff" 0 IGNORE "Hmm... Looks like a unified diff to me... 48The text leading up to this was: 49-------------------------- 50|--- x 51|+++ x 52-------------------------- 53Patching file x using Plan A... 54done 55" 56 57# 58# Asymmetric, but correct offset for first context line 59# 60cat > x.diff <<EOF 61--- x 62+++ x 63@@ -2,3 +2,4 @@ 64 2 65+insert 66 3 67 4 68EOF 69 70# 71# Correct offset for first context line if we start at 1 72# 73seq 1 5 > x 74docommand ASC3 "${patch} < x.diff" 0 IGNORE "Hmm... Looks like a unified diff to me... 75The text leading up to this was: 76-------------------------- 77|--- x 78|+++ x 79-------------------------- 80Patching file x using Plan A... 81done 82" 83 84# 85# Wrong offset for first context line if we start at 2 86# 87seq 2 5 > x 88docommand ASC4 "${patch} < x.diff" 0 IGNORE "Hmm... Looks like a unified diff to me... 89The text leading up to this was: 90-------------------------- 91|--- x 92|+++ x 93-------------------------- 94Patching file x using Plan A... 95Hunk #1 succeeded at 1 (offset -1 lines). 96done 97" 98 99# 100# Now less context lines after the insertion 101# 102cat > x.diff <<EOF 103--- x 104+++ x 105@@ -2,3 +2,4 @@ 106 2 107 3 108+insert 109 4 110EOF 111 112# 113# Correct offset for first context line if we start at 1 114# 115seq 1 5 > x 116docommand ASC5 "${patch} < x.diff" 0 IGNORE "Hmm... Looks like a unified diff to me... 117The text leading up to this was: 118-------------------------- 119|--- x 120|+++ x 121-------------------------- 122Patching file x using Plan A... 123done 124" 125 126# 127# Wrong offset for first context line if we start at 2 128# 129seq 2 5 > x 130docommand ASC6 "${patch} < x.diff" 0 IGNORE "Hmm... Looks like a unified diff to me... 131The text leading up to this was: 132-------------------------- 133|--- x 134|+++ x 135-------------------------- 136Patching file x using Plan A... 137Hunk #1 succeeded at 1 (offset -1 lines). 138done 139" 140 141remove x x.diff x.orig 142success 143