commit - 0f24033e38cc689c7c86333f00269a799660dd38
commit + 0d039490032e7afdddb00a59c0e6240c9b1a4dfa
blob - aa67f591fb351d377bca13b28e1dc0b7296e8a96
blob + 50e27eac588c197ea4e8e49c301c37a2bb14da90
--- lib/diff.c
+++ lib/diff.c
off_t outoff = 0;
int n;
- if (lines && *lines && *nlines > 0)
- outoff = (*lines)[*nlines - 1].offset;
- else if (lines) {
- err = add_line_metadata(lines, nlines, 0, GOT_DIFF_LINE_NONE);
- if (err)
- goto done;
+ if (lines && *lines) {
+ if (*nlines > 0)
+ outoff = (*lines)[*nlines - 1].offset;
+ else {
+ err = add_line_metadata(lines, nlines,
+ 0, GOT_DIFF_LINE_NONE);
+ if (err != NULL)
+ goto done;
+ }
}
if (resultp)
if (n < 0)
goto done;
outoff += n;
- if (lines) {
+ if (lines && *lines) {
err = add_line_metadata(lines, nlines, outoff,
GOT_DIFF_LINE_BLOB_MIN);
if (err)
if (n < 0)
goto done;
outoff += n;
- if (lines) {
+ if (lines && *lines) {
err = add_line_metadata(lines, nlines, outoff,
GOT_DIFF_LINE_BLOB_PLUS);
if (err)
blob - 0c5437a04f86df6eb79d9ec6ceb9a8f373d2704f
blob + 36e65fe9dbf6828fbe4915d554b475498d2bd900
--- lib/diffreg.c
+++ lib/diffreg.c
switch (output_format) {
case GOT_DIFF_OUTPUT_UNIDIFF:
rc = diff_output_unidiff(
- lines ? &output_info : NULL, outfile, &info,
+ lines && *lines ? &output_info : NULL, outfile, &info,
diff_result->result, context_lines);
if (rc != DIFF_RC_OK)
return got_error_set_errno(rc, "diff_output_unidiff");
break;
case GOT_DIFF_OUTPUT_PLAIN:
- rc = diff_output_plain(lines ? &output_info : NULL,
+ rc = diff_output_plain(lines && *lines ? &output_info : NULL,
outfile, &info, diff_result->result, 1);
if (rc != DIFF_RC_OK)
return got_error_set_errno(rc, "diff_output_edscript");