summaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/tree.c b/tree.c
index bb02c1c..f79ff98 100644
--- a/tree.c
+++ b/tree.c
@@ -30,9 +30,12 @@ static int read_one_entry_opt(const unsigned char *sha1, const char *base, int b
return add_cache_entry(ce, opt);
}
-static int read_one_entry(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage, void *context)
+static int read_one_entry(const unsigned char *sha1, struct strbuf *base,
+ const char *pathname, unsigned mode, int stage,
+ void *context)
{
- return read_one_entry_opt(sha1, base, baselen, pathname, mode, stage,
+ return read_one_entry_opt(sha1, base->buf, base->len, pathname,
+ mode, stage,
ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
}
@@ -40,9 +43,12 @@ static int read_one_entry(const unsigned char *sha1, const char *base, int basel
* This is used when the caller knows there is no existing entries at
* the stage that will conflict with the entry being added.
*/
-static int read_one_entry_quick(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage, void *context)
+static int read_one_entry_quick(const unsigned char *sha1, struct strbuf *base,
+ const char *pathname, unsigned mode, int stage,
+ void *context)
{
- return read_one_entry_opt(sha1, base, baselen, pathname, mode, stage,
+ return read_one_entry_opt(sha1, base->buf, base->len, pathname,
+ mode, stage,
ADD_CACHE_JUST_APPEND);
}
@@ -70,7 +76,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
continue;
}
- switch (fn(entry.sha1, base->buf, base->len,
+ switch (fn(entry.sha1, base,
entry.path, entry.mode, stage, context)) {
case 0:
continue;
@@ -96,7 +102,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
sha1_to_hex(entry.sha1),
base->buf, entry.path);
- hashcpy(sha1, commit->tree->object.sha1);
+ hashcpy(sha1, commit->tree->object.oid.hash);
}
else
continue;
@@ -198,7 +204,7 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
return 0;
}
-int parse_tree(struct tree *item)
+int parse_tree_gently(struct tree *item, int quiet_on_missing)
{
enum object_type type;
void *buffer;
@@ -206,14 +212,15 @@ int parse_tree(struct tree *item)
if (item->object.parsed)
return 0;
- buffer = read_sha1_file(item->object.sha1, &type, &size);
+ buffer = read_sha1_file(item->object.oid.hash, &type, &size);
if (!buffer)
- return error("Could not read %s",
- sha1_to_hex(item->object.sha1));
+ return quiet_on_missing ? -1 :
+ error("Could not read %s",
+ oid_to_hex(&item->object.oid));
if (type != OBJ_TREE) {
free(buffer);
return error("Object %s not a tree",
- sha1_to_hex(item->object.sha1));
+ oid_to_hex(&item->object.oid));
}
return parse_tree_buffer(item, buffer, size);
}
@@ -241,6 +248,6 @@ struct tree *parse_tree_indirect(const unsigned char *sha1)
else
return NULL;
if (!obj->parsed)
- parse_object(obj->sha1);
+ parse_object(obj->oid.hash);
} while (1);
}