summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/commit.c b/commit.c
index a127fe60c5..d1e1061214 100644
--- a/commit.c
+++ b/commit.c
@@ -9,7 +9,7 @@
#include "hex.h"
#include "repository.h"
#include "object-name.h"
-#include "object-store-ll.h"
+#include "odb.h"
#include "utf8.h"
#include "diff.h"
#include "revision.h"
@@ -29,7 +29,9 @@
#include "tree.h"
#include "hook.h"
#include "parse.h"
+#include "object-file.h"
#include "object-file-convert.h"
+#include "prio-queue.h"
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
@@ -373,7 +375,7 @@ const void *repo_get_commit_buffer(struct repository *r,
if (!ret) {
enum object_type type;
unsigned long size;
- ret = repo_read_object_file(r, &commit->object.oid, &type, &size);
+ ret = odb_read_object(r->objects, &commit->object.oid, &type, &size);
if (!ret)
die("cannot read commit object %s",
oid_to_hex(&commit->object.oid));
@@ -574,7 +576,7 @@ int repo_parse_commit_internal(struct repository *r,
if (commit_graph_paranoia == -1)
commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);
- if (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {
+ if (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) {
unparse_commit(r, &item->object.oid);
return quiet_on_missing ? -1 :
error(_("commit %s exists in commit-graph but not in the object database"),
@@ -584,7 +586,8 @@ int repo_parse_commit_internal(struct repository *r,
return 0;
}
- if (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)
+ if (odb_read_object_info_extended(r->objects, &item->object.oid,
+ &oi, flags) < 0)
return quiet_on_missing ? -1 :
error("Could not read %s",
oid_to_hex(&item->object.oid));
@@ -737,20 +740,27 @@ void commit_list_sort_by_date(struct commit_list **list)
commit_list_sort(list, commit_list_compare_by_date);
}
-struct commit *pop_most_recent_commit(struct commit_list **list,
+struct commit *pop_most_recent_commit(struct prio_queue *queue,
unsigned int mark)
{
- struct commit *ret = pop_commit(list);
+ struct commit *ret = prio_queue_peek(queue);
+ int get_pending = 1;
struct commit_list *parents = ret->parents;
while (parents) {
struct commit *commit = parents->item;
if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {
commit->object.flags |= mark;
- commit_list_insert_by_date(commit, list);
+ if (get_pending)
+ prio_queue_replace(queue, commit);
+ else
+ prio_queue_put(queue, commit);
+ get_pending = 0;
}
parents = parents->next;
}
+ if (get_pending)
+ prio_queue_get(queue);
return ret;
}
@@ -778,21 +788,19 @@ static void clear_commit_marks_1(struct commit_list **plist,
}
}
-void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark)
+void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
{
- struct commit_list *list = NULL;
-
- while (nr--) {
- clear_commit_marks_1(&list, *commit, mark);
- commit++;
- }
- while (list)
- clear_commit_marks_1(&list, pop_commit(&list), mark);
+ for (size_t i = 0; i < nr; i++)
+ clear_commit_marks(commit[i], mark);
}
void clear_commit_marks(struct commit *commit, unsigned int mark)
{
- clear_commit_marks_many(1, &commit, mark);
+ struct commit_list *list = NULL;
+
+ clear_commit_marks_1(&list, commit, mark);
+ while (list)
+ clear_commit_marks_1(&list, pop_commit(&list), mark);
}
struct commit *pop_commit(struct commit_list **stack)
@@ -1275,8 +1283,8 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h
desc = merge_remote_util(parent);
if (!desc || !desc->obj)
return;
- buf = repo_read_object_file(the_repository, &desc->obj->oid, &type,
- &size);
+ buf = odb_read_object(the_repository->objects, &desc->obj->oid,
+ &type, &size);
if (!buf || type != OBJ_TAG)
goto free_return;
if (!parse_signature(buf, size, &payload, &signature))
@@ -1380,7 +1388,7 @@ static int convert_commit_extra_headers(const struct commit_extra_header *orig,
struct commit_extra_header *new;
CALLOC_ARRAY(new, 1);
if (!strcmp(orig->key, "mergetag")) {
- if (convert_object_file(&out, algo, compat,
+ if (convert_object_file(the_repository, &out, algo, compat,
orig->value, orig->len,
OBJ_TAG, 1)) {
free(new);
@@ -1707,7 +1715,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
- assert_oid_type(tree, OBJ_TREE);
+ odb_assert_oid_type(the_repository->objects, tree, OBJ_TREE);
if (memchr(msg, '\0', msg_len))
return error("a NUL byte in commit log message not allowed.");
@@ -1797,8 +1805,8 @@ int commit_tree_extended(const char *msg, size_t msg_len,
compat_oid = &compat_oid_buf;
}
- result = write_object_file_flags(buffer.buf, buffer.len, OBJ_COMMIT,
- ret, compat_oid, 0);
+ result = odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len,
+ OBJ_COMMIT, ret, compat_oid, 0);
out:
free(parent_buf);
strbuf_release(&buffer);