]> git.ipfire.org Git - thirdparty/git.git/commitdiff
stash show: learn stash.showIncludeUntracked
authorDenton Liu <liu.denton@gmail.com>
Wed, 3 Mar 2021 11:16:43 +0000 (03:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Mar 2021 22:31:27 +0000 (14:31 -0800)
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 <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/stash.txt
Documentation/git-stash.txt
builtin/stash.c
t/t3905-stash-include-untracked.sh

index 00eb35434e883d917d895296e4b1bfd726bac29b..413f907cba059dfac0b7d481a652b253b3c588b5 100644 (file)
@@ -5,6 +5,11 @@ stash.useBuiltin::
        is always used. Setting this will emit a warning, to alert any
        remaining users that setting this now does nothing.
 
+stash.showIncludeUntracked::
+       If this is set to true, the `git stash show` command without an
+       option will show the untracked files of a stash entry.  Defaults to
+       false. See description of 'show' command in linkgit:git-stash[1].
+
 stash.showPatch::
        If this is set to true, the `git stash show` command without an
        option will show the stash entry in patch form.  Defaults to false.
index 8eeb60feb15dfec3def6038e42ff4967467c6f1e..a8c8c32f1e5157cdc7bd543a8882211ebfb1cc14 100644 (file)
@@ -91,8 +91,8 @@ show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]::
        By default, the command shows the diffstat, but it will accept any
        format known to 'git diff' (e.g., `git stash show -p stash@{1}`
        to view the second most recent entry in patch form).
-       You can use stash.showStat and/or stash.showPatch config variables
-       to change the default behavior.
+       You can use stash.showIncludeUntracked, stash.showStat, and
+       stash.showPatch config variables to change the default behavior.
 
 pop [--index] [-q|--quiet] [<stash>]::
 
index 9b7a541cd0ee41ba41273f852870fca428cdcb26..8922a1240c6344f7086b0eccb08e6c7b2dddef30 100644 (file)
@@ -768,6 +768,7 @@ static int list_stash(int argc, const char **argv, const char *prefix)
 
 static int show_stat = 1;
 static int show_patch;
+static int show_include_untracked;
 static int use_legacy_stash;
 
 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)
                show_patch = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "stash.showincludeuntracked")) {
+               show_include_untracked = git_config_bool(var, value);
+               return 0;
+       }
        if (!strcmp(var, "stash.usebuiltin")) {
                use_legacy_stash = !git_config_bool(var, value);
                return 0;
@@ -869,6 +874,9 @@ static int show_stash(int argc, const char **argv, const char *prefix)
                if (show_patch)
                        rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
 
+               if (show_include_untracked)
+                       show_untracked = UNTRACKED_INCLUDE;
+
                if (!show_stat && !show_patch) {
                        free_stash_info(&info);
                        return 0;
index 08ceef64111e3a663805272259244fecdcccbcba..b470db7ef7b4af6d9780b600da70c34ed8e5b6a1 100755 (executable)
@@ -319,6 +319,8 @@ test_expect_success 'stash show --include-untracked shows untracked files' '
        test_cmp expect actual &&
        git stash show --only-untracked --include-untracked >actual &&
        test_cmp expect actual &&
+       git -c stash.showIncludeUntracked=true stash show >actual &&
+       test_cmp expect actual &&
 
        cat >expect <<-EOF &&
        diff --git a/tracked b/tracked