Skip to content
  • Duy Nguyen's avatar
    tree_entry_interesting: do basedir compare on wildcard patterns when possible · c904cd89
    Duy Nguyen authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Currently we treat "*.c" and "path/to/*.c" the same way. Which means
    we check all possible paths in repo against "path/to/*.c". One could
    see that "path/elsewhere/foo.c" obviously cannot match "path/to/*.c"
    and we only need to check all paths _inside_ "path/to/" against that
    pattern.
    
    This patch checks the leading fixed part of a pathspec against base
    directory and exit early if possible. We could even optimize further
    in "path/to/something*.c" case (i.e. check the fixed part against
    name_entry as well) but that's more complicated and probably does not
    gain us much.
    
    -O2 build on linux-2.6, without and with this patch respectively:
    
    $ time git rev-list --quiet HEAD -- 'drivers/*.c'
    
    real    1m9.484s
    user    1m9.128s
    sys     0m0.181s
    
    $ time ~/w/git/git rev-list --quiet HEAD -- 'drivers/*.c'
    
    real    0m15.710s
    user    0m15.564s
    sys     0m0.107s
    
    Signed-off-by: default avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    c904cd89