diff options
Diffstat (limited to 'reflog.c')
-rw-r--r-- | reflog.c | 50 |
1 files changed, 26 insertions, 24 deletions
@@ -1,9 +1,11 @@ -#include "cache.h" -#include "object-store.h" +#include "git-compat-util.h" +#include "gettext.h" +#include "object-store-ll.h" #include "reflog.h" #include "refs.h" #include "revision.h" -#include "worktree.h" +#include "tree.h" +#include "tree-walk.h" /* Remember to update object flag allocation in object.h */ #define INCOMPLETE (1u<<10) @@ -28,7 +30,8 @@ static int tree_is_complete(const struct object_id *oid) if (!tree->buffer) { enum object_type type; unsigned long size; - void *data = read_object_file(oid, &type, &size); + void *data = repo_read_object_file(the_repository, oid, &type, + &size); if (!data) { tree->object.flags |= INCOMPLETE; return 0; @@ -36,10 +39,10 @@ static int tree_is_complete(const struct object_id *oid) tree->buffer = data; tree->size = size; } - init_tree_desc(&desc, tree->buffer, tree->size); + init_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size); complete = 1; while (tree_entry(&desc, &entry)) { - if (!has_object_file(&entry.oid) || + if (!repo_has_object_file(the_repository, &entry.oid) || (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) { tree->object.flags |= INCOMPLETE; complete = 0; @@ -186,14 +189,13 @@ static void mark_reachable(struct expire_reflog_policy_cb *cb) struct commit *commit = pop_commit(&pending); if (commit->object.flags & REACHABLE) continue; - if (parse_commit(commit)) + if (repo_parse_commit(the_repository, commit)) continue; commit->object.flags |= REACHABLE; if (commit->date < expire_limit) { commit_list_insert(commit, &leftover); continue; } - commit->object.flags |= REACHABLE; parent = commit->parents; while (parent) { commit = parent->item; @@ -240,8 +242,9 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit * Return true iff the specified reflog entry should be expired. */ int should_expire_reflog_ent(struct object_id *ooid, struct object_id *noid, - const char *email, timestamp_t timestamp, int tz, - const char *message, void *cb_data) + const char *email UNUSED, + timestamp_t timestamp, int tz UNUSED, + const char *message UNUSED, void *cb_data) { struct expire_reflog_policy_cb *cb = cb_data; struct commit *old_commit, *new_commit; @@ -294,7 +297,8 @@ int should_expire_reflog_ent_verbose(struct object_id *ooid, return expire; } -static int push_tip_to_list(const char *refname, const struct object_id *oid, +static int push_tip_to_list(const char *refname UNUSED, + const struct object_id *oid, int flags, void *cb_data) { struct commit_list **list = cb_data; @@ -310,16 +314,9 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid, static int is_head(const char *refname) { - switch (ref_type(refname)) { - case REF_TYPE_OTHER_PSEUDOREF: - case REF_TYPE_MAIN_PSEUDOREF: - if (parse_worktree_ref(refname, NULL, NULL, &refname)) - BUG("not a worktree ref: %s", refname); - break; - default: - break; - } - return !strcmp(refname, "HEAD"); + const char *stripped_refname; + parse_worktree_ref(refname, NULL, NULL, &stripped_refname); + return !strcmp(stripped_refname, "HEAD"); } void reflog_expiry_prepare(const char *refname, @@ -376,11 +373,16 @@ void reflog_expiry_cleanup(void *cb_data) clear_commit_marks(cb->tip_commit, REACHABLE); break; } + for (elem = cb->mark_list; elem; elem = elem->next) + clear_commit_marks(elem->item, REACHABLE); + free_commit_list(cb->mark_list); } -int count_reflog_ent(struct object_id *ooid, struct object_id *noid, - const char *email, timestamp_t timestamp, int tz, - const char *message, void *cb_data) +int count_reflog_ent(struct object_id *ooid UNUSED, + struct object_id *noid UNUSED, + const char *email UNUSED, + timestamp_t timestamp, int tz UNUSED, + const char *message UNUSED, void *cb_data) { struct cmd_reflog_expire_cb *cb = cb_data; if (!cb->expire_total || timestamp < cb->expire_total) |