Skip to content

Commit af5cd44

Browse files
Denton-Lgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1ff595d commit af5cd44

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

Documentation/config/stash.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ stash.useBuiltin::
66
remaining users that setting this now does nothing.
77

88
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].
1212

1313
stash.showPatch::
1414
If this is set to true, the `git stash show` command without an

Documentation/git-stash.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]::
9191
By default, the command shows the diffstat, but it will accept any
9292
format known to 'git diff' (e.g., `git stash show -p stash@{1}`
9393
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.
9698

9799
pop [--index] [-q|--quiet] [<stash>]::
98100

builtin/stash.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
831831
UNTRACKED_NONE,
832832
UNTRACKED_INCLUDE,
833833
UNTRACKED_ONLY
834-
} show_untracked = UNTRACKED_NONE;
834+
} show_untracked = show_include_untracked ? UNTRACKED_INCLUDE : UNTRACKED_NONE;
835835
struct option options[] = {
836836
OPT_SET_INT('u', "include-untracked", &show_untracked,
837837
N_("include untracked files in the stash"),
@@ -874,9 +874,6 @@ static int show_stash(int argc, const char **argv, const char *prefix)
874874
if (show_patch)
875875
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
876876

877-
if (show_include_untracked)
878-
show_untracked = UNTRACKED_INCLUDE;
879-
880877
if (!show_stat && !show_patch) {
881878
free_stash_info(&info);
882879
return 0;

t/t3905-stash-include-untracked.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ test_expect_success 'stash show --include-untracked shows untracked files' '
333333
git stash show -p --include-untracked >actual &&
334334
test_cmp expect actual &&
335335
git stash show --include-untracked -p >actual &&
336+
test_cmp expect actual &&
337+
git -c stash.showIncludeUntracked=true stash show -p >actual &&
336338
test_cmp expect actual
337339
'
338340

0 commit comments

Comments
 (0)