Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commit7fbc182
committed
Fix diff patch parser for paths with unsafe chars
This specifically covers the cases where unsafe chars occur in pathnames, and git-diff -p will escape those.From the git-diff-tree manpage:> 3. TAB, LF, double quote and backslash characters in pathnames are> represented as \t, \n, \" and \\, respectively. If there is need> for such substitution then the whole pathname is put in double> quotes.This patch checks whether or not this has happened and will unescapethose paths accordingly.One thing to note here is that, depending on the position in the patchformat, those paths may be prefixed with an a/ or b/. I've specificallymade sure to never interpret a path that actually starts with a/ or b/incorrectly.Example of that subtlety below. Here, the actual file path is"b/normal". On the diff file that gets encoded as "b/b/normal". diff --git a/b/normal b/b/normal new file mode 100644 index 0000000000000000000000000000000000000000..eaf5f7510320b6a327fb308379de2f94d8859a54 --- /dev/null +++ b/b/normal @@ -0,0 +1 @@ +dummy contentHere, we prefer the "---" and "+++" lines' values. Note that thesepaths start with a/ or b/. The only exception is the value "/dev/null",which is handled as a special case.Suppose now the file gets moved "b/moved", the output of that diff wouldthen be this: diff --git a/b/normal b/b/moved similarity index 100% rename from b/normal rename to b/movedWe prefer the "rename" lines' values in this case (the "diff" line isalways a last resort). Take note that those lines are not prefixed witha/ or b/, but the ones in the "diff" line are (just like the ones in"---" or "+++" lines).1 parent504870e commit7fbc182
File tree
3 files changed
+136
-15
lines changed- git
- test
- fixtures
3 files changed
+136
-15
lines changedLines changed: 34 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
25 | 39 |
| |
26 | 40 |
| |
27 | 41 |
| |
| |||
196 | 210 |
| |
197 | 211 |
| |
198 | 212 |
| |
199 |
| - | |
| 213 | + | |
200 | 214 |
| |
201 |
| - | |
| 215 | + | |
202 | 216 |
| |
203 | 217 |
| |
204 | 218 |
| |
| |||
208 | 222 |
| |
209 | 223 |
| |
210 | 224 |
| |
211 |
| - | |
212 |
| - | |
213 |
| - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
214 | 228 |
| |
215 | 229 |
| |
216 | 230 |
| |
| |||
319 | 333 |
| |
320 | 334 |
| |
321 | 335 |
| |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
322 | 349 |
| |
323 | 350 |
| |
324 | 351 |
| |
| |||
338 | 365 |
| |
339 | 366 |
| |
340 | 367 |
| |
341 |
| - | |
342 |
| - | |
343 |
| - | |
344 |
| - | |
345 |
| - | |
346 |
| - | |
347 |
| - | |
348 |
| - | |
| 368 | + | |
| 369 | + | |
349 | 370 |
| |
350 | 371 |
| |
351 | 372 |
| |
|
Lines changed: 75 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + |
Lines changed: 27 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 |
| - | |
| 1 | + | |
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
| |||
145 | 145 |
| |
146 | 146 |
| |
147 | 147 |
| |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
148 | 173 |
| |
149 | 174 |
| |
150 | 175 |
| |
151 | 176 |
| |
152 | 177 |
| |
153 |
| - | |
| 178 | + | |
154 | 179 |
| |
155 | 180 |
| |
156 | 181 |
| |
|
0 commit comments
Comments
(0)