@matheusbsbs / matheus-bagliano / commits / 7c4ed8c835
Fork 0

blame: inline get_patch()

Inline get_patch() to its only call site as a preparation for getting rid of struct patch. Also we don't need to check the ptr members because fill_origin_blob() already did, and the caller didn't check for NULL anyway, so drop the test. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 25, 2008 at 15:30 UTC 7c4ed8c83583517e7e6d851c8c01996ca6c803ff
1 file changed +11 -20
builtin-blame.c
+11 -20
@@ -542,25 +542,6 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
542 return state.ret;
543 }
544
545 -/*
546 - * Run diff between two origins and grab the patch output, so that
547 - * we can pass blame for lines origin is currently suspected for
548 - * to its parent.
549 - */
550 -static struct patch *get_patch(struct origin *parent, struct origin *origin)
551 -{
552 - mmfile_t file_p, file_o;
553 - struct patch *patch;
554 -
555 - fill_origin_blob(parent, &file_p);
556 - fill_origin_blob(origin, &file_o);
557 - if (!file_p.ptr || !file_o.ptr)
558 - return NULL;
559 - patch = compare_buffer(&file_p, &file_o, 0);
560 - num_get_patch++;
561 - return patch;
562 -}
563 -
545 static void free_patch(struct patch *p)
546 {
547 free(p->chunks);
@@ -824,12 +805,22 @@ static int pass_blame_to_parent(struct scoreboard *sb,
805 {
806 int i, last_in_target, plno, tlno;
807 struct patch *patch;
808 + mmfile_t file_p, file_o;
809
810 last_in_target = find_last_in_target(sb, target);
811 if (last_in_target < 0)
812 return 1; /* nothing remains for this target */
813
832 - patch = get_patch(parent, target);
814 + /*
815 + * Run diff between two origins and grab the patch output, so that
816 + * we can pass blame for lines origin is currently suspected for
817 + * to its parent.
818 + */
819 + fill_origin_blob(parent, &file_p);
820 + fill_origin_blob(target, &file_o);
821 + patch = compare_buffer(&file_p, &file_o, 0);
822 + num_get_patch++;
823 +
824 plno = tlno = 0;
825 for (i = 0; i < patch->num; i++) {
826 struct chunk *chunk = &patch->chunks[i];