On 10/8/2014 11:05 PM, Junio C Hamano wrote:
> Richard Hartmann <richih.mailingl...@gmail.com> writes:
> 
>> So this is not a real bug report, more of a "is this intended this way?"
>> richih@titanium  ~/git_test % git rev-parse --is-inside-work-tree
>> error: Malformed value for branch.autosetuprebase
>> fatal: bad config file line 8 in .git/config
>> richih@titanium  ~/git_test % cat .git/config
>> ...
>> [branch]
>> autosetuprebase = true
> 
> It does not seem to be limited to rev-parse but having a malformed
> configuration for that variable would break everything Git, which
> certainly is not how it is supposed to work.  It also seems that the
> breakage dates back very far into the past (I checked 1.7.0 and it
> seems to be broken the same way).
> 
> The same breakage exists for branch.autosetupmerge, I think, e.g.
> 
>       [branch]
>                 autosetupmerge = garbage
> 
> In config.c, git_default_branch_config() must be corrected to set
> git_branch_track and autorebase to BRANCH_TRACK_MALFORMED and
> AUTOREBASE_MALFORMED and the users of these two variables must be
> fixed to deal with the "malformed in the configuration" cases, I
> think.  The error should happen only in the codepath where we need
> the value, and no other places.

Supporting Junio's claim, there is a function called git_default_config()
which checks and sets a whole load of config values which may or maynot
be relevant to the codepath that called it. (branch.autosetuprebase is a
part of it) So an error may occur printing a seemingly unrelated config value
as the malformed variable as happened in your case.

There are currently 72 callers of git_default_config() in the codebase,
so a malformed config value breaks most of git commands. The only path
to correct this behavior would be either correct the config variable in
the file or we could decouple the huge monolithic function that
git_default_config() has become and use the git_config_get_value() in the
code paths that really need them. This part is doable, albeit slowly. All
the config variables in git_default_config() can be rewritten using the
new non callback based functions easily as demonstrated in an earlier
RFC patch.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to