Commit a6f38c10 authored by Junio C Hamano's avatar Junio C Hamano

Merge branch 'bw/object-id'

Conversion from uchar[20] to struct object_id continues.

* bw/object-id: (33 commits)
  diff: rename diff_fill_sha1_info to diff_fill_oid_info
  diffcore-rename: use is_empty_blob_oid
  tree-diff: convert path_appendnew to object_id
  tree-diff: convert diff_tree_paths to struct object_id
  tree-diff: convert try_to_follow_renames to struct object_id
  builtin/diff-tree: cleanup references to sha1
  diff-tree: convert diff_tree_sha1 to struct object_id
  notes-merge: convert write_note_to_worktree to struct object_id
  notes-merge: convert verify_notes_filepair to struct object_id
  notes-merge: convert find_notes_merge_pair_ps to struct object_id
  notes-merge: convert merge_from_diffs to struct object_id
  notes-merge: convert notes_merge* to struct object_id
  tree-diff: convert diff_root_tree_sha1 to struct object_id
  combine-diff: convert find_paths_* to struct object_id
  combine-diff: convert diff_tree_combined to struct object_id
  diff: convert diff_flush_patch_id to struct object_id
  patch-ids: convert to struct object_id
  diff: finish conversion for prepare_temp_file to struct object_id
  diff: convert reuse_worktree_file to struct object_id
  diff: convert fill_filespec to struct object_id
  ...
parents d04787e6 94e327e9
......@@ -556,9 +556,9 @@ static struct blame_origin *find_origin(struct commit *parent,
if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
"", &diff_opts);
diff_tree_oid(&parent->tree->object.oid,
&origin->commit->tree->object.oid,
"", &diff_opts);
diffcore_std(&diff_opts);
if (!diff_queued_diff.nr) {
......@@ -625,9 +625,9 @@ static struct blame_origin *find_rename(struct commit *parent,
if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
"", &diff_opts);
diff_tree_oid(&parent->tree->object.oid,
&origin->commit->tree->object.oid,
"", &diff_opts);
diffcore_std(&diff_opts);
for (i = 0; i < diff_queued_diff.nr; i++) {
......@@ -1247,7 +1247,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
/* Try "find copies harder" on new path if requested;
* we do not want to use diffcore_rename() actually to
* match things up; find_copies_harder is set only to
* force diff_tree_sha1() to feed all filepairs to diff_queue,
* force diff_tree_oid() to feed all filepairs to diff_queue,
* and this code needs to be after diff_setup_done(), which
* usually makes find-copies-harder imply copy detection.
*/
......@@ -1259,9 +1259,9 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
if (is_null_oid(&target->commit->object.oid))
do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
target->commit->tree->object.oid.hash,
"", &diff_opts);
diff_tree_oid(&parent->tree->object.oid,
&target->commit->tree->object.oid,
"", &diff_opts);
if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
diffcore_std(&diff_opts);
......
......@@ -563,7 +563,7 @@ static int copy_notes_for_rebase(const struct am_state *state)
goto finish;
}
if (copy_note_for_rewrite(c, from_obj.hash, to_obj.hash))
if (copy_note_for_rewrite(c, &from_obj, &to_obj))
ret = error(_("Failed to copy notes from '%s' to '%s'"),
oid_to_hex(&from_obj), oid_to_hex(&to_obj));
}
......
......@@ -1806,7 +1806,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
cfg = init_copy_notes_for_rewrite("amend");
if (cfg) {
/* we are amending, so current_head is not NULL */
copy_note_for_rewrite(cfg, current_head->object.oid.hash, oid.hash);
copy_note_for_rewrite(cfg, &current_head->object.oid, &oid);
finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
}
run_rewrite_hook(&current_head->object.oid, &oid);
......
......@@ -7,7 +7,7 @@
static struct rev_info log_tree_opt;
static int diff_tree_commit_sha1(const struct object_id *oid)
static int diff_tree_commit_oid(const struct object_id *oid)
{
struct commit *commit = lookup_commit_reference(oid);
if (!commit)
......@@ -49,8 +49,8 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
return -1;
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
oid_to_hex(&tree2->object.oid));
diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
"", &log_tree_opt.diffopt);
diff_tree_oid(&tree1->object.oid, &tree2->object.oid,
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
return 0;
}
......@@ -98,7 +98,6 @@ static void diff_tree_tweak_rev(struct rev_info *rev, struct setup_revision_opt
int cmd_diff_tree(int argc, const char **argv, const char *prefix)
{
int nr_sha1;
char line[1000];
struct object *tree1, *tree2;
static struct rev_info *opt = &log_tree_opt;
......@@ -134,15 +133,14 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
* second one is marked UNINTERESTING, we recover the original
* order the user gave, i.e. "a..b", by swapping the trees.
*/
nr_sha1 = opt->pending.nr;
switch (nr_sha1) {
switch (opt->pending.nr) {
case 0:
if (!read_stdin)
usage(diff_tree_usage);
break;
case 1:
tree1 = opt->pending.objects[0].item;
diff_tree_commit_sha1(&tree1->oid);
diff_tree_commit_oid(&tree1->oid);
break;
case 2:
tree1 = opt->pending.objects[0].item;
......@@ -150,9 +148,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
if (tree2->flags & UNINTERESTING) {
SWAP(tree2, tree1);
}
diff_tree_sha1(tree1->oid.hash,
tree2->oid.hash,
"", &opt->diffopt);
diff_tree_oid(&tree1->oid, &tree2->oid, "", &opt->diffopt);
log_tree_diff_flush(opt);
break;
}
......
......@@ -56,8 +56,8 @@ static void stuff_change(struct diff_options *opt,
one = alloc_filespec(old_path);
two = alloc_filespec(new_path);
fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
fill_filespec(one, old_oid, old_oid_valid, old_mode);
fill_filespec(two, new_oid, new_oid_valid, new_mode);
diff_queue(&diff_queued_diff, one, two);
}
......@@ -174,7 +174,7 @@ static int builtin_diff_tree(struct rev_info *revs,
swap = 1;
oid[swap] = &ent0->item->oid;
oid[1 - swap] = &ent1->item->oid;
diff_tree_sha1(oid[0]->hash, oid[1]->hash, "", &revs->diffopt);
diff_tree_oid(oid[0], oid[1], "", &revs->diffopt);
log_tree_diff_flush(revs);
return 0;
}
......@@ -194,7 +194,7 @@ static int builtin_diff_combined(struct rev_info *revs,
revs->dense_combined_merges = revs->combine_merges = 1;
for (i = 1; i < ents; i++)
oid_array_append(&parents, &ent[i].item->oid);
diff_tree_combined(ent[0].item->oid.hash, &parents,
diff_tree_combined(&ent[0].item->oid, &parents,
revs->dense_combined_merges, revs);
oid_array_clear(&parents);
return 0;
......
......@@ -562,12 +562,12 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
get_object_mark(&commit->parents->item->object) != 0 &&
!full_tree) {
parse_commit_or_die(commit->parents->item);
diff_tree_sha1(commit->parents->item->tree->object.oid.hash,
commit->tree->object.oid.hash, "", &rev->diffopt);
diff_tree_oid(&commit->parents->item->tree->object.oid,
&commit->tree->object.oid, "", &rev->diffopt);
}
else
diff_root_tree_sha1(commit->tree->object.oid.hash,
"", &rev->diffopt);
diff_root_tree_oid(&commit->tree->object.oid,
"", &rev->diffopt);
/* Export the referenced blobs, and remember the marks. */
for (i = 0; i < diff_queued_diff.nr; i++)
......
......@@ -342,7 +342,7 @@ static int grep_oid(struct grep_opt *opt, const struct object_id *oid,
#ifndef NO_PTHREADS
if (num_threads) {
add_work(opt, GREP_SOURCE_SHA1, pathbuf.buf, path, oid);
add_work(opt, GREP_SOURCE_OID, pathbuf.buf, path, oid);
strbuf_release(&pathbuf);
return 0;
} else
......@@ -351,7 +351,7 @@ static int grep_oid(struct grep_opt *opt, const struct object_id *oid,
struct grep_source gs;
int hit;
grep_source_init(&gs, GREP_SOURCE_SHA1, pathbuf.buf, path, oid);
grep_source_init(&gs, GREP_SOURCE_OID, pathbuf.buf, path, oid);
strbuf_release(&pathbuf);
hit = grep_source(opt, &gs);
......@@ -587,7 +587,7 @@ static int grep_submodule_launch(struct grep_opt *opt,
* with the object's name: 'tree-name:filename'. In order to
* provide uniformity of output we want to pass the name of the
* parent project's object name to the submodule so the submodule can
* prefix its output with the parent's name and not its own SHA1.
* prefix its output with the parent's name and not its own OID.
*/
if (gs->identifier && end_of_base)
argv_array_pushf(&cp.args, "--parent-basename=%.*s",
......@@ -600,12 +600,12 @@ static int grep_submodule_launch(struct grep_opt *opt,
* If there is a tree identifier for the submodule, add the
* rev after adding the submodule options but before the
* pathspecs. To do this we listen for the '--' and insert the
* sha1 before pushing the '--' onto the child process argv
* oid before pushing the '--' onto the child process argv
* array.
*/
if (gs->identifier &&
!strcmp("--", submodule_options.argv[i])) {
argv_array_push(&cp.args, sha1_to_hex(gs->identifier));
argv_array_push(&cp.args, oid_to_hex(gs->identifier));
}
argv_array_push(&cp.args, submodule_options.argv[i]);
......@@ -635,11 +635,11 @@ static int grep_submodule_launch(struct grep_opt *opt,
/*
* Prep grep structures for a submodule grep
* sha1: the sha1 of the submodule or NULL if using the working tree
* oid: the oid of the submodule or NULL if using the working tree
* filename: name of the submodule including tree name of parent
* path: location of the submodule
*/
static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
static int grep_submodule(struct grep_opt *opt, const struct object_id *oid,
const char *filename, const char *path)
{
if (!is_submodule_initialized(path))
......@@ -649,7 +649,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
* If searching history, check for the presense of the
* submodule's gitdir before skipping the submodule.
*/
if (sha1) {
if (oid) {
const struct submodule *sub =
submodule_from_path(null_sha1, path);
if (sub)
......@@ -664,7 +664,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
#ifndef NO_PTHREADS
if (num_threads) {
add_work(opt, GREP_SOURCE_SUBMODULE, filename, path, sha1);
add_work(opt, GREP_SOURCE_SUBMODULE, filename, path, oid);
return 0;
} else
#endif
......@@ -673,7 +673,7 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
int hit;
grep_source_init(&gs, GREP_SOURCE_SUBMODULE,
filename, path, sha1);
filename, path, oid);
hit = grep_submodule_launch(opt, &gs);
grep_source_clear(&gs);
......@@ -792,7 +792,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
check_attr);
free(data);
} else if (recurse_submodules && S_ISGITLINK(entry.mode)) {
hit |= grep_submodule(opt, entry.oid->hash, base->buf,
hit |= grep_submodule(opt, entry.oid, base->buf,
base->buf + tn_len);
}
......
......@@ -1052,9 +1052,9 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
diff_setup_done(&opts);
diff_tree_sha1(origin->tree->object.oid.hash,
head->tree->object.oid.hash,
"", &opts);
diff_tree_oid(&origin->tree->object.oid,
&head->tree->object.oid,
"", &opts);
diffcore_std(&opts);
diff_flush(&opts);
......@@ -1363,7 +1363,7 @@ static void prepare_bases(struct base_tree_info *bases,
struct object_id *patch_id;
if (commit->util)
continue;
if (commit_patch_id(commit, &diffopt, oid.hash, 0))
if (commit_patch_id(commit, &diffopt, &oid, 0))
die(_("cannot get patch id"));
ALLOC_GROW(bases->patch_id, bases->nr_patch_id + 1, bases->alloc_patch_id);
patch_id = bases->patch_id + bases->nr_patch_id;
......
......@@ -415,7 +415,7 @@ static void finish(struct commit *head_commit,
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
opts.detect_rename = DIFF_DETECT_RENAME;
diff_setup_done(&opts);
diff_tree_sha1(head->hash, new_head->hash, "", &opts);
diff_tree_oid(head, new_head, "", &opts);
diffcore_std(&opts);
diff_flush(&opts);
}
......
This diff is collapsed.
......@@ -1026,6 +1026,13 @@ static inline void oidcpy(struct object_id *dst, const struct object_id *src)
hashcpy(dst->hash, src->hash);
}
static inline struct object_id *oiddup(const struct object_id *src)
{
struct object_id *dst = xmalloc(sizeof(struct object_id));
oidcpy(dst, src);
return dst;
}
static inline void hashclr(unsigned char *hash)
{
memset(hash, 0, GIT_SHA1_RAWSZ);
......
......@@ -302,7 +302,7 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,
return xcalloc(1, 1);
} else if (textconv) {
struct diff_filespec *df = alloc_filespec(path);
fill_filespec(df, oid->hash, 1, mode);
fill_filespec(df, oid, 1, mode);
*size = fill_textconv(textconv, df, &blob);
free_filespec(df);
} else {
......@@ -1022,7 +1022,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
&result_size, NULL, NULL);
} else if (textconv) {
struct diff_filespec *df = alloc_filespec(elem->path);
fill_filespec(df, null_sha1, 0, st.st_mode);
fill_filespec(df, &null_oid, 0, st.st_mode);
result_size = fill_textconv(textconv, df, &result);
free_filespec(df);
} else if (0 <= (fd = open(elem->path, O_RDONLY))) {
......@@ -1311,7 +1311,7 @@ static const char *path_path(void *obj)
/* find set of paths that every parent touches */
static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,
static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
const struct oid_array *parents, struct diff_options *opt)
{
struct combine_diff_path *paths = NULL;
......@@ -1336,7 +1336,7 @@ static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,
opt->output_format = stat_opt;
else
opt->output_format = DIFF_FORMAT_NO_OUTPUT;
diff_tree_sha1(parents->oid[i].hash, sha1, "", opt);
diff_tree_oid(&parents->oid[i], oid, "", opt);
diffcore_std(opt);
paths = intersect_paths(paths, i, num_parent);
......@@ -1360,31 +1360,31 @@ static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,
* rename/copy detection, etc, comparing all trees simultaneously (= faster).
*/
static struct combine_diff_path *find_paths_multitree(
const unsigned char *sha1, const struct oid_array *parents,
const struct object_id *oid, const struct oid_array *parents,
struct diff_options *opt)
{
int i, nparent = parents->nr;
const unsigned char **parents_sha1;
const struct object_id **parents_oid;
struct combine_diff_path paths_head;
struct strbuf base;
ALLOC_ARRAY(parents_sha1, nparent);
ALLOC_ARRAY(parents_oid, nparent);
for (i = 0; i < nparent; i++)
parents_sha1[i] = parents->oid[i].hash;
parents_oid[i] = &parents->oid[i];
/* fake list head, so worker can assume it is non-NULL */
paths_head.next = NULL;
strbuf_init(&base, PATH_MAX);
diff_tree_paths(&paths_head, sha1, parents_sha1, nparent, &base, opt);
diff_tree_paths(&paths_head, oid, parents_oid, nparent, &base, opt);
strbuf_release(&base);
free(parents_sha1);
free(parents_oid);
return paths_head.next;
}
void diff_tree_combined(const unsigned char *sha1,
void diff_tree_combined(const struct object_id *oid,
const struct oid_array *parents,
int dense,
struct rev_info *rev)
......@@ -1448,11 +1448,11 @@ void diff_tree_combined(const unsigned char *sha1,
* diff(sha1,parent_i) for all i to do the job, specifically
* for parent0.
*/
paths = find_paths_generic(sha1, parents, &diffopts);
paths = find_paths_generic(oid, parents, &diffopts);
}
else {
int stat_opt;
paths = find_paths_multitree(sha1, parents, &diffopts);
paths = find_paths_multitree(oid, parents, &diffopts);
/*
* show stat against the first parent even
......@@ -1463,7 +1463,7 @@ void diff_tree_combined(const unsigned char *sha1,
if (stat_opt) {
diffopts.output_format = stat_opt;
diff_tree_sha1(parents->oid[0].hash, sha1, "", &diffopts);
diff_tree_oid(&parents->oid[0], oid, "", &diffopts);
diffcore_std(&diffopts);
if (opt->orderfile)
diffcore_order(opt->orderfile);
......@@ -1539,6 +1539,6 @@ void diff_tree_combined_merge(const struct commit *commit, int dense,
oid_array_append(&parents, &parent->item->object.oid);
parent = parent->next;
}
diff_tree_combined(commit->object.oid.hash, &parents, dense, rev);
diff_tree_combined(&commit->object.oid, &parents, dense, rev);
oid_array_clear(&parents);
}
......@@ -101,7 +101,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
struct cache_entry *ce = active_cache[i];
int changed;
unsigned dirty_submodule = 0;
const unsigned char *old_sha1, *new_sha1;
const struct object_id *old_oid, *new_oid;
if (diff_can_quit_early(&revs->diffopt))
break;
......@@ -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;
}
......@@ -233,12 +233,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
continue;
}
oldmode = ce->ce_mode;
old_sha1 = ce->oid.hash;
new_sha1 = changed ? null_sha1 : ce->oid.hash;
old_oid = &ce->oid;
new_oid = changed ? &null_oid : &ce->oid;
diff_change(&revs->diffopt, oldmode, newmode,
old_sha1, new_sha1,
!is_null_sha1(old_sha1),
!is_null_sha1(new_sha1),
old_oid, new_oid,
!is_null_oid(old_oid),
!is_null_oid(new_oid),
ce->name, 0, dirty_submodule);
}
......@@ -255,21 +255,21 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
static void diff_index_show_file(struct rev_info *revs,
const char *prefix,
const struct cache_entry *ce,
const unsigned char *sha1, int sha1_valid,
const struct object_id *oid, int oid_valid,
unsigned int mode,
unsigned dirty_submodule)
{
diff_addremove(&revs->diffopt, prefix[0], mode,
sha1, sha1_valid, ce->name, dirty_submodule);
oid, oid_valid, ce->name, dirty_submodule);
}
static int get_stat_data(const struct cache_entry *ce,
const unsigned char **sha1p,
const struct object_id **oidp,
unsigned int *modep,
int cached, int match_missing,
unsigned *dirty_submodule, struct diff_options *diffopt)
{
const unsigned char *sha1 = ce->oid.hash;
const struct object_id *oid = &ce->oid;
unsigned int mode = ce->ce_mode;
if (!cached && !ce_uptodate(ce)) {
......@@ -280,7 +280,7 @@ static int get_stat_data(const struct cache_entry *ce,
return -1;
else if (changed) {
if (match_missing) {
*sha1p = sha1;
*oidp = oid;
*modep = mode;
return 0;
}
......@@ -290,11 +290,11 @@ static int get_stat_data(const struct cache_entry *ce,
0, dirty_submodule);
if (changed) {
mode = ce_mode_from_stat(ce, st.st_mode);
sha1 = null_sha1;
oid = &null_oid;
}
}
*sha1p = sha1;
*oidp = oid;
*modep = mode;
return 0;
}
......@@ -303,7 +303,7 @@ static void show_new_file(struct rev_info *revs,
const struct cache_entry *new,
int cached, int match_missing)
{
const unsigned char *sha1;
const struct object_id *oid;
unsigned int mode;
unsigned dirty_submodule = 0;
......@@ -311,11 +311,11 @@ static void show_new_file(struct rev_info *revs,
* New file in the index: it might actually be different in
* the working tree.
*/
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
if (get_stat_data(new, &oid, &mode, cached, match_missing,
&dirty_submodule, &revs->diffopt) < 0)
return;
diff_index_show_file(revs, "+", new, sha1, !is_null_sha1(sha1), mode, dirty_submodule);
diff_index_show_file(revs, "+", new, oid, !is_null_oid(oid), mode, dirty_submodule);
}
static int show_modified(struct rev_info *revs,
......@@ -325,20 +325,20 @@ static int show_modified(struct rev_info *revs,
int cached, int match_missing)
{
unsigned int mode, oldmode;
const unsigned char *sha1;
const struct object_id *oid;
unsigned dirty_submodule = 0;
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
if (get_stat_data(new, &oid, &mode, cached, match_missing,
&dirty_submodule, &revs->diffopt) < 0) {
if (report_missing)
diff_index_show_file(revs, "-", old,
old->oid.hash, 1, old->ce_mode,
&old->oid, 1, old->ce_mode,
0);
return -1;
}
if (revs->combine_merges && !cached &&
(hashcmp(sha1, old->oid.hash) || oidcmp(&old->oid, &new->oid))) {
(oidcmp(oid, &old->oid) || oidcmp(&old->oid, &new->oid))) {
struct combine_diff_path *p;
int pathlen = ce_namelen(new);
......@@ -362,12 +362,12 @@ static int show_modified(struct rev_info *revs,
}
oldmode = old->ce_mode;
if (mode == oldmode && !hashcmp(sha1, old->oid.hash) && !dirty_submodule &&
if (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&
!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
return 0;
diff_change(&revs->diffopt, oldmode, mode,
old->oid.hash, sha1, 1, !is_null_sha1(sha1),
&old->oid, oid, 1, !is_null_oid(oid),
old->name, 0, dirty_submodule);
return 0;
}
......@@ -409,7 +409,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
struct diff_filepair *pair;
pair = diff_unmerge(&revs->diffopt, idx->name);
if (tree)
fill_filespec(pair->one, tree->oid.hash, 1,
fill_filespec(pair->one, &tree->oid, 1,
tree->ce_mode);
return;
}
......@@ -426,7 +426,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
* Something removed from the tree?
*/
if (!idx) {
diff_index_show_file(revs, "-", tree, tree->oid.hash, 1,
diff_index_show_file(revs, "-", tree, &tree->oid, 1,
tree->ce_mode, 0);
return;
}
......
......@@ -82,7 +82,7 @@ static struct diff_filespec *noindex_filespec(const char *name, int mode)
if (!name)
name = "/dev/null";
s = alloc_filespec(name);
fill_filespec(s, null_sha1, 0, mode);
fill_filespec(s, &null_oid, 0, mode);
if (name == file_from_standard_input)
populate_from_stdin(s);
return s;
......
......@@ -2702,13 +2702,13 @@ void free_filespec(struct diff_filespec *spec)
}
}
void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
int sha1_valid, unsigned short mode)
void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
int oid_valid, unsigned short mode)
{
if (mode) {
spec->mode = canon_mode(mode);
hashcpy(spec->oid.hash, sha1);
spec->oid_valid = sha1_valid;
oidcpy(&spec->oid, oid);
spec->oid_valid = oid_valid;
}
}
......@@ -2717,7 +2717,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
* the work tree has that object contents, return true, so that
* prepare_temp_file() does not have to inflate and extract.
*/
static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file)
static int reuse_worktree_file(const char *name, const struct object_id *oid, int want_file)
{
const struct cache_entry *ce;
struct stat st;
......@@ -2748,7 +2748,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
* objects however would tend to be slower as they need
* to be individually opened and inflated.
*/
if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1))
if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(oid->hash))
return 0;
/*
......@@ -2768,7 +2768,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
* This is not the sha1 we are looking for, or
* unreusable because it is not a regular file.
*/
if (hashcmp(sha1, ce->oid.hash) || !S_ISREG(ce->ce_mode))
if (oidcmp(oid, &ce->oid) || !S_ISREG(ce->ce_mode))
return 0;
/*
......@@ -2842,7 +2842,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
return diff_populate_gitlink(s, size_only);
if (!s->oid_valid ||
reuse_worktree_file(s->path, s->oid.hash, 0)) {
reuse_worktree_file(s->path, &s->oid, 0)) {
struct strbuf buf = STRBUF_INIT;
struct stat st;
int fd;
......@@ -3008,7 +3008,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
if (!S_ISGITLINK(one->mode) &&
(!one->oid_valid ||
reuse_worktree_file(name, one->oid.hash, 1))) {
reuse_worktree_file(name, &one->oid, 1))) {
struct stat st;
if (lstat(name, &st) < 0) {
if (errno == ENOENT)
......@@ -3030,13 +3030,13 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
/* we can borrow from the file in the work tree */
temp->name = name;
if (!one->oid_valid)
sha1_to_hex_r(temp->hex, null_sha1);
oid_to_hex_r(temp->hex, &null_oid);
else
oid_to_hex_r(temp->hex, &one->oid);
/* Even though we may sometimes borrow the
* contents from the work tree, we always want
* one->mode. mode is trustworthy even when
* !(one->sha1_valid), as long as
* !(one->oid_valid), as long as
* DIFF_FILE_VALID(one).
*/
xsnprintf(temp->mode, sizeof(temp->mode), "%06o", one->mode);
......@@ -3239,7 +3239,7 @@ static void run_diff_cmd(const char *pgm,
fprintf(o->file, "* Unmerged path %s\n", name);
}
static void diff_fill_sha1_info(struct diff_filespec *one)
static void diff_fill_oid_info(struct diff_filespec *one)
{
if (DIFF_FILE_VALID(one)) {
if (!one->oid_valid) {
......@@ -3298,8 +3298,8 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
return;
}
diff_fill_sha1_info(one);
diff_fill_sha1_info(two);
diff_fill_oid_info(one);
diff_fill_oid_info(two);
if (!pgm &&
DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) &&
......@@ -3344,8 +3344,8 @@ static void run_diffstat(struct diff_filepair *p, struct diff_options *o,
if (o->prefix_length)
strip_prefix(o->prefix_length, &name, &other);
diff_fill_sha1_info(p->one);
diff_fill_sha1_info(p->two);
diff_fill_oid_info(p->one);
diff_fill_oid_info(p->two);
builtin_diffstat(name, other, p->one, p->two, diffstat, o, p);
}
......@@ -3368,8 +3368,8 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
if (o->prefix_length)
strip_prefix(o->prefix_length, &name, &other);
diff_fill_sha1_info(p->one);
diff_fill_sha1_info(p->two);
diff_fill_oid_info(p->one);