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>
Brandon Williams committed
May 30, 2017 at 10:30 UTC
c26022ea8f54649ed6b3b545dd3158907abe5d2c
5 files changed
+17
-17
diff-lib.c
+3
-3
@@ -210,14 +210,14 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
210
continue;
211
}
212
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
213
- ce->oid.hash,
213
+ &ce->oid,
214
!is_null_oid(&ce->oid),
215
ce->name, 0);
216
continue;
217
} else if (revs->diffopt.ita_invisible_in_index &&
218
ce_intent_to_add(ce)) {
219
diff_addremove(&revs->diffopt, '+', ce->ce_mode,
220
- EMPTY_BLOB_SHA1_BIN, 0,
220
+ &empty_tree_oid, 0,
221
ce->name, 0);
222
continue;
223
}
@@ -260,7 +260,7 @@ static void diff_index_show_file(struct rev_info *revs,
260
unsigned dirty_submodule)
261
{
262
diff_addremove(&revs->diffopt, prefix[0], mode,
263
- oid->hash, oid_valid, ce->name, dirty_submodule);
263
+ oid, oid_valid, ce->name, dirty_submodule);
264
}
265
266
static int get_stat_data(const struct cache_entry *ce,
diff.c
+4
-4
@@ -5081,8 +5081,8 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)
5081
5082
void diff_addremove(struct diff_options *options,
5083
int addremove, unsigned mode,
5084
- const unsigned char *sha1,
5085
- int sha1_valid,
5084
+ const struct object_id *oid,
5085
+ int oid_valid,
5086
const char *concatpath, unsigned dirty_submodule)
5087
{
5088
struct diff_filespec *one, *two;
@@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,
5114
two = alloc_filespec(concatpath);
5115
5116
if (addremove != '+')
5117
- fill_filespec(one, sha1, sha1_valid, mode);
5117
+ fill_filespec(one, oid->hash, oid_valid, mode);
5118
if (addremove != '-') {
5119
- fill_filespec(two, sha1, sha1_valid, mode);
5119
+ fill_filespec(two, oid->hash, oid_valid, mode);
5120
two->dirty_submodule = dirty_submodule;
5121
}
5122
diff.h
+4
-4
@@ -31,8 +31,8 @@ typedef void (*change_fn_t)(struct diff_options *options,
31
32
typedef void (*add_remove_fn_t)(struct diff_options *options,
33
int addremove, unsigned mode,
34
- const unsigned char *sha1,
35
- int sha1_valid,
34
+ const struct object_id *oid,
35
+ int oid_valid,
36
const char *fullpath, unsigned dirty_submodule);
37
38
typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
@@ -247,8 +247,8 @@ extern int diff_can_quit_early(struct diff_options *);
247
extern void diff_addremove(struct diff_options *,
248
int addremove,
249
unsigned mode,
250
- const unsigned char *sha1,
251
- int sha1_valid,
250
+ const struct object_id *oid,
251
+ int oid_valid,
252
const char *fullpath, unsigned dirty_submodule);
253
254
extern void diff_change(struct diff_options *,
revision.c
+2
-2
@@ -401,8 +401,8 @@ static int tree_difference = REV_TREE_SAME;
401
402
static void file_add_remove(struct diff_options *options,
403
int addremove, unsigned mode,
404
- const unsigned char *sha1,
405
- int sha1_valid,
404
+ const struct object_id *oid,
405
+ int oid_valid,
406
const char *fullpath, unsigned dirty_submodule)
407
{
408
int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;
tree-diff.c
+4
-4
@@ -78,21 +78,21 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
78
1, 1, p->path, 0, 0);
79
}
80
else {
81
- const unsigned char *sha1;
81
+ const struct object_id *oid;
82
unsigned int mode;
83
int addremove;
84
85
if (p->mode) {
86
addremove = '+';
87
- sha1 = p->oid.hash;
87
+ oid = &p->oid;
88
mode = p->mode;
89
} else {
90
addremove = '-';
91
- sha1 = p0->oid.hash;
91
+ oid = &p0->oid;
92
mode = p0->mode;
93
}
94
95
- opt->add_remove(opt, addremove, mode, sha1, 1, p->path, 0);
95
+ opt->add_remove(opt, addremove, mode, oid, 1, p->path, 0);
96
}
97
98
return 0; /* we are done with p */