6221
if (p->one->mode == 0) {
6222
patch_id_add_string(&ctx, "newfilemode");
6223
patch_id_add_mode(&ctx, p->two->mode);
6224
- patch_id_add_string(&ctx, "---/dev/null");
6225
- patch_id_add_string(&ctx, "+++b/");
6226
- the_hash_algo->update_fn(&ctx, p->two->path, len2);
6224
} else if (p->two->mode == 0) {
6225
patch_id_add_string(&ctx, "deletedfilemode");
6226
patch_id_add_mode(&ctx, p->one->mode);
6230
- patch_id_add_string(&ctx, "---a/");
6231
- the_hash_algo->update_fn(&ctx, p->one->path, len1);
6232
- patch_id_add_string(&ctx, "+++/dev/null");
6233
- } else {
6234
- patch_id_add_string(&ctx, "---a/");
6235
- the_hash_algo->update_fn(&ctx, p->one->path, len1);
6236
- patch_id_add_string(&ctx, "+++b/");
6237
- the_hash_algo->update_fn(&ctx, p->two->path, len2);
6227
}
6228
6240
- if (diff_header_only)
6241
- continue;
6242
-
6243
- if (fill_mmfile(options->repo, &mf1, p->one) < 0 ||
6244
- fill_mmfile(options->repo, &mf2, p->two) < 0)
6245
- return error("unable to read files to diff");
6246
-
6247
- if (diff_filespec_is_binary(options->repo, p->one) ||
6229
+ if (diff_header_only) {
6230
+ /* don't do anything since we're only populating header info */
6231
+ } else if (diff_filespec_is_binary(options->repo, p->one) ||
6232
diff_filespec_is_binary(options->repo, p->two)) {
6233
the_hash_algo->update_fn(&ctx, oid_to_hex(&p->one->oid),
6234
the_hash_algo->hexsz);
6235
the_hash_algo->update_fn(&ctx, oid_to_hex(&p->two->oid),
6236
the_hash_algo->hexsz);
6253
- continue;
6254
- }
6255
-
6256
- xpp.flags = 0;
6257
- xecfg.ctxlen = 3;
6258
- xecfg.flags = XDL_EMIT_NO_HUNK_HDR;
6259
- if (xdi_diff_outf(&mf1, &mf2, NULL,
6260
- patch_id_consume, &data, &xpp, &xecfg))
6261
- return error("unable to generate patch-id diff for %s",
6262
- p->one->path);
6237
+ } else {
6238
+ if (p->one->mode == 0) {
6239
+ patch_id_add_string(&ctx, "---/dev/null");
6240
+ patch_id_add_string(&ctx, "+++b/");
6241
+ the_hash_algo->update_fn(&ctx, p->two->path, len2);
6242
+ } else if (p->two->mode == 0) {
6243
+ patch_id_add_string(&ctx, "---a/");
6244
+ the_hash_algo->update_fn(&ctx, p->one->path, len1);
6245
+ patch_id_add_string(&ctx, "+++/dev/null");
6246
+ } else {
6247
+ patch_id_add_string(&ctx, "---a/");
6248
+ the_hash_algo->update_fn(&ctx, p->one->path, len1);
6249
+ patch_id_add_string(&ctx, "+++b/");
6250
+ the_hash_algo->update_fn(&ctx, p->two->path, len2);
6251
+ }
6252
6253
+ if (fill_mmfile(options->repo, &mf1, p->one) < 0 ||
6254
+ fill_mmfile(options->repo, &mf2, p->two) < 0)
6255
+ return error("unable to read files to diff");
6256
+ xpp.flags = 0;
6257
+ xecfg.ctxlen = 3;
6258
+ xecfg.flags = XDL_EMIT_NO_HUNK_HDR;
6259
+ if (xdi_diff_outf(&mf1, &mf2, NULL,
6260
+ patch_id_consume, &data, &xpp, &xecfg))
6261
+ return error("unable to generate patch-id diff for %s",
6262
+ p->one->path);
6263
+ }
6264
if (stable)
6265
flush_one_hunk(oid, &ctx);
6266
}