Skip to content

Commit bbfabfd

Browse files
committed
GitAddSelectedHunkCommand: '\r\n' line endings were replaced by '\n' in patches which made them not apply.
1 parent 3ae011b commit bbfabfd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

git/add.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def cull_diff(self, result):
5959
hunks = [{"diff": ""}]
6060
i = 0
6161
matcher = re.compile('^@@ -([0-9]*)(?:,([0-9]*))? \+([0-9]*)(?:,([0-9]*))? @@')
62-
for line in result.splitlines():
62+
for line in result.splitlines(keepends=True): # if different line endings, patch will not apply
6363
if line.startswith('@@'):
6464
i += 1
6565
match = matcher.match(line)
@@ -70,7 +70,7 @@ def cull_diff(self, result):
7070
else:
7171
end = start
7272
hunks.append({"diff": "", "start": start, "end": end})
73-
hunks[i]["diff"] += line + "\n"
73+
hunks[i]["diff"] += line
7474

7575
diffs = hunks[0]["diff"]
7676
hunks.pop(0)

0 commit comments

Comments
 (0)