Quirk with Invalid Git Config


I bumped into what seems like a weird quirk with one of my git config files today. A bad value was reported:

error: Malformed value for branch.autosetuprebase
fatal: bad config file line 18 in .git/config

 

In the image, you’ll notice the branch reads “(ref: re…)”

I was getting this error because I incorrectly had the value of “true” for branch.autosetuprebase instead of “always”. Luckily, the error line tells me which setting has the incorrect value, but reports it as line 18 when in actuality, the line is 17. If I misspell autosetuprebase, the following error is reported:

fatal: bad config file line 17 in .git/config

It seems weird that an error on the same line would report two different line numbers depending on whether it was the key or the value that contained the issue. If you run across a config error like this, just try to remember to look at the value if it supplies you with the setting. If it’s generic enough like the second error, it’s probably the right line number. Since I’m not a pro at git, I’d be curious to know why it behaves this way if anybody can provide any insight.

AutoMapper Tests Made Simple