Skip to content

Commit 5189bb8

Browse files
dschogitster
authored andcommitted
range-diff: simplify code spawning git log
Previously, we waited for the child process to be finished in every failing code path as well as at the end of the function `show_range_diff()`. However, we do not need to wait that long. Directly after reading the output of the child process, we can wrap up the child process. This also has the advantage that we don't do a bunch of unnecessary work in case `finish_command()` returns with an error anyway. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a2d474a commit 5189bb8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

range-diff.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ static int read_patches(const char *range, struct string_list *list,
8080
finish_command(&cp);
8181
return -1;
8282
}
83+
if (finish_command(&cp))
84+
return -1;
8385

8486
line = contents.buf;
8587
size = contents.len;
@@ -101,7 +103,6 @@ static int read_patches(const char *range, struct string_list *list,
101103
string_list_clear(list, 1);
102104
strbuf_release(&buf);
103105
strbuf_release(&contents);
104-
finish_command(&cp);
105106
return -1;
106107
}
107108
util->matching = -1;
@@ -117,7 +118,6 @@ static int read_patches(const char *range, struct string_list *list,
117118
string_list_clear(list, 1);
118119
strbuf_release(&buf);
119120
strbuf_release(&contents);
120-
finish_command(&cp);
121121
return -1;
122122
}
123123

@@ -227,9 +227,6 @@ static int read_patches(const char *range, struct string_list *list,
227227
strbuf_release(&buf);
228228
free(current_filename);
229229

230-
if (finish_command(&cp))
231-
return -1;
232-
233230
return 0;
234231
}
235232

0 commit comments

Comments
 (0)