Skip to content
  • Thomas Gummerer's avatar
    stash: setup default diff output format if necessary · 8e407bc8
    Thomas Gummerer authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    In the scripted 'git stash show' when no arguments are passed, we just
    pass '--stat' to 'git diff'.  When any argument is passed to 'stash
    show', we no longer pass '--stat' to 'git diff', and pass whatever
    flags are passed directly through to 'git diff'.
    
    By default 'git diff' shows the patch output.  So when a user uses
    'git stash show --patience', they would be shown the diff as expected,
    using the patience algorithm.  '--patience' in this case only changes
    the diff algorithm, but does not cause 'git diff' to show the diff by
    itself.  The diff is shown because that's the default behaviour of
    'git diff'.
    
    In the C version of 'git stash show', we try to emulate that behaviour
    using the internal diff API.  However we forgot to set up the default
    output format, in case it wasn't set by any of the flags that were
    passed through.  So 'git stash show --patience' in the builtin version
    of stash would be completely silent, while it would show the diff in
    the scripted version.
    
    The same thing would happen for other flags that only affect the way a
    patch is displayed, rather than switching to a different output format
    than the default one.
    
    Fix this by setting up the default output format for 'git diff'.
    
    Reported-by: default avatarDenton Liu <liu.denton@gmail.com>
    Signed-off-by: default avatarThomas Gummerer <t.gummerer@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    8e407bc8