keep fileindex->tree diff code similar to fileindex->DIR diff code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
diff --git a/lib/fileindex.c b/lib/fileindex.c
index 9d87a00..f3934b9 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -623,7 +623,7 @@ walk_fileindex(struct got_fileindex *fileindex, struct got_fileindex_entry *ie)
static const struct got_error *
diff_fileindex_tree(struct got_fileindex *, struct got_fileindex_entry **,
- struct got_tree_object *, const char *, const char *,
+ const struct got_tree_entries *, const char *, const char *,
struct got_repository *, struct got_fileindex_diff_tree_cb *, void *);
static const struct got_error *
@@ -648,8 +648,9 @@ walk_tree(struct got_tree_entry **next, struct got_fileindex *fileindex,
return err;
}
- err = diff_fileindex_tree(fileindex, ie, subtree,
- subpath, entry_name, repo, cb, cb_arg);
+ err = diff_fileindex_tree(fileindex, ie,
+ got_object_tree_get_entries(subtree), subpath, entry_name,
+ repo, cb, cb_arg);
free(subpath);
got_object_tree_close(subtree);
if (err)
@@ -662,17 +663,15 @@ walk_tree(struct got_tree_entry **next, struct got_fileindex *fileindex,
static const struct got_error *
diff_fileindex_tree(struct got_fileindex *fileindex,
- struct got_fileindex_entry **ie, struct got_tree_object *tree,
+ struct got_fileindex_entry **ie, const struct got_tree_entries *entries,
const char *path, const char *entry_name, struct got_repository *repo,
struct got_fileindex_diff_tree_cb *cb, void *cb_arg)
{
const struct got_error *err = NULL;
struct got_tree_entry *te = NULL;
size_t path_len = strlen(path);
- const struct got_tree_entries *entries;
struct got_fileindex_entry *next;
- entries = got_object_tree_get_entries(tree);
te = SIMPLEQ_FIRST(&entries->head);
while ((*ie && got_path_is_child((*ie)->path, path, path_len)) || te) {
if (te && *ie) {
@@ -751,10 +750,13 @@ got_fileindex_diff_tree(struct got_fileindex *fileindex,
struct got_repository *repo,
struct got_fileindex_diff_tree_cb *cb, void *cb_arg)
{
- struct got_fileindex_entry *min;
- min = RB_MIN(got_fileindex_tree, &fileindex->entries);
- return diff_fileindex_tree(fileindex, &min, tree, path, entry_name,
- repo, cb, cb_arg);
+ struct got_fileindex_entry *ie;
+ ie = RB_MIN(got_fileindex_tree, &fileindex->entries);
+ while (ie && !got_path_is_child(ie->path, path, strlen(path)))
+ ie = walk_fileindex(fileindex, ie);
+ return diff_fileindex_tree(fileindex, &ie,
+ got_object_tree_get_entries(tree), path, entry_name, repo,
+ cb, cb_arg);
}
static const struct got_error *