• J
    config: add a notion of "scope" · 9acc5911
    Jeff King 提交于
    A config callback passed to git_config() doesn't know very
    much about the context in which it sees a variable. It can
    ask whether the variable comes from a file, and get the file
    name. But without analyzing the filename (which is hard to
    do accurately), it cannot tell whether it is in system-level
    config, user-level config, or repo-specific config.
    
    Generally this doesn't matter; the point of not passing this
    to the callback is that it should treat the config the same
    no matter where it comes from. But some programs, like
    upload-pack, are a special case: we should be able to run
    them in an untrusted repository, which means we cannot use
    any "dangerous" config from the repository config file (but
    it is OK to use it from system or user config).
    
    This patch teaches the config code to record the "scope" of
    each variable, and make it available inside config
    callbacks, similar to how we give access to the filename.
    The scope is the starting source for a particular parsing
    operation, and remains the same even if we include other
    files (so a .git/config which includes another file will
    remain CONFIG_SCOPE_REPO, as it would be similarly
    untrusted).
    Signed-off-by: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    9acc5911
cache.h 65.7 KB