commit - 3db5a0afedc4111bd9721c0e5229cd217202ac84
commit + 7783f73c4beef7010e3332dee7f94dad9a54109f
blob - 2d75c470b84a9c0f07ca7ccd39595267ab24fd49
blob + 08328fe81ea2c2cf86331c9b155ab3b6134f9836
--- lib/worktree.c
+++ lib/worktree.c
if (err)
goto done;
- if (fseek(ondisk_file, 0L, SEEK_SET) == -1) {
- err = got_ferror(ondisk_file, GOT_ERR_IO);
- goto done;
- }
-
r = diffreg_result->result;
for (n = 0; n < r->chunks.len; n += nchunks_parsed) {
struct diff_chunk *c;
struct diff_chunk_context cc = {};
+ off_t pos;
int clc, crc;
/*
clc = diff_chunk_get_left_count(c);
crc = diff_chunk_get_right_count(c);
- if (!crc && clc) {
+ if (!crc || crc == clc) {
nchunks_parsed = 1;
- continue; /* removed lines */
+ continue; /* removed or unchanged lines */
}
- diff_chunk_context_load_change(&cc, &nchunks_parsed, r, n, 0);
-
- while (ln < cc.right.start) {
- err = skip_one_line(ondisk_file);
- if (err)
- goto done;
- ++ln;
+ pos = diff_chunk_get_right_start_pos(c);
+ if (fseek(ondisk_file, pos, SEEK_SET) == -1) {
+ err = got_ferror(ondisk_file, GOT_ERR_IO);
+ goto done;
}
+ diff_chunk_context_load_change(&cc, &nchunks_parsed, r, n, 0);
+ ln = cc.right.start;
+
while (ln < cc.right.end) {
linelen = getline(&line, &linesize, ondisk_file);
if (linelen == -1) {