stash show: use stash.showIncludeUntracked even when diff options given
If options pertaining to how the diff is displayed is provided to `git stash show`, the command will ignore the stash.showIncludeUntracked configuration variable, defaulting to not showing any untracked files. This is unintuitive behaviour since the format of the diff output and whether or not to display untracked files are orthogonal. Use stash.showIncludeUntracked even when diff options are given. Of course, this is still overridable via the command-line options. Update the documentation to explicitly say which configuration variables will be overridden when a diff options are given. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
May 21, 2021 at 03:37 UTC
af5cd44b6f8f1934bc8b91f646eb2e73dcab57f3
4 files changed
+10
-9
Documentation/config/stash.txt
+3
-3
@@ -6,9 +6,9 @@ stash.useBuiltin::
6
remaining users that setting this now does nothing.
7
8
stash.showIncludeUntracked::
9
- If this is set to true, the `git stash show` command without an
10
- option will show the untracked files of a stash entry. Defaults to
11
- false. See description of 'show' command in linkgit:git-stash[1].
9
+ If this is set to true, the `git stash show` command will show
10
+ the untracked files of a stash entry. Defaults to false. See
11
+ description of 'show' command in linkgit:git-stash[1].
12
13
stash.showPatch::
14
If this is set to true, the `git stash show` command without an
Documentation/git-stash.txt
+4
-2
@@ -91,8 +91,10 @@ show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]::
91
By default, the command shows the diffstat, but it will accept any
92
format known to 'git diff' (e.g., `git stash show -p stash@{1}`
93
to view the second most recent entry in patch form).
94
- You can use stash.showIncludeUntracked, stash.showStat, and
95
- stash.showPatch config variables to change the default behavior.
94
+ If no `<diff-option>` is provided, the default behavior will be given
95
+ by the `stash.showStat`, and `stash.showPatch` config variables. You
96
+ can also use `stash.showIncludeUntracked` to set whether
97
+ `--include-untracked` is enabled by default.
98
99
pop [--index] [-q|--quiet] [<stash>]::
100
builtin/stash.c
+1
-4
@@ -831,7 +831,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
831
UNTRACKED_NONE,
832
UNTRACKED_INCLUDE,
833
UNTRACKED_ONLY
834
- } show_untracked = UNTRACKED_NONE;
834
+ } show_untracked = show_include_untracked ? UNTRACKED_INCLUDE : UNTRACKED_NONE;
835
struct option options[] = {
836
OPT_SET_INT('u', "include-untracked", &show_untracked,
837
N_("include untracked files in the stash"),
@@ -874,9 +874,6 @@ static int show_stash(int argc, const char **argv, const char *prefix)
874
if (show_patch)
875
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
876
877
- if (show_include_untracked)
878
- show_untracked = UNTRACKED_INCLUDE;
879
-
877
if (!show_stat && !show_patch) {
878
free_stash_info(&info);
879
return 0;
t/t3905-stash-include-untracked.sh
+2
@@ -333,6 +333,8 @@ test_expect_success 'stash show --include-untracked shows untracked files' '
333
git stash show -p --include-untracked >actual &&
334
test_cmp expect actual &&
335
git stash show --include-untracked -p >actual &&
336
+ test_cmp expect actual &&
337
+ git -c stash.showIncludeUntracked=true stash show -p >actual &&
338
test_cmp expect actual
339
'
340