diff options
author | Thomas Gummerer <t.gummerer@gmail.com> | 2019-03-20 22:49:55 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-03-21 10:41:56 +0900 |
commit | 8e407bc817febdf1ff2edcce01945b3eac6d376b (patch) | |
tree | 6f160be8a03b4e025936663fd022e89437ef9c35 /builtin | |
parent | tests: add a special setup where stash.useBuiltin is off (diff) | |
download | tgif-8e407bc817febdf1ff2edcce01945b3eac6d376b.tar.xz |
stash: setup default diff output format if necessary
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: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/stash.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/stash.c b/builtin/stash.c index 1bfa24030c..b008fe24ed 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -760,6 +760,10 @@ static int show_stash(int argc, const char **argv, const char *prefix) free_stash_info(&info); usage_with_options(git_stash_show_usage, options); } + if (!rev.diffopt.output_format) { + rev.diffopt.output_format = DIFF_FORMAT_PATCH; + diff_setup_done(&rev.diffopt); + } rev.diffopt.flags.recursive = 1; setup_diff_pager(&rev.diffopt); |