diff: convert diff_addremove to struct object_id

Convert diff_addremove to take a struct object_id.  In addtion convert
the function pointer type 'add_remove_fn_t' to also take a struct
object_id.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Brandon Williams 2017-05-30 10:30:47 -07:00 коммит произвёл Junio C Hamano
Родитель fcf2cfb54b
Коммит c26022ea8f
5 изменённых файлов: 17 добавлений и 17 удалений

Просмотреть файл

@ -210,14 +210,14 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
continue;
}
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
ce->oid.hash,
&ce->oid,
!is_null_oid(&ce->oid),
ce->name, 0);
continue;
} else if (revs->diffopt.ita_invisible_in_index &&
ce_intent_to_add(ce)) {
diff_addremove(&revs->diffopt, '+', ce->ce_mode,
EMPTY_BLOB_SHA1_BIN, 0,
&empty_tree_oid, 0,
ce->name, 0);
continue;
}
@ -260,7 +260,7 @@ static void diff_index_show_file(struct rev_info *revs,
unsigned dirty_submodule)
{
diff_addremove(&revs->diffopt, prefix[0], mode,
oid->hash, oid_valid, ce->name, dirty_submodule);
oid, oid_valid, ce->name, dirty_submodule);
}
static int get_stat_data(const struct cache_entry *ce,

8
diff.c
Просмотреть файл

@ -5081,8 +5081,8 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)
void diff_addremove(struct diff_options *options,
int addremove, unsigned mode,
const unsigned char *sha1,
int sha1_valid,
const struct object_id *oid,
int oid_valid,
const char *concatpath, unsigned dirty_submodule)
{
struct diff_filespec *one, *two;
@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,
two = alloc_filespec(concatpath);
if (addremove != '+')
fill_filespec(one, sha1, sha1_valid, mode);
fill_filespec(one, oid->hash, oid_valid, mode);
if (addremove != '-') {
fill_filespec(two, sha1, sha1_valid, mode);
fill_filespec(two, oid->hash, oid_valid, mode);
two->dirty_submodule = dirty_submodule;
}

8
diff.h
Просмотреть файл

@ -31,8 +31,8 @@ typedef void (*change_fn_t)(struct diff_options *options,
typedef void (*add_remove_fn_t)(struct diff_options *options,
int addremove, unsigned mode,
const unsigned char *sha1,
int sha1_valid,
const struct object_id *oid,
int oid_valid,
const char *fullpath, unsigned dirty_submodule);
typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
@ -247,8 +247,8 @@ extern int diff_can_quit_early(struct diff_options *);
extern void diff_addremove(struct diff_options *,
int addremove,
unsigned mode,
const unsigned char *sha1,
int sha1_valid,
const struct object_id *oid,
int oid_valid,
const char *fullpath, unsigned dirty_submodule);
extern void diff_change(struct diff_options *,

Просмотреть файл

@ -401,8 +401,8 @@ static int tree_difference = REV_TREE_SAME;
static void file_add_remove(struct diff_options *options,
int addremove, unsigned mode,
const unsigned char *sha1,
int sha1_valid,
const struct object_id *oid,
int oid_valid,
const char *fullpath, unsigned dirty_submodule)
{
int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;

Просмотреть файл

@ -78,21 +78,21 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
1, 1, p->path, 0, 0);
}
else {
const unsigned char *sha1;
const struct object_id *oid;
unsigned int mode;
int addremove;
if (p->mode) {
addremove = '+';
sha1 = p->oid.hash;
oid = &p->oid;
mode = p->mode;
} else {
addremove = '-';
sha1 = p0->oid.hash;
oid = &p0->oid;
mode = p0->mode;
}
opt->add_remove(opt, addremove, mode, sha1, 1, p->path, 0);
opt->add_remove(opt, addremove, mode, oid, 1, p->path, 0);
}
return 0; /* we are done with p */