• J
    add: don't complain when adding empty project root · 07d7bedd
    Jeff King 提交于
    We try to warn the user if one of their pathspecs caused no
    matches, as it may have been a typo. However, we disable the
    warning if the pathspec points to an existing file, since
    that means it is not a typo but simply an empty directory.
    
    Unfortunately, the file_exists() test was broken for one
    special case: the pathspec of the project root is just "".
    This patch detects this special case and acts as if the file
    exists (which it must, since it is the project root).
    
    The user-visible effect is that this:
    
      $ mkdir repo && cd repo && git init && git add .
    
    used to complain like:
    
      fatal: pathspec '' did not match any files
    
    but now is a silent no-op.
    Signed-off-by: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    07d7bedd
builtin-add.c 8.0 KB