diff options
| author | Patrick Steinhardt <ps@pks.im> | 2018-10-05 19:32:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-05 19:32:10 +0200 |
| commit | 8e0b172981a046d19f1d9efa5acd6186bccbd3ce (patch) | |
| tree | 3e7ac388cadae960fe7e22175ce0da878afe9d18 /src/submodule.c | |
| parent | 8b89f362a34fcccdf1c6c5f3445895b71d9c6d56 (diff) | |
| parent | c590b41fe4057a84a9bd31a5605ceef2c309b0f8 (diff) | |
| download | libgit2-0.27.5.tar.gz | |
Merge pull request #4834 from pks-t/pks/v0.27.5v0.27.5
Security release v0.27.5
Diffstat (limited to 'src/submodule.c')
| -rw-r--r-- | src/submodule.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/submodule.c b/src/submodule.c index 4bf74dcfb..06b7de585 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -1813,6 +1813,14 @@ static int get_value(const char **out, git_config *cfg, git_buf *buf, const char return error; } +static bool looks_like_command_line_option(const char *s) +{ + if (s && s[0] == '-') + return true; + + return false; +} + static int submodule_read_config(git_submodule *sm, git_config *cfg) { git_buf key = GIT_BUF_INIT; @@ -1826,24 +1834,31 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) if ((error = get_value(&value, cfg, &key, sm->name, "path")) == 0) { in_config = 1; + /* We would warn here if we had that API */ + if (!looks_like_command_line_option(value)) { /* * TODO: if case insensitive filesystem, then the following strcmp * should be strcasecmp */ - if (strcmp(sm->name, value) != 0) { - if (sm->path != sm->name) - git__free(sm->path); - sm->path = git__strdup(value); - GITERR_CHECK_ALLOC(sm->path); + if (strcmp(sm->name, value) != 0) { + if (sm->path != sm->name) + git__free(sm->path); + sm->path = git__strdup(value); + GITERR_CHECK_ALLOC(sm->path); + } + } } else if (error != GIT_ENOTFOUND) { goto cleanup; } if ((error = get_value(&value, cfg, &key, sm->name, "url")) == 0) { - in_config = 1; - sm->url = git__strdup(value); - GITERR_CHECK_ALLOC(sm->url); + /* We would warn here if we had that API */ + if (!looks_like_command_line_option(value)) { + in_config = 1; + sm->url = git__strdup(value); + GITERR_CHECK_ALLOC(sm->url); + } } else if (error != GIT_ENOTFOUND) { goto cleanup; } |
