aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/shared.c b/shared.c
index a63633b..a48eea6 100644
--- a/shared.c
+++ b/shared.c
@@ -263,15 +263,15 @@ void cgit_diff_tree_cb(struct diff_queue_struct *q,
263 } 263 }
264} 264}
265 265
266static int load_mmfile(mmfile_t *file, const unsigned char *sha1) 266static int load_mmfile(mmfile_t *file, const struct object_id *oid)
267{ 267{
268 enum object_type type; 268 enum object_type type;
269 269
270 if (is_null_sha1(sha1)) { 270 if (is_null_oid(oid)) {
271 file->ptr = (char *)""; 271 file->ptr = (char *)"";
272 file->size = 0; 272 file->size = 0;
273 } else { 273 } else {
274 file->ptr = read_sha1_file(sha1, &type, 274 file->ptr = read_sha1_file(oid->hash, &type,
275 (unsigned long *)&file->size); 275 (unsigned long *)&file->size);
276 } 276 }
277 return 1; 277 return 1;
@@ -322,8 +322,8 @@ static int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf)
322 return 0; 322 return 0;
323} 323}
324 324
325int cgit_diff_files(const unsigned char *old_sha1, 325int cgit_diff_files(const struct object_id *old_oid,
326 const unsigned char *new_sha1, unsigned long *old_size, 326 const struct object_id *new_oid, unsigned long *old_size,
327 unsigned long *new_size, int *binary, int context, 327 unsigned long *new_size, int *binary, int context,
328 int ignorews, linediff_fn fn) 328 int ignorews, linediff_fn fn)
329{ 329{
@@ -332,7 +332,7 @@ int cgit_diff_files(const unsigned char *old_sha1,
332 xdemitconf_t emit_params; 332 xdemitconf_t emit_params;
333 xdemitcb_t emit_cb; 333 xdemitcb_t emit_cb;
334 334
335 if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) 335 if (!load_mmfile(&file1, old_oid) || !load_mmfile(&file2, new_oid))
336 return 1; 336 return 1;
337 337
338 *old_size = file1.size; 338 *old_size = file1.size;
@@ -366,8 +366,8 @@ int cgit_diff_files(const unsigned char *old_sha1,
366 return 0; 366 return 0;
367} 367}
368 368
369void cgit_diff_tree(const unsigned char *old_sha1, 369void cgit_diff_tree(const struct object_id *old_oid,
370 const unsigned char *new_sha1, 370 const struct object_id *new_oid,
371 filepair_fn fn, const char *prefix, int ignorews) 371 filepair_fn fn, const char *prefix, int ignorews)
372{ 372{
373 struct diff_options opt; 373 struct diff_options opt;
@@ -391,21 +391,21 @@ void cgit_diff_tree(const unsigned char *old_sha1,
391 } 391 }
392 diff_setup_done(&opt); 392 diff_setup_done(&opt);
393 393
394 if (old_sha1 && !is_null_sha1(old_sha1)) 394 if (old_oid && !is_null_oid(old_oid))
395 diff_tree_sha1(old_sha1, new_sha1, "", &opt); 395 diff_tree_sha1(old_oid->hash, new_oid->hash, "", &opt);
396 else 396 else
397 diff_root_tree_sha1(new_sha1, "", &opt); 397 diff_root_tree_sha1(new_oid->hash, "", &opt);
398 diffcore_std(&opt); 398 diffcore_std(&opt);
399 diff_flush(&opt); 399 diff_flush(&opt);
400} 400}
401 401
402void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix) 402void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix)
403{ 403{
404 unsigned char *old_sha1 = NULL; 404 const struct object_id *old_oid = NULL;
405 405
406 if (commit->parents) 406 if (commit->parents)
407 old_sha1 = commit->parents->item->object.oid.hash; 407 old_oid = &commit->parents->item->object.oid;
408 cgit_diff_tree(old_sha1, commit->object.oid.hash, fn, prefix, 408 cgit_diff_tree(old_oid, &commit->object.oid, fn, prefix,
409 ctx.qry.ignorews); 409 ctx.qry.ignorews);
410} 410}
411 411