Skip to content

Commit

Permalink
range-diff: simplify code spawning git log
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
dscho authored and gitster committed Feb 5, 2021
1 parent a2d474a commit 5189bb8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions range-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ static int read_patches(const char *range, struct string_list *list,
finish_command(&cp);
return -1;
}
if (finish_command(&cp))
return -1;

line = contents.buf;
size = contents.len;
Expand All @@ -101,7 +103,6 @@ static int read_patches(const char *range, struct string_list *list,
string_list_clear(list, 1);
strbuf_release(&buf);
strbuf_release(&contents);
finish_command(&cp);
return -1;
}
util->matching = -1;
Expand All @@ -117,7 +118,6 @@ static int read_patches(const char *range, struct string_list *list,
string_list_clear(list, 1);
strbuf_release(&buf);
strbuf_release(&contents);
finish_command(&cp);
return -1;
}

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

if (finish_command(&cp))
return -1;

return 0;
}

Expand Down

0 comments on commit 5189bb8

Please sign in to comment.