@@ -587,10 +587,10 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
strbuf_add(base, entry.path, te_len);
- if (S_ISREG(entry.mode)) {
+ if (entry.object_type == OBJ_BLOB) {
hit |= grep_oid(opt, &entry.oid, base->buf, tn_len,
check_attr ? base->buf + tn_len : NULL);
- } else if (S_ISDIR(entry.mode)) {
+ } else if (entry.object_type == OBJ_TREE) {
enum object_type type;
struct tree_desc sub;
void *data;
@@ -606,7 +606,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
hit |= grep_tree(opt, pathspec, &sub, base, tn_len,
check_attr);
free(data);
- } else if (recurse_submodules && S_ISGITLINK(entry.mode)) {
+ } else if (recurse_submodules && entry.object_type == OBJ_COMMIT) {
hit |= grep_submodule(opt, pathspec, &entry.oid,
base->buf, base->buf + tn_len,
1); /* ignored */
@@ -275,11 +275,11 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
if (dirmask == mask)
return;
- if (n[2].mode && !S_ISDIR(n[2].mode))
+ if (n[2].object_type != OBJ_TREE)
entry = link_entry(3, info, n + 2, entry);
- if (n[1].mode && !S_ISDIR(n[1].mode))
+ if (n[1].object_type != OBJ_TREE)
entry = link_entry(2, info, n + 1, entry);
- if (n[0].mode && !S_ISDIR(n[0].mode))
+ if (n[0].object_type != OBJ_TREE)
entry = link_entry(1, info, n + 0, entry);
add_merge_entry(entry);
@@ -324,7 +324,8 @@ static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, s
}
if (same_entry(entry+0, entry+1)) {
- if (!is_null_oid(&entry[2].oid) && !S_ISDIR(entry[2].mode)) {
+ if (!is_null_oid(&entry[2].oid) &&
+ entry[2].object_type != OBJ_TREE) {
/* We did not touch, they modified -- take theirs */
resolve(info, entry+1, entry+2);
return mask;
@@ -1524,7 +1524,7 @@ static void add_pbase_object(struct tree_desc *tree,
int cmp;
while (tree_entry(tree,&entry)) {
- if (S_ISGITLINK(entry.mode))
+ if (entry.object_type == OBJ_COMMIT)
continue;
cmp = tree_entry_len(&entry) != cmplen ? 1 :
memcmp(name, entry.path, cmplen);
@@ -1538,7 +1538,7 @@ static void add_pbase_object(struct tree_desc *tree,
fullname, 1);
return;
}
- if (S_ISDIR(entry.mode)) {
+ if (entry.object_type == OBJ_TREE) {
struct tree_desc sub;
struct pbase_tree_cache *tree;
const char *down = name+cmplen+1;
@@ -95,7 +95,8 @@ static int tree_is_complete(const struct object_id *oid)
complete = 1;
while (tree_entry(&desc, &entry)) {
if (!has_object_file(&entry.oid) ||
- (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
+ (entry.object_type == OBJ_TREE &&
+ !tree_is_complete(&entry.oid))) {
tree->object.flags |= INCOMPLETE;
complete = 0;
}
@@ -726,7 +726,7 @@ static void prime_cache_tree_rec(struct repository *r,
init_tree_desc(&desc, tree->buffer, tree->size);
cnt = 0;
while (tree_entry(&desc, &entry)) {
- if (!S_ISDIR(entry.mode))
+ if (entry.object_type != OBJ_TREE)
cnt++;
else {
struct cache_tree_sub *sub;
@@ -293,7 +293,7 @@ void resolve_tree_islands(struct repository *r,
while (tree_entry(&desc, &entry)) {
struct object *obj;
- if (S_ISGITLINK(entry.mode))
+ if (entry.object_type == OBJ_COMMIT)
continue;
obj = lookup_object(r, &entry.oid);
@@ -418,7 +418,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
if (path_len == 2 * (hashsz - prefix_len)) {
/* This is potentially the remainder of the SHA-1 */
- if (!S_ISREG(entry.mode))
+ if (entry.object_type != OBJ_BLOB)
/* notes must be blobs */
goto handle_non_note;
@@ -431,7 +431,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
/* This is potentially an internal node */
size_t len = prefix_len;
- if (!S_ISDIR(entry.mode))
+ if (entry.object_type != OBJ_TREE)
/* internal nodes must be trees */
goto handle_non_note;
@@ -1297,7 +1297,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
if (dirmask) {
/* special case: "diff-index --cached" looking at a tree */
if (o->diff_index_cached &&
- n == 1 && dirmask == 1 && S_ISDIR(names->mode)) {
+ n == 1 && dirmask == 1 && names->object_type == OBJ_TREE) {
int matches;
matches = cache_tree_matches_traversal(o->src_index->cache_tree,
names, info);
Refactor more users of the "entry.mode" field to use the new "entry.object_type" field. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- builtin/grep.c | 6 +++--- builtin/merge-tree.c | 9 +++++---- builtin/pack-objects.c | 4 ++-- builtin/reflog.c | 3 ++- cache-tree.c | 2 +- delta-islands.c | 2 +- notes.c | 4 ++-- unpack-trees.c | 2 +- 8 files changed, 17 insertions(+), 15 deletions(-)