From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>
Subject: [PATCH 5/6] tree-walk: convert tree_entry_extract to struct object_id
Date: Sun, 17 Apr 2016 23:10:40 +0000 [thread overview]
Message-ID: <1460934641-435791-6-git-send-email-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <1460934641-435791-1-git-send-email-sandals@crustytoothpaste.net>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
fsck.c | 6 +++---
match-trees.c | 12 ++++++------
tree-diff.c | 2 +-
tree-walk.c | 10 +++++-----
tree-walk.h | 4 ++--
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/fsck.c b/fsck.c
index 606eba8c..92b17f5d 100644
--- a/fsck.c
+++ b/fsck.c
@@ -450,11 +450,11 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
while (desc.size) {
unsigned mode;
const char *name;
- const unsigned char *sha1;
+ const struct object_id *oid;
- sha1 = tree_entry_extract(&desc, &name, &mode);
+ oid = tree_entry_extract(&desc, &name, &mode);
- has_null_sha1 |= is_null_sha1(sha1);
+ has_null_sha1 |= is_null_oid(oid);
has_full_path |= !!strchr(name, '/');
has_empty_name |= !*name;
has_dot |= !strcmp(name, ".");
diff --git a/match-trees.c b/match-trees.c
index 751f8f20..8ca7c68f 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -131,14 +131,14 @@ static void match_trees(const unsigned char *hash1,
while (one.size) {
const char *path;
- const unsigned char *elem;
+ const struct object_id *elem;
unsigned mode;
int score;
elem = tree_entry_extract(&one, &path, &mode);
if (!S_ISDIR(mode))
goto next;
- score = score_trees(elem, hash2);
+ score = score_trees(elem->hash, hash2);
if (*best_score < score) {
free(*best_match);
*best_match = xstrfmt("%s%s", base, path);
@@ -146,7 +146,7 @@ static void match_trees(const unsigned char *hash1,
}
if (recurse_limit) {
char *newbase = xstrfmt("%s%s/", base, path);
- match_trees(elem, hash2, best_score, best_match,
+ match_trees(elem->hash, hash2, best_score, best_match,
newbase, recurse_limit - 1);
free(newbase);
}
@@ -191,15 +191,15 @@ static int splice_tree(const unsigned char *hash1,
while (desc.size) {
const char *name;
unsigned mode;
- const unsigned char *sha1;
+ const struct object_id *oid;
- sha1 = tree_entry_extract(&desc, &name, &mode);
+ oid = tree_entry_extract(&desc, &name, &mode);
if (strlen(name) == toplen &&
!memcmp(name, prefix, toplen)) {
if (!S_ISDIR(mode))
die("entry %s in tree %s is not a tree",
name, sha1_to_hex(hash1));
- rewrite_here = (unsigned char *) sha1;
+ rewrite_here = (unsigned char *) oid->hash;
break;
}
update_tree_entry(&desc);
diff --git a/tree-diff.c b/tree-diff.c
index 402f9ff2..ff4e0d3c 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -183,7 +183,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
if (t) {
/* path present in resulting tree */
- sha1 = tree_entry_extract(t, &path, &mode);
+ sha1 = tree_entry_extract(t, &path, &mode)->hash;
pathlen = tree_entry_len(&t->entry);
isdir = S_ISDIR(mode);
} else {
diff --git a/tree-walk.c b/tree-walk.c
index fab57dd5..ce278424 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -433,10 +433,10 @@ static int find_tree_entry(struct tree_desc *t, const char *name, unsigned char
int namelen = strlen(name);
while (t->size) {
const char *entry;
- const unsigned char *sha1;
+ const struct object_id *oid;
int entrylen, cmp;
- sha1 = tree_entry_extract(t, &entry, mode);
+ oid = tree_entry_extract(t, &entry, mode);
entrylen = tree_entry_len(&t->entry);
update_tree_entry(t);
if (entrylen > namelen)
@@ -447,7 +447,7 @@ static int find_tree_entry(struct tree_desc *t, const char *name, unsigned char
if (cmp < 0)
break;
if (entrylen == namelen) {
- hashcpy(result, sha1);
+ hashcpy(result, oid->hash);
return 0;
}
if (name[entrylen] != '/')
@@ -455,10 +455,10 @@ static int find_tree_entry(struct tree_desc *t, const char *name, unsigned char
if (!S_ISDIR(*mode))
break;
if (++entrylen == namelen) {
- hashcpy(result, sha1);
+ hashcpy(result, oid->hash);
return 0;
}
- return get_tree_entry(sha1, name + entrylen, result, mode);
+ return get_tree_entry(oid->hash, name + entrylen, result, mode);
}
return -1;
}
diff --git a/tree-walk.h b/tree-walk.h
index 58f31f55..97a7d695 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -13,11 +13,11 @@ struct tree_desc {
unsigned int size;
};
-static inline const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
+static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
{
*pathp = desc->entry.path;
*modep = desc->entry.mode;
- return desc->entry.oid->hash;
+ return desc->entry.oid;
}
static inline int tree_entry_len(const struct name_entry *ne)
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-04-18 2:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-17 23:10 [PATCH 0/6] object_id Part 3 brian m. carlson
2016-04-17 23:10 ` [PATCH 1/6] Introduce a get_oid function brian m. carlson
2016-04-17 23:10 ` [PATCH 2/6] test-match-trees: convert to use struct object_id brian m. carlson
2016-04-17 23:10 ` [PATCH 3/6] match-trees: convert shift_tree and shift_tree_by to object_id brian m. carlson
2016-04-17 23:10 ` [PATCH 4/6] Convert struct name_entry to use struct object_id brian m. carlson
2016-04-19 23:02 ` Junio C Hamano
2016-04-19 23:16 ` brian m. carlson
2016-04-20 0:17 ` Junio C Hamano
2016-04-17 23:10 ` brian m. carlson [this message]
2016-04-17 23:10 ` [PATCH 6/6] match-trees: convert several leaf functions to " brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460934641-435791-6-git-send-email-sandals@crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).