Skip to content

Commit 86e15ff

Browse files
committed
Merge branch 'rs/diff-postimage-in-context'
* rs/diff-postimage-in-context: xdiff: print post-image for common records instead of pre-image
2 parents d1afa8b + baf5aaa commit 86e15ff

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,27 @@ test_expect_success 'another test, with -w --ignore-space-at-eol' 'test_cmp expe
103103
git diff -w -b --ignore-space-at-eol > out
104104
test_expect_success 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'
105105

106-
tr 'Q' '\015' << EOF > expect
106+
tr 'Q_' '\015 ' << EOF > expect
107107
diff --git a/x b/x
108108
index d99af23..8b32fb5 100644
109109
--- a/x
110110
+++ b/x
111111
@@ -1,6 +1,6 @@
112112
-whitespace at beginning
113113
+ whitespace at beginning
114-
whitespace change
114+
whitespace change
115115
-whitespace in the middle
116116
+white space in the middle
117-
whitespace at end
117+
whitespace at end__
118118
unchanged line
119-
CR at endQ
119+
CR at end
120120
EOF
121121
git diff -b > out
122122
test_expect_success 'another test, with -b' 'test_cmp expect out'
123123
git diff -b --ignore-space-at-eol > out
124124
test_expect_success 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
125125

126-
tr 'Q' '\015' << EOF > expect
126+
tr 'Q_' '\015 ' << EOF > expect
127127
diff --git a/x b/x
128128
index d99af23..8b32fb5 100644
129129
--- a/x
@@ -135,9 +135,9 @@ index d99af23..8b32fb5 100644
135135
+ whitespace at beginning
136136
+whitespace change
137137
+white space in the middle
138-
whitespace at end
138+
whitespace at end__
139139
unchanged line
140-
CR at endQ
140+
CR at end
141141
EOF
142142
git diff --ignore-space-at-eol > out
143143
test_expect_success 'another test, with --ignore-space-at-eol' 'test_cmp expect out'

xdiff/xemit.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static long def_ff(const char *rec, long len, char *buf, long sz, void *priv)
8787

8888
static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
8989
xdemitconf_t const *xecfg) {
90-
xdfile_t *xdf = &xe->xdf1;
90+
xdfile_t *xdf = &xe->xdf2;
9191
const char *rchg = xdf->rchg;
9292
long ix;
9393

@@ -204,16 +204,16 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
204204
/*
205205
* Emit pre-context.
206206
*/
207-
for (; s1 < xch->i1; s1++)
208-
if (xdl_emit_record(&xe->xdf1, s1, " ", ecb) < 0)
207+
for (; s2 < xch->i2; s2++)
208+
if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0)
209209
return -1;
210210

211211
for (s1 = xch->i1, s2 = xch->i2;; xch = xch->next) {
212212
/*
213213
* Merge previous with current change atom.
214214
*/
215215
for (; s1 < xch->i1 && s2 < xch->i2; s1++, s2++)
216-
if (xdl_emit_record(&xe->xdf1, s1, " ", ecb) < 0)
216+
if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0)
217217
return -1;
218218

219219
/*
@@ -239,8 +239,8 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
239239
/*
240240
* Emit post-context.
241241
*/
242-
for (s1 = xche->i1 + xche->chg1; s1 < e1; s1++)
243-
if (xdl_emit_record(&xe->xdf1, s1, " ", ecb) < 0)
242+
for (s2 = xche->i2 + xche->chg2; s2 < e2; s2++)
243+
if (xdl_emit_record(&xe->xdf2, s2, " ", ecb) < 0)
244244
return -1;
245245
}
246246

0 commit comments

Comments
 (0)