• C
    commit: allow partial commits with relative paths · 8894d535
    Clemens Buchacher 提交于
    In order to do partial commits, git-commit overlays a tree on the
    cache and checks pathspecs against the result. Currently, the
    overlaying is done using "prefix" which prevents relative pathspecs
    with ".." and absolute pathspec from matching when they refer to
    files not under "prefix" and absent from the index, but still in
    the tree (i.e.  files staged for removal).
    
    The point of providing a prefix at all is performance optimization.
    If we say there is no common prefix for the files of interest, then
    we have to read the entire tree into the index.
    
    But even if we cannot use the working directory as a prefix, we can
    still figure out if there is a common prefix for all given paths,
    and use that instead. The pathspec_prefix() routine from ls-files.c
    does exactly that.
    
    Any use of global variables is removed from pathspec_prefix() so
    that it can be called from commit.c.
    Reported-by: NReuben Thomas <rrt@sc3d.org>
    Analyzed-by: NMichael J Gruber <git@drmicha.warpmail.net>
    Signed-off-by: NClemens Buchacher <drizzd@aon.at>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    8894d535
setup.c 21.1 KB