Skip to content
Merged
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
10 changes: 6 additions & 4 deletions src/attrcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,22 @@ static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file)
{
int error = 0;
git_attr_file_entry *entry;
git_attr_file *old = NULL;

if (!file)
return 0;

if ((error = attr_cache_lock(cache)) < 0)
return error;

if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL)
file = git__compare_and_swap(&entry->file[file->source], file, NULL);
old = git__compare_and_swap(&entry->file[file->source], file, NULL);

attr_cache_unlock(cache);

if (file) {
GIT_REFCOUNT_OWN(file, NULL);
git_attr_file__free(file);
if (old) {
GIT_REFCOUNT_OWN(old, NULL);
git_attr_file__free(old);
}

return error;
Expand Down
12 changes: 6 additions & 6 deletions src/integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t
}

/* Use clang/gcc compiler intrinsics whenever possible */
#if (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow)
# define git__add_sizet_overflow(out, one, two) \
__builtin_uadd_overflow(one, two, out)
# define git__multiply_sizet_overflow(out, one, two) \
__builtin_umul_overflow(one, two, out)
#elif (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow)
#if (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow)
# define git__add_sizet_overflow(out, one, two) \
__builtin_uaddl_overflow(one, two, out)
# define git__multiply_sizet_overflow(out, one, two) \
__builtin_umull_overflow(one, two, out)
#elif (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow)
# define git__add_sizet_overflow(out, one, two) \
__builtin_uadd_overflow(one, two, out)
# define git__multiply_sizet_overflow(out, one, two) \
__builtin_umul_overflow(one, two, out)
#else

/**
Expand Down
7 changes: 3 additions & 4 deletions src/submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ static int load_submodule_names(git_strmap *out, git_config *cfg)
git_buf_put(&buf, fdot + 1, ldot - fdot - 1);
git_strmap_insert(out, entry->value, git_buf_detach(&buf), rval);
if (rval < 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to your change, which looks good to me, but is there any reason why git_strmap_insert is implemented as a macro? rval being used as a return value when it is at first sight passed in as an int only looks really horrible.

I'd at a minimum like to change it so the macro expects a pointer to an int so that the call here at least behaves somewhat like a normal function call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I share your dismay and would be happy to see anything that makes things more readable and less magical.

giterr_set(GITERR_NOMEMORY, "Error inserting submodule into hash table");
free_submodule_names(out);
giterr_set(GITERR_NOMEMORY, "error inserting submodule into hash table");
return -1;
}
}
Expand Down Expand Up @@ -513,12 +512,12 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
goto cleanup;
}
/* add back submodule information from index */
if (idx) {
if (mods && idx) {
if ((error = submodules_from_index(map, idx, mods)) < 0)
goto cleanup;
}
/* add submodule information from HEAD */
if (head) {
if (mods && head) {
if ((error = submodules_from_head(map, head, mods)) < 0)
goto cleanup;
}
Expand Down
5 changes: 1 addition & 4 deletions tests/checkout/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
cl_assert(git_path_exists("testrepo/link_to_new.txt"));
cl_assert(git_path_exists("testrepo/new.txt"));

git_object_free(g_object);
cl_git_pass(git_revparse_single(&g_object, g_repo, "8496071c1b46c854b31185ea97743be6a8774479"));

g_opts.checkout_strategy =
Expand All @@ -454,10 +455,6 @@ void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
cl_assert(!git_path_exists("testrepo/branch_file.txt"));
cl_assert(!git_path_exists("testrepo/link_to_new.txt"));
cl_assert(git_path_exists("testrepo/new.txt"));

git_object_free(g_object);
g_object = NULL;

}

void test_checkout_tree__can_disable_pattern_match(void)
Expand Down