diff.c: reduce implicit dependency on the_index
diff and textconv code has so widespread use that it's hard to simply update their api and all call sites at once because it would result in a big patch. For now reduce the_index references to two places: diff_setup() and fill_textconv(). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
92a1bf5a58
commit
b78ea5fc35
@ -5,7 +5,8 @@
|
||||
#include "diff.h"
|
||||
#include "diffcore.h"
|
||||
|
||||
static int should_break(struct diff_filespec *src,
|
||||
static int should_break(struct repository *r,
|
||||
struct diff_filespec *src,
|
||||
struct diff_filespec *dst,
|
||||
int break_score,
|
||||
int *merge_score_p)
|
||||
@ -61,7 +62,8 @@ static int should_break(struct diff_filespec *src,
|
||||
!oidcmp(&src->oid, &dst->oid))
|
||||
return 0; /* they are the same */
|
||||
|
||||
if (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0))
|
||||
if (diff_populate_filespec(r, src, 0) ||
|
||||
diff_populate_filespec(r, dst, 0))
|
||||
return 0; /* error but caught downstream */
|
||||
|
||||
max_size = ((src->size > dst->size) ? src->size : dst->size);
|
||||
@ -71,7 +73,7 @@ static int should_break(struct diff_filespec *src,
|
||||
if (!src->size)
|
||||
return 0; /* we do not let empty files get renamed */
|
||||
|
||||
if (diffcore_count_changes(src, dst,
|
||||
if (diffcore_count_changes(r, src, dst,
|
||||
&src->cnt_data, &dst->cnt_data,
|
||||
&src_copied, &literal_added))
|
||||
return 0;
|
||||
@ -114,7 +116,7 @@ static int should_break(struct diff_filespec *src,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void diffcore_break(int break_score)
|
||||
void diffcore_break(struct repository *r, int break_score)
|
||||
{
|
||||
struct diff_queue_struct *q = &diff_queued_diff;
|
||||
struct diff_queue_struct outq;
|
||||
@ -178,7 +180,7 @@ void diffcore_break(int break_score)
|
||||
object_type(p->one->mode) == OBJ_BLOB &&
|
||||
object_type(p->two->mode) == OBJ_BLOB &&
|
||||
!strcmp(p->one->path, p->two->path)) {
|
||||
if (should_break(p->one, p->two,
|
||||
if (should_break(r, p->one, p->two,
|
||||
break_score, &score)) {
|
||||
/* Split this into delete and create */
|
||||
struct diff_filespec *null_one, *null_two;
|
||||
|
Reference in New Issue
Block a user