commit - e51ebd83fa731d197ee4074ee2e94dbc0581078c
commit + e4c510c1d83fe01247b6f59d855dffad81e4f26a
blob - e507bbb93de1346023e265fcae281efe13dd2ed5
blob + 6cd959e4159e40e5fcc467e4f69c7318fd54d3d5
--- include/diff_output.h
+++ include/diff_output.h
struct diff_input_info {
const char *left_path;
const char *right_path;
+
+ /* Set by caller of diff_output_* functions. */
+ int flags;
+#define DIFF_INPUT_LEFT_NONEXISTENT 0x00000001
+#define DIFF_INPUT_RIGHT_NONEXISTENT 0x00000002
};
struct diff_output_info {
const struct diff_input_info *info,
const struct diff_result *result,
const struct diff_chunk_context *cc);
+
+const char *diff_output_get_label_left(const struct diff_input_info *info);
+const char *diff_output_get_label_right(const struct diff_input_info *info);
blob - ad654fe1ca00262a9179746c88012cad9aedb134
blob + e286c6225a8b2095cd86a33a23e4c4031b3f3a0c
--- lib/diff_output.c
+++ lib/diff_output.c
{
ARRAYLIST_FREE(output_info->line_offsets);
free(output_info);
+}
+
+const char *
+diff_output_get_label_left(const struct diff_input_info *info)
+{
+ if (info->flags & DIFF_INPUT_LEFT_NONEXISTENT)
+ return "/dev/null";
+
+ return info->left_path ? : "a";
+}
+
+const char *
+diff_output_get_label_right(const struct diff_input_info *info)
+{
+ if (info->flags & DIFF_INPUT_RIGHT_NONEXISTENT)
+ return "/dev/null";
+
+ return info->right_path ? : "b";
}
blob - 677f5baf44d4fa746fc192cb95326307b7f2bf0c
blob + 1c9b6d17294abf78edffde84b7937856f2620bb1
--- lib/diff_output_edscript.c
+++ lib/diff_output_edscript.c
continue;
fprintf(dest, "Binary files %s and %s differ\n",
- info->left_path ? : "a",
- info->right_path ? : "b");
+ diff_output_get_label_left(info),
+ diff_output_get_label_right(info));
break;
}
blob - 520dc91d99494e5f4a3c9be8c238a6defd1ff48a
blob + 0c30eeafe6f5d012f49287395a528b8490816ccd
--- lib/diff_output_unidiff.c
+++ lib/diff_output_unidiff.c
}
if (print_header && !(state->header_printed)) {
- rc = fprintf(dest, "--- %s\n", info->left_path ? : "a");
+ rc = fprintf(dest, "--- %s\n",
+ diff_output_get_label_left(info));
if (rc < 0)
return errno;
if (outinfo) {
*offp = outoff;
}
- rc = fprintf(dest, "+++ %s\n", info->right_path ? : "b");
+ rc = fprintf(dest, "+++ %s\n",
+ diff_output_get_label_right(info));
if (rc < 0)
return errno;
if (outinfo) {
continue;
fprintf(dest, "Binary files %s and %s differ\n",
- info->left_path ? : "a",
- info->right_path ? : "b");
+ diff_output_get_label_left(info),
+ diff_output_get_label_right(info));
break;
}