Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commite77128e
committed
Make diff patch parsing more reliable
The a_path and b_path cannot reliably be read from the first diff lineas it's ambiguous. From the git-diff manpage: > The a/ and b/ filenames are the same unless rename/copy is involved. > Especially, **even for a creation or a deletion**, /dev/null is not > used in place of the a/ or b/ filenames.This patch changes the a_path and b_path detection to read it from themore reliable locations further down the diff headers. Two use casesare fixed by this: - As the man page snippet above states, for new/deleted files the a or b path will now be properly None. - File names with spaces in it are now properly parsed.Working on this patch, I realized the --- and +++ lines really belong tothe diff header, not the diff contents. This means that when parsingthe patch format, the --- and +++ will now be swallowed, and not end upanymore as part of the diff contents. The diff contents now alwaysstart with an @@ line.This may be a breaking change for some users that rely on thisbehaviour. However, those users could now access that information morereliably via the normal Diff properties a_path and b_path now.1 parent0d7a40f commite77128e
File tree
4 files changed
+38
-14
lines changed- git
- test
- fixtures
4 files changed
+38
-14
lines changedLines changed: 22 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
198 | 198 |
| |
199 | 199 |
| |
200 | 200 |
| |
201 |
| - | |
202 |
| - | |
203 |
| - | |
204 |
| - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
205 | 205 |
| |
206 | 206 |
| |
207 | 207 |
| |
208 | 208 |
| |
209 | 209 |
| |
210 | 210 |
| |
| 211 | + | |
| 212 | + | |
211 | 213 |
| |
212 | 214 |
| |
213 | 215 |
| |
| |||
231 | 233 |
| |
232 | 234 |
| |
233 | 235 |
| |
234 |
| - | |
| 236 | + | |
235 | 237 |
| |
236 | 238 |
| |
237 |
| - | |
238 | 239 |
| |
239 |
| - | |
| 240 | + | |
| 241 | + | |
240 | 242 |
| |
241 | 243 |
| |
242 |
| - | |
243 | 244 |
| |
244 | 245 |
| |
245 | 246 |
| |
| |||
329 | 330 |
| |
330 | 331 |
| |
331 | 332 |
| |
332 |
| - | |
| 333 | + | |
| 334 | + | |
333 | 335 |
| |
334 |
| - | |
| 336 | + | |
| 337 | + | |
335 | 338 |
| |
336 | 339 |
| |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
337 | 349 |
| |
338 | 350 |
| |
339 | 351 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + |
Lines changed: 0 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 |
| - | |
2 |
| - | |
3 | 1 |
| |
4 | 2 |
| |
5 | 3 |
| |
|
Lines changed: 9 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
79 |
| - | |
| 79 | + | |
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
| |||
140 | 140 |
| |
141 | 141 |
| |
142 | 142 |
| |
143 |
| - | |
| 143 | + | |
| 144 | + | |
144 | 145 |
| |
145 | 146 |
| |
146 | 147 |
| |
| |||
156 | 157 |
| |
157 | 158 |
| |
158 | 159 |
| |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
159 | 166 |
| |
160 | 167 |
| |
161 | 168 |
| |
|
0 commit comments
Comments
(0)