Created
February 7, 2022 17:44
-
-
Save katipogluMustafa/b9aea94c0ff3a3918dad9c84102a4d98 to your computer and use it in GitHub Desktop.
Random code fragment from git source code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A small part of 200 lines long function from Git source code. | |
*/ | |
if (inaccurate_eof && | |
old > oldlines && old[-1] == '\n' && | |
newlines.len > 0 && newlines.buf[newlines.len - 1] == '\n') { | |
old--; | |
strbuf_setlen(&newlines, newlines.len - 1); | |
preimage.line_allocated[preimage.nr - 1].len--; | |
postimage.line_allocated[postimage.nr - 1].len--; | |
} | |
leading = frag->leading; | |
trailing = frag->trailing; | |
/* | |
* A hunk to change lines at the beginning would begin with | |
* @@ -1,L +N,M @@ | |
* but we need to be careful. -U0 that inserts before the second | |
* line also has this pattern. | |
* | |
* And a hunk to add to an empty file would begin with | |
* @@ -0,0 +N,M @@ | |
* | |
* In other words, a hunk that is (frag->oldpos <= 1) with or | |
* without leading context must match at the beginning. | |
*/ | |
match_beginning = (!frag->oldpos || | |
(frag->oldpos == 1 && !state->unidiff_zero)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment