summaryrefslogtreecommitdiff
path: root/shallow.c
diff options
context:
space:
mode:
Diffstat (limited to 'shallow.c')
-rw-r--r--shallow.c63
1 files changed, 40 insertions, 23 deletions
diff --git a/shallow.c b/shallow.c
index 8cb768e..7ff50dd 100644
--- a/shallow.c
+++ b/shallow.c
@@ -1,20 +1,23 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "hex.h"
#include "repository.h"
#include "tempfile.h"
#include "lockfile.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "commit.h"
#include "tag.h"
#include "pkt-line.h"
-#include "remote.h"
#include "refs.h"
#include "oid-array.h"
+#include "path.h"
#include "diff.h"
#include "revision.h"
#include "commit-slab.h"
#include "list-objects.h"
#include "commit-reach.h"
#include "shallow.h"
+#include "statinfo.h"
+#include "trace.h"
void set_alternate_shallow_file(struct repository *r, const char *path, int override)
{
@@ -30,12 +33,14 @@ int register_shallow(struct repository *r, const struct object_id *oid)
{
struct commit_graft *graft =
xmalloc(sizeof(struct commit_graft));
- struct commit *commit = lookup_commit(the_repository, oid);
+ struct commit *commit = lookup_commit(r, oid);
oidcpy(&graft->oid, oid);
graft->nr_parent = -1;
- if (commit && commit->object.parsed)
+ if (commit && commit->object.parsed) {
+ free_commit_list(commit->parents);
commit->parents = NULL;
+ }
return register_commit_graft(r, graft, 0);
}
@@ -247,7 +252,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
struct commit *c = p->item;
struct commit_list *parent;
- if (parse_commit(c))
+ if (repo_parse_commit(the_repository, c))
die("unable to parse commit %s",
oid_to_hex(&c->object.oid));
@@ -301,7 +306,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
if (graft->nr_parent != -1)
return 0;
if (data->flags & QUICK) {
- if (!has_object_file(&graft->oid))
+ if (!repo_has_object_file(the_repository, &graft->oid))
return 0;
} else if (data->flags & SEEN_ONLY) {
struct commit *c = lookup_commit(the_repository, &graft->oid);
@@ -466,7 +471,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
ALLOC_ARRAY(info->ours, sa->nr);
ALLOC_ARRAY(info->theirs, sa->nr);
for (i = 0; i < sa->nr; i++) {
- if (has_object_file(sa->oid + i)) {
+ if (repo_has_object_file(the_repository, sa->oid + i)) {
struct commit_graft *graft;
graft = lookup_commit_graft(the_repository,
&sa->oid[i]);
@@ -494,7 +499,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
for (i = dst = 0; i < info->nr_theirs; i++) {
if (i != dst)
info->theirs[dst] = info->theirs[i];
- if (has_object_file(oid + info->theirs[i]))
+ if (repo_has_object_file(the_repository, oid + info->theirs[i]))
dst++;
}
info->nr_theirs = dst;
@@ -583,7 +588,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
if (c->object.flags & BOTTOM)
continue;
- if (parse_commit(c))
+ if (repo_parse_commit(the_repository, c))
die("unable to parse commit %s",
oid_to_hex(&c->object.oid));
@@ -604,8 +609,10 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
free(tmp);
}
-static int mark_uninteresting(const char *refname, const struct object_id *oid,
- int flags, void *cb_data)
+static int mark_uninteresting(const char *refname UNUSED,
+ const struct object_id *oid,
+ int flags UNUSED,
+ void *cb_data UNUSED)
{
struct commit *commit = lookup_commit_reference_gently(the_repository,
oid, 1);
@@ -715,8 +722,10 @@ struct commit_array {
int nr, alloc;
};
-static int add_ref(const char *refname, const struct object_id *oid,
- int flags, void *cb_data)
+static int add_ref(const char *refname UNUSED,
+ const struct object_id *oid,
+ int flags UNUSED,
+ void *cb_data)
{
struct commit_array *ca = cb_data;
ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
@@ -785,12 +794,16 @@ static void post_assign_shallow(struct shallow_info *info,
if (!*bitmap)
continue;
for (j = 0; j < bitmap_nr; j++)
- if (bitmap[0][j] &&
- /* Step 7, reachability test at commit level */
- !in_merge_bases_many(c, ca.nr, ca.commits)) {
- update_refstatus(ref_status, info->ref->nr, *bitmap);
- dst++;
- break;
+ if (bitmap[0][j]) {
+ /* Step 7, reachability test at commit level */
+ int ret = repo_in_merge_bases_many(the_repository, c, ca.nr, ca.commits, 1);
+ if (ret < 0)
+ exit(128);
+ if (!ret) {
+ update_refstatus(ref_status, info->ref->nr, *bitmap);
+ dst++;
+ break;
+ }
}
}
info->nr_ours = dst;
@@ -815,9 +828,13 @@ int delayed_reachability_test(struct shallow_info *si, int c)
si->nr_commits = ca.nr;
}
- si->reachable[c] = in_merge_bases_many(commit,
- si->nr_commits,
- si->commits);
+ si->reachable[c] = repo_in_merge_bases_many(the_repository,
+ commit,
+ si->nr_commits,
+ si->commits,
+ 1);
+ if (si->reachable[c] < 0)
+ exit(128);
si->need_reachability_test[c] = 0;
}
return si->reachable[c];