Closed zkamvar closed 3 years ago
I think that is expected, option names are not case sensitive.
Can you please include code if the bug, if any? This works for me:
library(gert)
stopifnot(libgit2_config()$version >= "1.1")
repo <- git_init(tempfile())
writeLines('hello', file.path(repo, 'test.txt'))
git_add('test.txt', repo = repo)
git_commit('This is a test', repo = repo)
git_branch_list(repo = repo)
# A tibble: 1 x 6
# name local ref upstream commit updated
#* <chr> <lgl> <chr> <chr> <chr> <dttm>
#1 main TRUE refs/heads… NA 0fd28d59cdfd5f35175c3281… 2021-03-25 15:35:41
You are correct. It works for me:
library(gert)
#> Linking to libgit2 v1.1.0, ssh support: YES
#> Global config: /Users/zhian/.gitconfig
#> Default user: Zhian N. Kamvar <zkamvar@gmail.com>
stopifnot(libgit2_config()$version >= "1.1")
repo <- git_init(tempfile())
writeLines('hello', file.path(repo, 'test.txt'))
git_add('test.txt', repo = repo)
#> # A tibble: 1 x 3
#> file status staged
#> <chr> <chr> <lgl>
#> 1 test.txt new TRUE
git_commit('This is a test', repo = repo)
#> [1] "d34f7b456f5f4dff3b13b7c0eb2b666fe4c6fcb9"
git_branch_list(repo = repo)
#> # A tibble: 1 x 6
#> name local ref upstream commit updated
#> * <chr> <lgl> <chr> <chr> <chr> <dttm>
#> 1 main TRUE refs/heads… <NA> d34f7b456f5f4dff3b13b7c0… 2021-03-25 08:18:49
Created on 2021-03-25 by the reprex package (v1.0.0)
I think this means that this is an issue in {usethis} where this line should be changed to be case-insensitive: https://github.com/r-lib/usethis/blob/29192cf7e485c7bb29b64d6394aac13909a30880/R/utils-git.R#L63
Should I open an issue there?
I don't really understand why gert changes the case, though. Does that serve some purpose?
This is done by libgit2, not gert. I don't know why, I suspect to normalize the option names if they are in fact case insensitive. We'd have to ask @ethomson to be sure.
Ah, I see. I guess that suggests that I (meaning: usethis) should become case insensitive re: git config keys.
It is mentioned here in the documentation: https://libgit2.org/libgit2/#HEAD/type/git_config_entry that the name gets indeed normalized.
Indeed I think you should wrap both sides in tolower()
in usethis when comparing/searching by key names.
I think it would also be worthwhile to document this in the {gert} documentation. I can make a PR suggestion if you would like.
@zkamvar yes that sounds good, feel free to send a PR to improve the docs. Please keep the wording concise, with a link to the canonical source (libgit2 docs) for more details.
I was experiencing the same problem as #110, and I noticed that
init.defaultBranch
is set to lowercase in the output ofgert::git_config_global()
:Created on 2021-03-22 by the reprex package (v1.0.0)
In my configuration file, however, the B is upper case: https://github.com/zkamvar/config-files/blob/master/.gitconfig