diff options
| -rw-r--r-- | CHANGELOG.md | 5 | ||||
| -rw-r--r-- | include/git2/diff.h | 4 | ||||
| -rw-r--r-- | src/config_file.c | 18 | ||||
| -rw-r--r-- | src/diff.c | 2 | ||||
| -rw-r--r-- | src/remote.c | 2 | ||||
| -rw-r--r-- | tests/config/include.c | 16 | ||||
| -rw-r--r-- | tests/network/remote/rename.c | 9 |
7 files changed, 46 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ccd2c485..786668c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,3 +107,8 @@ v0.21 + 1 * The THREADSAFE option to build libgit2 with threading support has been flipped to be on by default. + +* The context_lines and interhunk_lines fields in git_diff_options are + now uint32_t instead of uint16_t. This allows to set them to UINT_MAX, + in effect asking for "infinite" context e.g. to iterate over all the + unmodified lines of a diff. diff --git a/include/git2/diff.h b/include/git2/diff.h index 1013b5c33..4403944f4 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -377,8 +377,8 @@ typedef struct { /* options controlling how to diff text is generated */ - uint16_t context_lines; /**< defaults to 3 */ - uint16_t interhunk_lines; /**< defaults to 0 */ + uint32_t context_lines; /**< defaults to 3 */ + uint32_t interhunk_lines; /**< defaults to 0 */ uint16_t id_abbrev; /**< default 'core.abbrev' or 7 if unset */ git_off_t max_size; /**< defaults to 512MB */ const char *old_prefix; /**< defaults to "a" */ diff --git a/src/config_file.c b/src/config_file.c index 093e74a70..d72e12c56 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -1269,7 +1269,7 @@ static int config_parse(git_strmap *values, diskfile_backend *cfg_file, struct r if ((result = git_path_dirname_r(&path, reader->file_path)) < 0) break; - /* We need to know out index in the array, as the next config_parse call may realloc */ + /* We need to know our index in the array, as the next config_parse call may realloc */ index = git_array_size(cfg_file->readers) - 1; dir = git_buf_detach(&path); result = included_path(&path, dir, var->entry->value); @@ -1280,12 +1280,18 @@ static int config_parse(git_strmap *values, diskfile_backend *cfg_file, struct r r->file_path = git_buf_detach(&path); git_buf_init(&r->buffer, 0); - if ((result = git_futils_readbuffer_updated(&r->buffer, r->file_path, &r->file_mtime, - &r->file_size, NULL)) < 0) - break; + result = git_futils_readbuffer_updated(&r->buffer, r->file_path, &r->file_mtime, + &r->file_size, NULL); + + if (result == 0) { + result = config_parse(values, cfg_file, r, level, depth+1); + r = git_array_get(cfg_file->readers, index); + } + else if (result == GIT_ENOTFOUND) { + giterr_clear(); + result = 0; + } - result = config_parse(values, cfg_file, r, level, depth+1); - r = git_array_get(cfg_file->readers, index); git_buf_free(&r->buffer); if (result < 0) diff --git a/src/diff.c b/src/diff.c index 2691d7ca0..375d4cb13 100644 --- a/src/diff.c +++ b/src/diff.c @@ -439,7 +439,7 @@ static int diff_list_apply_options( /* If not given explicit `opts`, check `diff.xyz` configs */ if (!opts) { int context = git_config__get_int_force(cfg, "diff.context", 3); - diff->opts.context_lines = context >= 0 ? (uint16_t)context : 3; + diff->opts.context_lines = context >= 0 ? (uint32_t)context : 3; /* add other defaults here */ } diff --git a/src/remote.c b/src/remote.c index d346fb328..c98c160ee 100644 --- a/src/remote.c +++ b/src/remote.c @@ -1677,7 +1677,7 @@ int git_remote_rename(git_strarray *out, git_repository *repo, const char *name, assert(out && repo && name && new_name); if ((error = git_remote_load(&remote, repo, name)) < 0) - return -1; + return error; if ((error = ensure_remote_name_is_valid(new_name)) < 0) goto cleanup; diff --git a/tests/config/include.c b/tests/config/include.c index 167814e59..d4af59509 100644 --- a/tests/config/include.c +++ b/tests/config/include.c @@ -86,3 +86,19 @@ void test_config_include__depth(void) unlink("a"); unlink("b"); } + +void test_config_include__missing(void) +{ + git_config *cfg; + const char *str; + + cl_git_mkfile("including", "[include]\npath = nonexistentfile\n[foo]\nbar = baz"); + + giterr_clear(); + cl_git_pass(git_config_open_ondisk(&cfg, "including")); + cl_assert(giterr_last() == NULL); + cl_git_pass(git_config_get_string(&str, cfg, "foo.bar")); + cl_assert_equal_s(str, "baz"); + + git_config_free(cfg); +} diff --git a/tests/network/remote/rename.c b/tests/network/remote/rename.c index e1aea0297..49929a470 100644 --- a/tests/network/remote/rename.c +++ b/tests/network/remote/rename.c @@ -200,6 +200,15 @@ void test_network_remote_rename__overwrite_ref_in_target(void) git_branch_iterator_free(iter); } +void test_network_remote_rename__nonexistent_returns_enotfound(void) +{ + git_strarray problems = {0}; + + int err = git_remote_rename(&problems, _repo, "nonexistent", "renamed"); + + cl_assert_equal_i(GIT_ENOTFOUND, err); +} + void test_network_remote_rename__symref_head(void) { int error; |
