Skip to content

Commit 0af760e

Browse files
Denton-Lgitster
authored andcommitted
stash show: learn stash.showIncludeUntracked
The previous commit teaches `git stash show --include-untracked`. It may be desirable for a user to be able to always enable the --include-untracked behavior. Teach the stash.showIncludeUntracked config option which allows users to do this in a similar manner to stash.showPatch. Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d3c7bf7 commit 0af760e

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

Documentation/config/stash.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ stash.useBuiltin::
55
is always used. Setting this will emit a warning, to alert any
66
remaining users that setting this now does nothing.
77

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].
12+
813
stash.showPatch::
914
If this is set to true, the `git stash show` command without an
1015
option will show the stash entry in patch form. Defaults to false.

Documentation/git-stash.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ 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.showStat and/or stash.showPatch config variables
95-
to change the default behavior.
94+
You can use stash.showIncludeUntracked, stash.showStat, and
95+
stash.showPatch config variables to change the default behavior.
9696

9797
pop [--index] [-q|--quiet] [<stash>]::
9898

builtin/stash.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ static int list_stash(int argc, const char **argv, const char *prefix)
768768

769769
static int show_stat = 1;
770770
static int show_patch;
771+
static int show_include_untracked;
771772
static int use_legacy_stash;
772773

773774
static int git_stash_config(const char *var, const char *value, void *cb)
@@ -780,6 +781,10 @@ static int git_stash_config(const char *var, const char *value, void *cb)
780781
show_patch = git_config_bool(var, value);
781782
return 0;
782783
}
784+
if (!strcmp(var, "stash.showincludeuntracked")) {
785+
show_include_untracked = git_config_bool(var, value);
786+
return 0;
787+
}
783788
if (!strcmp(var, "stash.usebuiltin")) {
784789
use_legacy_stash = !git_config_bool(var, value);
785790
return 0;
@@ -869,6 +874,9 @@ static int show_stash(int argc, const char **argv, const char *prefix)
869874
if (show_patch)
870875
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
871876

877+
if (show_include_untracked)
878+
show_untracked = UNTRACKED_INCLUDE;
879+
872880
if (!show_stat && !show_patch) {
873881
free_stash_info(&info);
874882
return 0;

t/t3905-stash-include-untracked.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ test_expect_success 'stash show --include-untracked shows untracked files' '
319319
test_cmp expect actual &&
320320
git stash show --only-untracked --include-untracked >actual &&
321321
test_cmp expect actual &&
322+
git -c stash.showIncludeUntracked=true stash show >actual &&
323+
test_cmp expect actual &&
322324
323325
cat >expect <<-EOF &&
324326
diff --git a/tracked b/tracked

0 commit comments

Comments
 (0)