mirror of
https://github.com/git/git.git
synced 2026-01-11 13:23:12 +09:00
shallow: fix -Wsign-compare warnings
Fix a couple of -Wsign-compare issues in "shallow.c" and mark the file as -Wsign-compare-clean. This change prepares the code for a refactoring of `repo_in_merge_bases_many()`, which will be adapted to accept the number of commits as `size_t` instead of `int`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
1ab5948141
commit
455ac07021
38
shallow.c
38
shallow.c
@ -1,5 +1,4 @@
|
|||||||
#define USE_THE_REPOSITORY_VARIABLE
|
#define USE_THE_REPOSITORY_VARIABLE
|
||||||
#define DISABLE_SIGN_COMPARE_WARNINGS
|
|
||||||
|
|
||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
#include "hex.h"
|
#include "hex.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,
|
struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
|
||||||
int shallow_flag, int not_shallow_flag)
|
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 commit_list *result = NULL;
|
||||||
struct object_array stack = OBJECT_ARRAY_INIT;
|
struct object_array stack = OBJECT_ARRAY_INIT;
|
||||||
struct commit *commit = NULL;
|
struct commit *commit = NULL;
|
||||||
@ -335,16 +335,16 @@ static int write_shallow_commits_1(struct strbuf *out, int use_pack_protocol,
|
|||||||
const struct oid_array *extra,
|
const struct oid_array *extra,
|
||||||
unsigned flags)
|
unsigned flags)
|
||||||
{
|
{
|
||||||
struct write_shallow_data data;
|
struct write_shallow_data data = {
|
||||||
int i;
|
.out = out,
|
||||||
data.out = out;
|
.use_pack_protocol = use_pack_protocol,
|
||||||
data.use_pack_protocol = use_pack_protocol;
|
.flags = flags,
|
||||||
data.count = 0;
|
};
|
||||||
data.flags = flags;
|
|
||||||
for_each_commit_graft(write_one_shallow, &data);
|
for_each_commit_graft(write_one_shallow, &data);
|
||||||
if (!extra)
|
if (!extra)
|
||||||
return data.count;
|
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_addstr(out, oid_to_hex(extra->oid + i));
|
||||||
strbuf_addch(out, '\n');
|
strbuf_addch(out, '\n');
|
||||||
data.count++;
|
data.count++;
|
||||||
@ -466,7 +466,6 @@ struct trace_key trace_shallow = TRACE_KEY_INIT(SHALLOW);
|
|||||||
*/
|
*/
|
||||||
void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
|
void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
trace_printf_key(&trace_shallow, "shallow: prepare_shallow_info\n");
|
trace_printf_key(&trace_shallow, "shallow: prepare_shallow_info\n");
|
||||||
memset(info, 0, sizeof(*info));
|
memset(info, 0, sizeof(*info));
|
||||||
info->shallow = sa;
|
info->shallow = sa;
|
||||||
@ -474,7 +473,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
|
|||||||
return;
|
return;
|
||||||
ALLOC_ARRAY(info->ours, sa->nr);
|
ALLOC_ARRAY(info->ours, sa->nr);
|
||||||
ALLOC_ARRAY(info->theirs, 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)) {
|
if (repo_has_object_file(the_repository, sa->oid + i)) {
|
||||||
struct commit_graft *graft;
|
struct commit_graft *graft;
|
||||||
graft = lookup_commit_graft(the_repository,
|
graft = lookup_commit_graft(the_repository,
|
||||||
@ -507,7 +506,7 @@ void clear_shallow_info(struct shallow_info *info)
|
|||||||
void remove_nonexistent_theirs_shallow(struct shallow_info *info)
|
void remove_nonexistent_theirs_shallow(struct shallow_info *info)
|
||||||
{
|
{
|
||||||
struct object_id *oid = info->shallow->oid;
|
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");
|
trace_printf_key(&trace_shallow, "shallow: remove_nonexistent_theirs_shallow\n");
|
||||||
for (i = dst = 0; i < info->nr_theirs; i++) {
|
for (i = dst = 0; i < info->nr_theirs; i++) {
|
||||||
if (i != dst)
|
if (i != dst)
|
||||||
@ -560,7 +559,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
|
|||||||
{
|
{
|
||||||
unsigned int i, nr;
|
unsigned int i, nr;
|
||||||
struct commit_list *head = NULL;
|
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);
|
size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
|
||||||
struct commit *c = lookup_commit_reference_gently(the_repository, oid,
|
struct commit *c = lookup_commit_reference_gently(the_repository, oid,
|
||||||
1);
|
1);
|
||||||
@ -660,7 +659,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
|
|||||||
struct object_id *oid = info->shallow->oid;
|
struct object_id *oid = info->shallow->oid;
|
||||||
struct oid_array *ref = info->ref;
|
struct oid_array *ref = info->ref;
|
||||||
unsigned int i, nr;
|
unsigned int i, nr;
|
||||||
int *shallow, nr_shallow = 0;
|
size_t *shallow, nr_shallow = 0;
|
||||||
struct paint_info pi;
|
struct paint_info pi;
|
||||||
|
|
||||||
trace_printf_key(&trace_shallow, "shallow: assign_shallow_commits_to_refs\n");
|
trace_printf_key(&trace_shallow, "shallow: assign_shallow_commits_to_refs\n");
|
||||||
@ -735,7 +734,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
|
|||||||
|
|
||||||
struct commit_array {
|
struct commit_array {
|
||||||
struct commit **commits;
|
struct commit **commits;
|
||||||
int nr, alloc;
|
size_t nr, alloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int add_ref(const char *refname UNUSED,
|
static int add_ref(const char *refname UNUSED,
|
||||||
@ -753,12 +752,11 @@ static int add_ref(const char *refname UNUSED,
|
|||||||
return 0;
|
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)
|
if (!ref_status)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < nr; i++)
|
for (size_t i = 0; i < nr; i++)
|
||||||
if (bitmap[i / 32] & (1U << (i % 32)))
|
if (bitmap[i / 32] & (1U << (i % 32)))
|
||||||
ref_status[i]++;
|
ref_status[i]++;
|
||||||
}
|
}
|
||||||
@ -773,8 +771,8 @@ static void post_assign_shallow(struct shallow_info *info,
|
|||||||
struct object_id *oid = info->shallow->oid;
|
struct object_id *oid = info->shallow->oid;
|
||||||
struct commit *c;
|
struct commit *c;
|
||||||
uint32_t **bitmap;
|
uint32_t **bitmap;
|
||||||
int dst, i, j;
|
size_t dst, i, j;
|
||||||
int bitmap_nr = DIV_ROUND_UP(info->ref->nr, 32);
|
size_t bitmap_nr = DIV_ROUND_UP(info->ref->nr, 32);
|
||||||
struct commit_array ca;
|
struct commit_array ca;
|
||||||
|
|
||||||
trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");
|
trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");
|
||||||
|
|||||||
@ -59,8 +59,8 @@ void prune_shallow(unsigned options);
|
|||||||
*/
|
*/
|
||||||
struct shallow_info {
|
struct shallow_info {
|
||||||
struct oid_array *shallow;
|
struct oid_array *shallow;
|
||||||
int *ours, nr_ours;
|
size_t *ours, nr_ours;
|
||||||
int *theirs, nr_theirs;
|
size_t *theirs, nr_theirs;
|
||||||
struct oid_array *ref;
|
struct oid_array *ref;
|
||||||
|
|
||||||
/* for receive-pack */
|
/* for receive-pack */
|
||||||
@ -69,7 +69,7 @@ struct shallow_info {
|
|||||||
int *reachable;
|
int *reachable;
|
||||||
int *shallow_ref;
|
int *shallow_ref;
|
||||||
struct commit **commits;
|
struct commit **commits;
|
||||||
int nr_commits;
|
size_t nr_commits;
|
||||||
};
|
};
|
||||||
|
|
||||||
void prepare_shallow_info(struct shallow_info *, struct oid_array *);
|
void prepare_shallow_info(struct shallow_info *, struct oid_array *);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user