Skip to content

Commit c26022e

Browse files
bmwillgitster
authored andcommitted
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>
1 parent fcf2cfb commit c26022e

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

diff-lib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
210210
continue;
211211
}
212212
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
213-
ce->oid.hash,
213+
&ce->oid,
214214
!is_null_oid(&ce->oid),
215215
ce->name, 0);
216216
continue;
217217
} else if (revs->diffopt.ita_invisible_in_index &&
218218
ce_intent_to_add(ce)) {
219219
diff_addremove(&revs->diffopt, '+', ce->ce_mode,
220-
EMPTY_BLOB_SHA1_BIN, 0,
220+
&empty_tree_oid, 0,
221221
ce->name, 0);
222222
continue;
223223
}
@@ -260,7 +260,7 @@ static void diff_index_show_file(struct rev_info *revs,
260260
unsigned dirty_submodule)
261261
{
262262
diff_addremove(&revs->diffopt, prefix[0], mode,
263-
oid->hash, oid_valid, ce->name, dirty_submodule);
263+
oid, oid_valid, ce->name, dirty_submodule);
264264
}
265265

266266
static int get_stat_data(const struct cache_entry *ce,

diff.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5081,8 +5081,8 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)
50815081

50825082
void diff_addremove(struct diff_options *options,
50835083
int addremove, unsigned mode,
5084-
const unsigned char *sha1,
5085-
int sha1_valid,
5084+
const struct object_id *oid,
5085+
int oid_valid,
50865086
const char *concatpath, unsigned dirty_submodule)
50875087
{
50885088
struct diff_filespec *one, *two;
@@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,
51145114
two = alloc_filespec(concatpath);
51155115

51165116
if (addremove != '+')
5117-
fill_filespec(one, sha1, sha1_valid, mode);
5117+
fill_filespec(one, oid->hash, oid_valid, mode);
51185118
if (addremove != '-') {
5119-
fill_filespec(two, sha1, sha1_valid, mode);
5119+
fill_filespec(two, oid->hash, oid_valid, mode);
51205120
two->dirty_submodule = dirty_submodule;
51215121
}
51225122

diff.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ typedef void (*change_fn_t)(struct diff_options *options,
3131

3232
typedef void (*add_remove_fn_t)(struct diff_options *options,
3333
int addremove, unsigned mode,
34-
const unsigned char *sha1,
35-
int sha1_valid,
34+
const struct object_id *oid,
35+
int oid_valid,
3636
const char *fullpath, unsigned dirty_submodule);
3737

3838
typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
@@ -247,8 +247,8 @@ extern int diff_can_quit_early(struct diff_options *);
247247
extern void diff_addremove(struct diff_options *,
248248
int addremove,
249249
unsigned mode,
250-
const unsigned char *sha1,
251-
int sha1_valid,
250+
const struct object_id *oid,
251+
int oid_valid,
252252
const char *fullpath, unsigned dirty_submodule);
253253

254254
extern void diff_change(struct diff_options *,

revision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ static int tree_difference = REV_TREE_SAME;
401401

402402
static void file_add_remove(struct diff_options *options,
403403
int addremove, unsigned mode,
404-
const unsigned char *sha1,
405-
int sha1_valid,
404+
const struct object_id *oid,
405+
int oid_valid,
406406
const char *fullpath, unsigned dirty_submodule)
407407
{
408408
int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD;

tree-diff.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ static int emit_diff_first_parent_only(struct diff_options *opt, struct combine_
7878
1, 1, p->path, 0, 0);
7979
}
8080
else {
81-
const unsigned char *sha1;
81+
const struct object_id *oid;
8282
unsigned int mode;
8383
int addremove;
8484

8585
if (p->mode) {
8686
addremove = '+';
87-
sha1 = p->oid.hash;
87+
oid = &p->oid;
8888
mode = p->mode;
8989
} else {
9090
addremove = '-';
91-
sha1 = p0->oid.hash;
91+
oid = &p0->oid;
9292
mode = p0->mode;
9393
}
9494

95-
opt->add_remove(opt, addremove, mode, sha1, 1, p->path, 0);
95+
opt->add_remove(opt, addremove, mode, oid, 1, p->path, 0);
9696
}
9797

9898
return 0; /* we are done with p */

0 commit comments

Comments
 (0)