Home > Enterprise >  How do I find a mixed case entry in .gitmodules using `--get-regexp`?
How do I find a mixed case entry in .gitmodules using `--get-regexp`?

Time:08-19

I have a submodule defined in .gitmodules as

[submodule "FastFold"]
  path = .vim/pack/test/start/FastFold
  url = https://github.cim/Konfekt/FastFold.git
  ignore = dirty

I'm trying to get the path using git config -f .gitmodules --get-regexp "FastFold.path" but that command returns nothing with an exit code of 1 (no match).

Docs for --get-regexp state

Regular expression matching is currently case-sensitive and done against a canonicalized version of the key in which section and variable names are lowercased, but subsection names are not.

I'm able to get the path for entries that are all lower-cased, so I'm pretty sure this is a valid regexp.

I wondered if the part of the quote above that said variable names are lowercased might mean "fastfold.path" would work, but that returns the same result.

How can I find the path for a mixed case submodule entry like this one? And how should I properly name the submodule to avoid this problem in the future?

CodePudding user response:

You want either:

git config -f .gitmodules --get-regexp '^submodule\.FastFold\.path$'

(in which case, --get-regexp is kind of pointless) or:

git config -f .gitmodules --get-regexp "\.FastFold\.path"

(which doesn't seem right: don't you only want matching submodule entries?). The \. makes the match require a literal dot, and the literal dot is needed to make FastFold a subsection name, so that it will not be canonicalized into lowercase. Remember that . in a regular expression means "any character", not "a literal period".

(Overall, git config -f .gitmodules --get submodule.FastFold.path is correct and a whole lot simpler.)

  • Related