Skip to content

Fallout from azure-pipelines-msvc #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ static void verify_working_tree_path(struct repository *r,
pos = index_name_pos(r->index, path, strlen(path));
if (pos >= 0)
; /* path is in the index */
else if (-1 - pos < r->index->cache_nr &&
!strcmp(r->index->cache[-1 - pos]->name, path))
else if (insert_pos_to_index_pos(pos) < r->index->cache_nr &&
!strcmp(r->index->cache[insert_pos_to_index_pos(pos)]->name,
path))
; /* path is in the index, unmerged */
else
die("no such path '%s' in HEAD", path);
Expand Down
2 changes: 1 addition & 1 deletion builtin/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int index_range_of_same_dir(const char *src, int length,
if (first >= 0)
die(_("%.*s is in index"), len_w_slash, src_w_slash);

first = -1 - first;
first = insert_pos_to_index_pos(first);
for (last = first; last < active_nr; last++) {
const char *path = active_cache[last]->name;
if (strncmp(path, src_w_slash, len_w_slash))
Expand Down
5 changes: 5 additions & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ static inline int index_pos_to_insert_pos(uintmax_t pos)
return -1 - (int)pos;
}

static inline int insert_pos_to_index_pos(int pos)
{
return -1 - pos;
}

#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
Expand Down
4 changes: 2 additions & 2 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ static int dir_in_way(struct index_state *istate, const char *path,
pos = index_name_pos(istate, dirpath.buf, dirpath.len);

if (pos < 0)
pos = -1 - pos;
pos = insert_pos_to_index_pos(pos);
if (pos < istate->cache_nr &&
!strncmp(dirpath.buf, istate->cache[pos]->name, dirpath.len)) {
strbuf_release(&dirpath);
Expand Down Expand Up @@ -822,7 +822,7 @@ static int would_lose_untracked(struct merge_options *opt, const char *path)
int pos = index_name_pos(istate, path, strlen(path));

if (pos < 0)
pos = -1 - pos;
pos = insert_pos_to_index_pos(pos);
while (pos < istate->cache_nr &&
!strcmp(path, istate->cache[pos]->name)) {
/*
Expand Down
2 changes: 1 addition & 1 deletion read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ static int index_name_pos_also_unmerged(struct index_state *istate,
return pos;

/* maybe unmerged? */
pos = -1 - pos;
pos = insert_pos_to_index_pos(pos);
if (pos >= istate->cache_nr ||
compare_name((ce = istate->cache[pos]), path, namelen))
return -1;
Expand Down
2 changes: 1 addition & 1 deletion rerere.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static struct rerere_dir *find_rerere_dir(const char *hex)
rr_dir->status = NULL;
rr_dir->status_nr = 0;
rr_dir->status_alloc = 0;
pos = -1 - pos;
pos = insert_pos_to_index_pos(pos);

/* Make sure the array is big enough ... */
ALLOC_GROW(rerere_dir, rerere_dir_nr + 1, rerere_dir_alloc);
Expand Down
2 changes: 1 addition & 1 deletion sha1-name.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void find_short_object_filename(struct disambiguate_state *ds)
loose_objects = odb_loose_cache(odb, &ds->bin_pfx);
pos = oid_array_lookup(loose_objects, &ds->bin_pfx);
if (pos < 0)
pos = -1 - pos;
pos = insert_pos_to_index_pos(pos);
while (!ds->ambiguous && pos < loose_objects->nr) {
const struct object_id *oid;
oid = loose_objects->oid + pos;
Expand Down
2 changes: 1 addition & 1 deletion submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int is_gitmodules_unmerged(const struct index_state *istate)
{
int pos = index_name_pos(istate, GITMODULES_FILE, strlen(GITMODULES_FILE));
if (pos < 0) { /* .gitmodules not found or isn't merged */
pos = -1 - pos;
pos = insert_pos_to_index_pos(pos);
if (istate->cache_nr > pos) { /* there is a .gitmodules */
const struct cache_entry *ce = istate->cache[pos];
if (ce_namelen(ce) == strlen(GITMODULES_FILE) &&
Expand Down
2 changes: 1 addition & 1 deletion unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static int locate_in_src_index(const struct cache_entry *ce,
int len = ce_namelen(ce);
int pos = index_name_pos(index, ce->name, len);
if (pos < 0)
pos = -1 - pos;
pos = insert_pos_to_index_pos(pos);
return pos;
}

Expand Down