Skip to content
  • Junio C Hamano's avatar
    Fix 'git add' with .gitignore · 4d06f8ac
    Junio C Hamano authored
    When '*.ig' is ignored, and you have two files f.ig and d.ig/foo
    in the working tree,
    
    	$ git add .
    
    correctly ignored f.ig but failed to ignore d.ig/foo.  This was
    caused by a thinko in an earlier commit 4888c534
    
    , when we tried
    to allow adding otherwise ignored files.
    
    After reverting that commit, this takes a much simpler approach.
    When we have an unmatched pathspec that talks about an existing
    pathname, we know it is an ignored path the user tried to add,
    so we include it in the set of paths directory walker returned.
    
    This does not let you say "git add -f D" on an ignored directory
    D and add everything under D.  People can submit a patch to
    further allow it if they want to, but I think it is a saner
    behaviour to require explicit paths to be spelled out in such a
    case.
    
    Signed-off-by: default avatarJunio C Hamano <junkio@cox.net>
    4d06f8ac