aboutsummaryrefslogtreecommitdiffstats
path: root/shallow.c
diff options
context:
space:
mode:
Diffstat (limited to 'shallow.c')
-rw-r--r--shallow.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/shallow.c b/shallow.c
index 82a8da3d73..2f82ebd6e3 100644
--- a/shallow.c
+++ b/shallow.c
@@ -1,12 +1,11 @@
#define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "hex.h"
#include "repository.h"
#include "tempfile.h"
#include "lockfile.h"
-#include "object-store-ll.h"
+#include "object-store.h"
#include "commit.h"
#include "tag.h"
#include "pkt-line.h"
@@ -134,7 +133,8 @@ static void free_depth_in_slab(int **ptr)
struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
int shallow_flag, int not_shallow_flag)
{
- int i = 0, cur_depth = 0;
+ size_t i = 0;
+ int cur_depth = 0;
struct commit_list *result = NULL;
struct object_array stack = OBJECT_ARRAY_INIT;
struct commit *commit = NULL;
@@ -226,7 +226,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
* SHALLOW (excluded) and NOT_SHALLOW (included) should not be
* set at this point. But better be safe than sorry.
*/
- clear_object_flags(both_flags);
+ clear_object_flags(the_repository, both_flags);
is_repository_shallow(the_repository); /* make sure shallows are read */
@@ -335,16 +335,16 @@ static int write_shallow_commits_1(struct strbuf *out, int use_pack_protocol,
const struct oid_array *extra,
unsigned flags)
{
- struct write_shallow_data data;
- int i;
- data.out = out;
- data.use_pack_protocol = use_pack_protocol;
- data.count = 0;
- data.flags = flags;
+ struct write_shallow_data data = {
+ .out = out,
+ .use_pack_protocol = use_pack_protocol,
+ .flags = flags,
+ };
+
for_each_commit_graft(write_one_shallow, &data);
if (!extra)
return data.count;
- for (i = 0; i < extra->nr; i++) {
+ for (size_t i = 0; i < extra->nr; i++) {
strbuf_addstr(out, oid_to_hex(extra->oid + i));
strbuf_addch(out, '\n');
data.count++;
@@ -364,7 +364,9 @@ const char *setup_temporary_shallow(const struct oid_array *extra)
struct strbuf sb = STRBUF_INIT;
if (write_shallow_commits(&sb, 0, extra)) {
- temp = xmks_tempfile(git_path("shallow_XXXXXX"));
+ char *path = repo_git_path(the_repository, "shallow_XXXXXX");
+ temp = xmks_tempfile(path);
+ free(path);
if (write_in_full(temp->fd, sb.buf, sb.len) < 0 ||
close_tempfile_gently(temp) < 0)
@@ -466,7 +468,6 @@ struct trace_key trace_shallow = TRACE_KEY_INIT(SHALLOW);
*/
void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
{
- int i;
trace_printf_key(&trace_shallow, "shallow: prepare_shallow_info\n");
memset(info, 0, sizeof(*info));
info->shallow = sa;
@@ -474,7 +475,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
return;
ALLOC_ARRAY(info->ours, sa->nr);
ALLOC_ARRAY(info->theirs, sa->nr);
- for (i = 0; i < sa->nr; i++) {
+ for (size_t i = 0; i < sa->nr; i++) {
if (repo_has_object_file(the_repository, sa->oid + i)) {
struct commit_graft *graft;
graft = lookup_commit_graft(the_repository,
@@ -507,7 +508,7 @@ void clear_shallow_info(struct shallow_info *info)
void remove_nonexistent_theirs_shallow(struct shallow_info *info)
{
struct object_id *oid = info->shallow->oid;
- int i, dst;
+ size_t i, dst;
trace_printf_key(&trace_shallow, "shallow: remove_nonexistent_theirs_shallow\n");
for (i = dst = 0; i < info->nr_theirs; i++) {
if (i != dst)
@@ -535,7 +536,7 @@ static uint32_t *paint_alloc(struct paint_info *info)
unsigned nr = DIV_ROUND_UP(info->nr_bits, 32);
unsigned size = nr * sizeof(uint32_t);
void *p;
- if (!info->pool_count || size > info->end - info->free) {
+ if (!info->pool_count || info->end < info->free + size) {
if (size > POOL_SIZE)
BUG("pool size too small for %d in paint_alloc()",
size);
@@ -560,7 +561,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
{
unsigned int i, nr;
struct commit_list *head = NULL;
- int bitmap_nr = DIV_ROUND_UP(info->nr_bits, 32);
+ size_t bitmap_nr = DIV_ROUND_UP(info->nr_bits, 32);
size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
struct commit *c = lookup_commit_reference_gently(the_repository, oid,
1);
@@ -612,9 +613,9 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
}
}
- nr = get_max_object_index();
+ nr = get_max_object_index(the_repository);
for (i = 0; i < nr; i++) {
- struct object *o = get_indexed_object(i);
+ struct object *o = get_indexed_object(the_repository, i);
if (o && o->type == OBJ_COMMIT)
o->flags &= ~SEEN;
}
@@ -660,7 +661,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
struct object_id *oid = info->shallow->oid;
struct oid_array *ref = info->ref;
unsigned int i, nr;
- int *shallow, nr_shallow = 0;
+ size_t *shallow, nr_shallow = 0;
struct paint_info pi;
trace_printf_key(&trace_shallow, "shallow: assign_shallow_commits_to_refs\n");
@@ -674,9 +675,9 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
* Prepare the commit graph to track what refs can reach what
* (new) shallow commits.
*/
- nr = get_max_object_index();
+ nr = get_max_object_index(the_repository);
for (i = 0; i < nr; i++) {
- struct object *o = get_indexed_object(i);
+ struct object *o = get_indexed_object(the_repository, i);
if (!o || o->type != OBJ_COMMIT)
continue;
@@ -735,7 +736,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
struct commit_array {
struct commit **commits;
- int nr, alloc;
+ size_t nr, alloc;
};
static int add_ref(const char *refname UNUSED,
@@ -753,12 +754,11 @@ static int add_ref(const char *refname UNUSED,
return 0;
}
-static void update_refstatus(int *ref_status, int nr, uint32_t *bitmap)
+static void update_refstatus(int *ref_status, size_t nr, uint32_t *bitmap)
{
- unsigned int i;
if (!ref_status)
return;
- for (i = 0; i < nr; i++)
+ for (size_t i = 0; i < nr; i++)
if (bitmap[i / 32] & (1U << (i % 32)))
ref_status[i]++;
}
@@ -773,8 +773,8 @@ static void post_assign_shallow(struct shallow_info *info,
struct object_id *oid = info->shallow->oid;
struct commit *c;
uint32_t **bitmap;
- int dst, i, j;
- int bitmap_nr = DIV_ROUND_UP(info->ref->nr, 32);
+ size_t dst, i, j;
+ size_t bitmap_nr = DIV_ROUND_UP(info->ref->nr, 32);
struct commit_array ca;
trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");