Skip to content

Commit a3ed9a3

Browse files
committed
fixup! built-in add -p: implement the hunk splitting feature
While it is true that the diffs Git generates can only contain comment lines at the end of a hunk, and really only when indicating that a line does not end in a Line Feed, comment lines _are_ a valid diff construct. Let's play it safe by handling those when splitting hunks. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 098aa77 commit a3ed9a3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

add-patch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,10 @@ static int split_hunk(struct add_p_state *s, struct file_diff *file_diff,
867867

868868
if (marker != ' ' || (ch != '-' && ch != '+')) {
869869
next_hunk_line:
870+
/* Comment lines are attached to the previous line */
871+
if (ch == '\\')
872+
ch = marker ? marker : ' ';
873+
870874
/* current hunk not done yet */
871875
if (ch == ' ')
872876
context_line_count++;

0 commit comments

Comments
 (0)