Skip to content
  • Matheus Tavares's avatar
    grep: follow conventions for printing paths w/ unusual chars · 45115d84
    Matheus Tavares authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    grep does not follow the conventions used by other Git commands when
    printing paths that contain unusual characters (as double-quotes or
    newlines). Commands such as ls-files, commit, status and diff will:
    
    - Quote and escape unusual pathnames, by default.
    - Print names verbatim and unquoted when "-z" is used.
    
    But grep *never* quotes/escapes absolute paths with unusual chars and
    *always* quotes/escapes relative ones, even with "-z". Besides being
    inconsistent in its own output, the deviation from other Git commands
    can be confusing. So let's make it follow the two rules above and add
    some tests for this new behavior. Note that, making grep quote/escape
    all unusual paths by default, also make it fully compliant with the
    core.quotePath configuration, which is currently ignored for absolute
    paths.
    
    Reported-by: default avatarGreg Hurrell <greg@hurrell.net>
    Helped-by: default avatarJohannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: default avatarMatheus Tavares <matheus.bernardino@usp.br>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    45115d84