diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2016-04-17 23:10:39 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-25 14:23:42 -0700 |
commit | 7d924c9139e33e7599d7aed0446e634c427a5f15 (patch) | |
tree | 61d1667fff3d183398d5223d86805ec44264a518 | |
parent | 82db3d44e7a9d9219dd8e19607026bae9e435012 (diff) | |
download | git-7d924c9139e33e7599d7aed0446e634c427a5f15.tar.gz |
struct name_entry: use struct object_id instead of unsigned char sha1[20]
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/grep.c | 6 | ||||
-rw-r--r-- | builtin/merge-tree.c | 18 | ||||
-rw-r--r-- | builtin/pack-objects.c | 4 | ||||
-rw-r--r-- | builtin/reflog.c | 4 | ||||
-rw-r--r-- | cache-tree.c | 4 | ||||
-rw-r--r-- | fsck.c | 4 | ||||
-rw-r--r-- | http-push.c | 4 | ||||
-rw-r--r-- | list-objects.c | 6 | ||||
-rw-r--r-- | match-trees.c | 2 | ||||
-rw-r--r-- | notes.c | 4 | ||||
-rw-r--r-- | revision.c | 4 | ||||
-rw-r--r-- | tree-diff.c | 6 | ||||
-rw-r--r-- | tree-walk.c | 6 | ||||
-rw-r--r-- | tree-walk.h | 6 | ||||
-rw-r--r-- | tree.c | 10 | ||||
-rw-r--r-- | unpack-trees.c | 4 | ||||
-rw-r--r-- | walker.c | 4 |
17 files changed, 48 insertions, 48 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index aa7435f380..b15020067b 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -438,7 +438,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, strbuf_add(base, entry.path, te_len); if (S_ISREG(entry.mode)) { - hit |= grep_sha1(opt, entry.sha1, base->buf, tn_len, + hit |= grep_sha1(opt, entry.oid->hash, base->buf, tn_len, check_attr ? base->buf + tn_len : NULL); } else if (S_ISDIR(entry.mode)) { @@ -447,10 +447,10 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, void *data; unsigned long size; - data = lock_and_read_sha1_file(entry.sha1, &type, &size); + data = lock_and_read_sha1_file(entry.oid->hash, &type, &size); if (!data) die(_("unable to read tree (%s)"), - sha1_to_hex(entry.sha1)); + oid_to_hex(entry.oid)); strbuf_addch(base, '/'); init_tree_desc(&sub, data, size); diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index ca570041df..5b7ab9b967 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -150,15 +150,15 @@ static void show_result(void) /* An empty entry never compares same, not even to another empty entry */ static int same_entry(struct name_entry *a, struct name_entry *b) { - return a->sha1 && - b->sha1 && - !hashcmp(a->sha1, b->sha1) && + return a->oid && + b->oid && + !oidcmp(a->oid, b->oid) && a->mode == b->mode; } static int both_empty(struct name_entry *a, struct name_entry *b) { - return !(a->sha1 || b->sha1); + return !(a->oid || b->oid); } static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path) @@ -188,8 +188,8 @@ static void resolve(const struct traverse_info *info, struct name_entry *ours, s return; path = traverse_path(info, result); - orig = create_entry(2, ours->mode, ours->sha1, path); - final = create_entry(0, result->mode, result->sha1, path); + orig = create_entry(2, ours->mode, ours->oid->hash, path); + final = create_entry(0, result->mode, result->oid->hash, path); final->link = orig; @@ -213,7 +213,7 @@ 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)->sha1 : NULL) +#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)); @@ -239,7 +239,7 @@ static struct merge_list *link_entry(unsigned stage, const struct traverse_info path = entry->path; else path = traverse_path(info, n); - link = create_entry(stage, n->mode, n->sha1, path); + link = create_entry(stage, n->mode, n->oid->hash, path); link->link = entry; return link; } @@ -314,7 +314,7 @@ static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, s } if (same_entry(entry+0, entry+1)) { - if (entry[2].sha1 && !S_ISDIR(entry[2].mode)) { + if (entry[2].oid && !S_ISDIR(entry[2].mode)) { /* We did not touch, they modified -- take theirs */ resolve(info, entry+1, entry+2); return mask; diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index a27de5b323..d56b2c2d1e 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1186,7 +1186,7 @@ static void add_pbase_object(struct tree_desc *tree, if (cmp < 0) return; if (name[cmplen] != '/') { - add_object_entry(entry.sha1, + add_object_entry(entry.oid->hash, object_type(entry.mode), fullname, 1); return; @@ -1197,7 +1197,7 @@ static void add_pbase_object(struct tree_desc *tree, const char *down = name+cmplen+1; int downlen = name_cmp_len(down); - tree = pbase_tree_get(entry.sha1); + tree = pbase_tree_get(entry.oid->hash); if (!tree) return; init_tree_desc(&sub, tree->tree_data, tree->tree_size); diff --git a/builtin/reflog.c b/builtin/reflog.c index 2d46b6482a..7a7136e53e 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -84,8 +84,8 @@ static int tree_is_complete(const unsigned char *sha1) init_tree_desc(&desc, tree->buffer, tree->size); complete = 1; while (tree_entry(&desc, &entry)) { - if (!has_sha1_file(entry.sha1) || - (S_ISDIR(entry.mode) && !tree_is_complete(entry.sha1))) { + if (!has_sha1_file(entry.oid->hash) || + (S_ISDIR(entry.mode) && !tree_is_complete(entry.oid->hash))) { tree->object.flags |= INCOMPLETE; complete = 0; } diff --git a/cache-tree.c b/cache-tree.c index 3ebf9c3aa4..ddf0cc9f9a 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -663,7 +663,7 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree) cnt++; else { struct cache_tree_sub *sub; - struct tree *subtree = lookup_tree(entry.sha1); + struct tree *subtree = lookup_tree(entry.oid->hash); if (!subtree->object.parsed) parse_tree(subtree); sub = cache_tree_sub(it, entry.path); @@ -710,7 +710,7 @@ int cache_tree_matches_traversal(struct cache_tree *root, it = find_cache_tree_from_traversal(root, info); it = cache_tree_find(it, ent->path); - if (it && it->entry_count > 0 && !hashcmp(ent->sha1, it->sha1)) + if (it && it->entry_count > 0 && !hashcmp(ent->oid->hash, it->sha1)) return it->entry_count; return 0; } @@ -312,9 +312,9 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op if (S_ISGITLINK(entry.mode)) continue; if (S_ISDIR(entry.mode)) - result = options->walk(&lookup_tree(entry.sha1)->object, OBJ_TREE, data, options); + result = options->walk(&lookup_tree(entry.oid->hash)->object, OBJ_TREE, data, options); else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) - result = options->walk(&lookup_blob(entry.sha1)->object, OBJ_BLOB, data, options); + result = options->walk(&lookup_blob(entry.oid->hash)->object, OBJ_BLOB, data, options); else { result = error("in tree %s: entry %s has bad mode %.6o", oid_to_hex(&tree->object.oid), entry.path, entry.mode); diff --git a/http-push.c b/http-push.c index bd60668707..ded0b742ad 100644 --- a/http-push.c +++ b/http-push.c @@ -1312,10 +1312,10 @@ static struct object_list **process_tree(struct tree *tree, while (tree_entry(&desc, &entry)) switch (object_type(entry.mode)) { case OBJ_TREE: - p = process_tree(lookup_tree(entry.sha1), p); + p = process_tree(lookup_tree(entry.oid->hash), p); break; case OBJ_BLOB: - p = process_blob(lookup_blob(entry.sha1), p); + p = process_blob(lookup_blob(entry.oid->hash), p); break; default: /* Subproject commit - not in this repository */ diff --git a/list-objects.c b/list-objects.c index 917cc5d7c9..f3ca6aafb7 100644 --- a/list-objects.c +++ b/list-objects.c @@ -110,16 +110,16 @@ static void process_tree(struct rev_info *revs, if (S_ISDIR(entry.mode)) process_tree(revs, - lookup_tree(entry.sha1), + lookup_tree(entry.oid->hash), show, base, entry.path, cb_data); else if (S_ISGITLINK(entry.mode)) - process_gitlink(revs, entry.sha1, + process_gitlink(revs, entry.oid->hash, show, base, entry.path, cb_data); else process_blob(revs, - lookup_blob(entry.sha1), + lookup_blob(entry.oid->hash), show, base, entry.path, cb_data); } diff --git a/match-trees.c b/match-trees.c index 9977752a67..751f8f2011 100644 --- a/match-trees.c +++ b/match-trees.c @@ -104,7 +104,7 @@ static int score_trees(const unsigned char *hash1, const unsigned char *hash2) else if (cmp > 0) /* path2 does not appear in one */ score += score_missing(e2.mode, e2.path); - else if (hashcmp(e1.sha1, e2.sha1)) + else if (oidcmp(e1.oid, e2.oid)) /* they are different */ score += score_differs(e1.mode, e2.mode, e1.path); else @@ -446,7 +446,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree, l = (struct leaf_node *) xcalloc(1, sizeof(struct leaf_node)); hashcpy(l->key_sha1, object_sha1); - hashcpy(l->val_sha1, entry.sha1); + hashcpy(l->val_sha1, entry.oid->hash); if (len < 20) { if (!S_ISDIR(entry.mode) || path_len != 2) goto handle_non_note; /* not subtree */ @@ -493,7 +493,7 @@ handle_non_note: } strbuf_addstr(&non_note_path, entry.path); add_non_note(t, strbuf_detach(&non_note_path, NULL), - entry.mode, entry.sha1); + entry.mode, entry.oid->hash); } } free(buf); diff --git a/revision.c b/revision.c index 8b2dfe3160..a356dde09e 100644 --- a/revision.c +++ b/revision.c @@ -59,10 +59,10 @@ static void mark_tree_contents_uninteresting(struct tree *tree) while (tree_entry(&desc, &entry)) { switch (object_type(entry.mode)) { case OBJ_TREE: - mark_tree_uninteresting(lookup_tree(entry.sha1)); + mark_tree_uninteresting(lookup_tree(entry.oid->hash)); break; case OBJ_BLOB: - mark_blob_uninteresting(lookup_blob(entry.sha1)); + mark_blob_uninteresting(lookup_blob(entry.oid->hash)); break; default: /* Subproject commit - not in this repository */ diff --git a/tree-diff.c b/tree-diff.c index 4dda9a14ab..402f9ff23a 100644 --- a/tree-diff.c +++ b/tree-diff.c @@ -229,7 +229,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, DIFF_STATUS_ADDED; if (tpi_valid) { - sha1_i = tp[i].entry.sha1; + sha1_i = tp[i].entry.oid->hash; mode_i = tp[i].entry.mode; } else { @@ -270,7 +270,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p, /* same rule as in emitthis */ int tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ); - parents_sha1[i] = tpi_valid ? tp[i].entry.sha1 + parents_sha1[i] = tpi_valid ? tp[i].entry.oid->hash : NULL; } @@ -482,7 +482,7 @@ static struct combine_diff_path *ll_diff_tree_paths( continue; /* diff(t,pi) != ΓΈ */ - if (hashcmp(t.entry.sha1, tp[i].entry.sha1) || + if (oidcmp(t.entry.oid, tp[i].entry.oid) || (t.entry.mode != tp[i].entry.mode)) continue; diff --git a/tree-walk.c b/tree-walk.c index cd4bb2c38b..fab57dd524 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -38,7 +38,7 @@ static void decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned /* Initialize the descriptor entry */ desc->entry.path = path; desc->entry.mode = canon_mode(mode); - desc->entry.sha1 = (const unsigned char *)(path + len); + desc->entry.oid = (const struct object_id *)(path + len); } void init_tree_desc(struct tree_desc *desc, const void *buffer, unsigned long size) @@ -76,7 +76,7 @@ static void entry_extract(struct tree_desc *t, struct name_entry *a) void update_tree_entry(struct tree_desc *desc) { const void *buf = desc->buffer; - const unsigned char *end = desc->entry.sha1 + 20; + const unsigned char *end = desc->entry.oid->hash + 20; unsigned long size = desc->size; unsigned long len = end - (const unsigned char *)buf; @@ -110,7 +110,7 @@ void setup_traverse_info(struct traverse_info *info, const char *base) pathlen--; info->pathlen = pathlen ? pathlen + 1 : 0; info->name.path = base; - info->name.sha1 = (void *)(base + pathlen + 1); + info->name.oid = (void *)(base + pathlen + 1); if (pathlen) info->prev = &dummy; } diff --git a/tree-walk.h b/tree-walk.h index 174eb617df..58f31f5596 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -2,7 +2,7 @@ #define TREE_WALK_H struct name_entry { - const unsigned char *sha1; + const struct object_id *oid; const char *path; unsigned int mode; }; @@ -17,12 +17,12 @@ static inline const unsigned char *tree_entry_extract(struct tree_desc *desc, co { *pathp = desc->entry.path; *modep = desc->entry.mode; - return desc->entry.sha1; + return desc->entry.oid->hash; } static inline int tree_entry_len(const struct name_entry *ne) { - return (const char *)ne->sha1 - ne->path - 1; + return (const char *)ne->oid - ne->path - 1; } void update_tree_entry(struct tree_desc *); @@ -76,7 +76,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, continue; } - switch (fn(entry.sha1, base, + switch (fn(entry.oid->hash, base, entry.path, entry.mode, stage, context)) { case 0: continue; @@ -87,19 +87,19 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, } if (S_ISDIR(entry.mode)) - hashcpy(sha1, entry.sha1); + hashcpy(sha1, entry.oid->hash); else if (S_ISGITLINK(entry.mode)) { struct commit *commit; - commit = lookup_commit(entry.sha1); + commit = lookup_commit(entry.oid->hash); if (!commit) die("Commit %s in submodule path %s%s not found", - sha1_to_hex(entry.sha1), + oid_to_hex(entry.oid), base->buf, entry.path); if (parse_commit(commit)) die("Invalid commit %s in submodule path %s%s", - sha1_to_hex(entry.sha1), + oid_to_hex(entry.oid), base->buf, entry.path); hashcpy(sha1, commit->tree->object.oid.hash); diff --git a/unpack-trees.c b/unpack-trees.c index 9f55cc28b9..11308e9e5b 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -475,7 +475,7 @@ static int traverse_trees_recursive(int n, unsigned long dirmask, for (i = 0; i < n; i++, dirmask >>= 1) { const unsigned char *sha1 = NULL; if (dirmask & 1) - sha1 = names[i].sha1; + sha1 = names[i].oid->hash; buf[i] = fill_tree_descriptor(t+i, sha1); } @@ -591,7 +591,7 @@ static struct cache_entry *create_ce_entry(const struct traverse_info *info, con ce->ce_mode = create_ce_mode(n->mode); ce->ce_flags = create_ce_flags(stage); ce->ce_namelen = len; - hashcpy(ce->sha1, n->sha1); + hashcpy(ce->sha1, n->oid->hash); make_traverse_path(ce->name, info, n); return ce; @@ -43,12 +43,12 @@ static int process_tree(struct walker *walker, struct tree *tree) if (S_ISGITLINK(entry.mode)) continue; if (S_ISDIR(entry.mode)) { - struct tree *tree = lookup_tree(entry.sha1); + struct tree *tree = lookup_tree(entry.oid->hash); if (tree) obj = &tree->object; } else { - struct blob *blob = lookup_blob(entry.sha1); + struct blob *blob = lookup_blob(entry.oid->hash); if (blob) obj = &blob->object; } |