mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'rs/object-id'
Conversion from uchar[20] to struct object_id continues. * rs/object-id: tree-walk: convert fill_tree_descriptor() to object_id
This commit is contained in:
commit
11bd95604a
|
@ -55,9 +55,9 @@ Initializing
|
|||
|
||||
`fill_tree_descriptor`::
|
||||
|
||||
Initialize a `tree_desc` and decode its first entry given the sha1 of
|
||||
a tree. Returns the `buffer` member if the sha1 is a valid tree
|
||||
identifier and NULL otherwise.
|
||||
Initialize a `tree_desc` and decode its first entry given the
|
||||
object ID of a tree. Returns the `buffer` member if the latter
|
||||
is a valid tree identifier and NULL otherwise.
|
||||
|
||||
`setup_traverse_info`::
|
||||
|
||||
|
|
|
@ -213,11 +213,11 @@ static void unresolved_directory(const struct traverse_info *info,
|
|||
|
||||
newbase = traverse_path(info, p);
|
||||
|
||||
#define ENTRY_SHA1(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid->hash : NULL)
|
||||
buf0 = fill_tree_descriptor(t+0, ENTRY_SHA1(n + 0));
|
||||
buf1 = fill_tree_descriptor(t+1, ENTRY_SHA1(n + 1));
|
||||
buf2 = fill_tree_descriptor(t+2, ENTRY_SHA1(n + 2));
|
||||
#undef ENTRY_SHA1
|
||||
#define ENTRY_OID(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid : NULL)
|
||||
buf0 = fill_tree_descriptor(t + 0, ENTRY_OID(n + 0));
|
||||
buf1 = fill_tree_descriptor(t + 1, ENTRY_OID(n + 1));
|
||||
buf2 = fill_tree_descriptor(t + 2, ENTRY_OID(n + 2));
|
||||
#undef ENTRY_OID
|
||||
|
||||
merge_trees(t, newbase);
|
||||
|
||||
|
@ -352,7 +352,7 @@ static void *get_tree_descriptor(struct tree_desc *desc, const char *rev)
|
|||
|
||||
if (get_oid(rev, &oid))
|
||||
die("unknown rev %s", rev);
|
||||
buf = fill_tree_descriptor(desc, oid.hash);
|
||||
buf = fill_tree_descriptor(desc, &oid);
|
||||
if (!buf)
|
||||
die("%s is not a tree", rev);
|
||||
return buf;
|
||||
|
|
|
@ -75,13 +75,13 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
|
|||
struct object_id head_oid;
|
||||
if (get_oid("HEAD", &head_oid))
|
||||
return error(_("You do not have a valid HEAD."));
|
||||
if (!fill_tree_descriptor(desc, head_oid.hash))
|
||||
if (!fill_tree_descriptor(desc, &head_oid))
|
||||
return error(_("Failed to find tree of HEAD."));
|
||||
nr++;
|
||||
opts.fn = twoway_merge;
|
||||
}
|
||||
|
||||
if (!fill_tree_descriptor(desc + nr - 1, oid->hash))
|
||||
if (!fill_tree_descriptor(desc + nr - 1, oid))
|
||||
return error(_("Failed to find tree of %s."), oid_to_hex(oid));
|
||||
if (unpack_trees(nr, desc, &opts))
|
||||
return -1;
|
||||
|
|
2
notes.c
2
notes.c
|
@ -425,7 +425,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
|
|||
unsigned char type;
|
||||
struct leaf_node *l;
|
||||
|
||||
buf = fill_tree_descriptor(&desc, subtree->val_oid.hash);
|
||||
buf = fill_tree_descriptor(&desc, &subtree->val_oid);
|
||||
if (!buf)
|
||||
die("Could not read %s for notes-index",
|
||||
oid_to_hex(&subtree->val_oid));
|
||||
|
|
|
@ -421,9 +421,8 @@ static struct combine_diff_path *ll_diff_tree_paths(
|
|||
* diff_tree_oid(parent, commit) )
|
||||
*/
|
||||
for (i = 0; i < nparent; ++i)
|
||||
tptree[i] = fill_tree_descriptor(&tp[i],
|
||||
parents_oid[i] ? parents_oid[i]->hash : NULL);
|
||||
ttree = fill_tree_descriptor(&t, oid ? oid->hash : NULL);
|
||||
tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]);
|
||||
ttree = fill_tree_descriptor(&t, oid);
|
||||
|
||||
/* Enable recursion indefinitely */
|
||||
opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);
|
||||
|
|
|
@ -78,15 +78,16 @@ int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned l
|
|||
return result;
|
||||
}
|
||||
|
||||
void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1)
|
||||
void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid)
|
||||
{
|
||||
unsigned long size = 0;
|
||||
void *buf = NULL;
|
||||
|
||||
if (sha1) {
|
||||
buf = read_object_with_reference(sha1, tree_type, &size, NULL);
|
||||
if (oid) {
|
||||
buf = read_object_with_reference(oid->hash, tree_type, &size,
|
||||
NULL);
|
||||
if (!buf)
|
||||
die("unable to read tree %s", sha1_to_hex(sha1));
|
||||
die("unable to read tree %s", oid_to_hex(oid));
|
||||
}
|
||||
init_tree_desc(desc, buf, size);
|
||||
return buf;
|
||||
|
|
|
@ -42,7 +42,7 @@ int init_tree_desc_gently(struct tree_desc *desc, const void *buf, unsigned long
|
|||
int tree_entry(struct tree_desc *, struct name_entry *);
|
||||
int tree_entry_gently(struct tree_desc *, struct name_entry *);
|
||||
|
||||
void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1);
|
||||
void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid);
|
||||
|
||||
struct traverse_info;
|
||||
typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
|
||||
|
|
|
@ -662,10 +662,10 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
|
|||
else if (i > 1 && are_same_oid(&names[i], &names[i - 2]))
|
||||
t[i] = t[i - 2];
|
||||
else {
|
||||
const unsigned char *sha1 = NULL;
|
||||
const struct object_id *oid = NULL;
|
||||
if (dirmask & 1)
|
||||
sha1 = names[i].oid->hash;
|
||||
buf[nr_buf++] = fill_tree_descriptor(t+i, sha1);
|
||||
oid = names[i].oid;
|
||||
buf[nr_buf++] = fill_tree_descriptor(t + i, oid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue