From patchwork Tue Feb 2 09:33:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0948C433E0 for ; Tue, 2 Feb 2021 09:34:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AC0D64EE4 for ; Tue, 2 Feb 2021 09:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232643AbhBBJex (ORCPT ); Tue, 2 Feb 2021 04:34:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231688AbhBBJe1 (ORCPT ); Tue, 2 Feb 2021 04:34:27 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80282C061573 for ; Tue, 2 Feb 2021 01:33:47 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id y10so7886674plk.7 for ; Tue, 02 Feb 2021 01:33:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QT02VIMAM8UX072iG0VP9UA3J9ck5MTLRQXakDA1lIA=; b=XKV/0FtCfBdNddD6QnLibH6pXuf9ivKRzMmJF54GVy4LMvI2/grwYp2qDipYNh5eR/ 6D3YOVQ977U8SsqC7+qqubukRhiVcunFzlns56Uy3BLKIW2Xi6/sQcT7FPt0xvPLH8Ge r9QziHgVxBDaPzhHKNruiZC5u32jIp1N+BLN78Okzq7eNkvjOe00TlqLmkz1VfBN27l+ s5mLudu2urQgKJRnnRVNmfaQa6LElNlhU7d3gAIRtvHIqnlCpjLcX2apNetpD54r9Vrm 3gdhhNatO/v8eF6LWLkoiR5MwQPyJzzVka4bDeUHxciFd7uD2ftiicgRiPNU7kwBwezG 6JmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QT02VIMAM8UX072iG0VP9UA3J9ck5MTLRQXakDA1lIA=; b=H4Bzq8NnNTD8DnFSgkvn5LzVlTD4IYudxRqPMEaRhjxAbvbjqkp2e/GV/y5LI9+Icx 6F4y7lYLFDkYblpeDsmfOgG7vrdDQNHshghpxEcLwmytDnNuUmLZUSbwAMGKOrjyqXkE /cLx3+SYIAsfcYnaA2UdzRc+RZFCQf6C9jehN1n9gNZ/s/uxZeSxg+bYEciiUFd+0LaT Rsf8wP6CSAIPBotumEBX2MLQR9W2DPGJVikDRny31vAvdZfkadrwvxcLOzrpR3g2BQhz GhZGRkIkV8oUC+BgOlJ75nFExGwhnujnTj9p0dbHrcqd8x4c9wUIJHmt4SfWlju5tdzG ulJw== X-Gm-Message-State: AOAM531fkbkYumosUIQbS/XHD/zy0h+j1+QBrrJJC3Fjgy/hVED2NNN3 cZ3AdDNOyuw4n/hTCXRgsznZ5b2E3qs= X-Google-Smtp-Source: ABdhPJzH4HdUNY2VrSPeOWmPGKGeDl9EoCW41Z1/Tvtd+Fica0pG10N6wRsBE//jK0PH92aBUQWSBA== X-Received: by 2002:a17:90a:304:: with SMTP id 4mr3400708pje.126.1612258426912; Tue, 02 Feb 2021 01:33:46 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:33:38 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 1/9] git-stash.txt: be explicit about subcommand options Date: Tue, 2 Feb 2021 01:33:18 -0800 Message-Id: <17675b9e4c0c50e6bfd5219c933b5ba1148ab86c.1612258145.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, the options for the `list` and `show` subcommands are just listed as ``. This seems to imply, from a cursory glance at the summary, that they take the stash options listed below. However, reading more carefully, we see that they take log options and diff options respectively. Make it more obvious that they take log and diff options by explicitly stating this in the subcommand summary. Signed-off-by: Denton Liu --- Documentation/git-stash.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 31f1beb65b..46ee37b35a 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -67,7 +67,7 @@ save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q Instead, all non-option arguments are concatenated to form the stash message. -list []:: +list []:: List the stash entries that you currently have. Each 'stash entry' is listed with its name (e.g. `stash@{0}` is the latest entry, `stash@{1}` is @@ -83,7 +83,7 @@ stash@{1}: On master: 9cc0589... Add git-stash The command takes options applicable to the 'git log' command to control what is shown and how. See linkgit:git-log[1]. -show [] []:: +show [] []:: Show the changes recorded in the stash entry as a diff between the stashed contents and the commit back when the stash entry was first From patchwork Tue Feb 2 09:33:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36420C433DB for ; Tue, 2 Feb 2021 09:36:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E962364D99 for ; Tue, 2 Feb 2021 09:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233038AbhBBJgH (ORCPT ); Tue, 2 Feb 2021 04:36:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232991AbhBBJfN (ORCPT ); Tue, 2 Feb 2021 04:35:13 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88900C061794 for ; Tue, 2 Feb 2021 01:33:57 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id y10so7886927plk.7 for ; Tue, 02 Feb 2021 01:33:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BU0Hi7RAV2KElXGBIE71hMJoCEINqunWPtqs8tMqIso=; b=QZ8kA4UWMqZL5/Aj0BW20RliHcE1kmCfovX2HGry5R3D+Jb209ZhqwSXq/N5e+EcDB JSTx6isR630uT98AV9HiXuCRgmPpXe/tzCWs0u/e/1qVGzbAWczXS60krFSagXtRCzDc pFP+/85XG7JcJE1VzGftZvItfZOM0Ub2FHBBBkGloygJjaLJiCm6fhONri0R2R465/Ix jKz7IReaKYtwT7kya3DVBOXZQIO9CNUwaRiCy3/EsnU1jK4XqC/0No56cmgHLWxygI3a 4gtYb/XCaXNK/LIAQ6nHs4XcgjJl4zBZHb10WYSTrBik4vEhTx+fuUVIonmfTTgyMegv vQTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BU0Hi7RAV2KElXGBIE71hMJoCEINqunWPtqs8tMqIso=; b=pYOIQTKAa79EaoVS8PxoErtsuCQyqRVbybsFl1uJ1NaUvDdN8/AiFN9OUzs1/7/do8 KtLFCqw11qVvfEGPw59cm2LdalQM1gH0kmqpImS+GgFOZq9fvkX9TIRP409P2bzEaK2d qLdlgyJwWC96mAQyNENH/l9Iw9x50AAzyeYHCWajrE1tYn8LgdsJdC8EvyTTqOZF+j22 2lNoUbnTfxvxXms0NWHDVb+cSbQrx2WVucOSfvLPd97GDcXBblpnHXTeT5/AO+6fJbcL afqEUODGH0Snan21/BIn6futK5ONg1VJKSQXQMeSLv6vajABZp2XlsOoOA58xvjnHuqd 1eDw== X-Gm-Message-State: AOAM531P+Vv17RyyKTVGkPxFBp06zwFnahhnwGJ+WG/XSJM7FLfDgf7V uH8vrVDXpDnZ/Qrjg65DzwEG8QfGy4k= X-Google-Smtp-Source: ABdhPJyYsW7fk6xNshs2PYXEKOJib9OyqyZWvEjzA11jd+EHYqlg8jsH2R14RiMHPtO3uHZ4j3BJ+g== X-Received: by 2002:a17:902:8643:b029:da:d5f9:28f6 with SMTP id y3-20020a1709028643b02900dad5f928f6mr21542137plt.8.1612258436863; Tue, 02 Feb 2021 01:33:56 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.33.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:33:48 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 2/9] t3905: remove spaces after redirect operators Date: Tue, 2 Feb 2021 01:33:19 -0800 Message-Id: <0de324e3bc9b900a0e4badd9eba58d196d4f4f0a.1612258145.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org For shell scripts, the usual convention is for there to be no space after redirection operators, (e.g. `>file`, not `> file`). Remove these spaces wherever they appear. Signed-off-by: Denton Liu --- t/t3905-stash-include-untracked.sh | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index f075c7f1f3..1d416944b7 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -8,16 +8,16 @@ test_description='Test git stash --include-untracked' . ./test-lib.sh test_expect_success 'stash save --include-untracked some dirty working directory' ' - echo 1 > file && + echo 1 >file && git add file && test_tick && git commit -m initial && - echo 2 > file && + echo 2 >file && git add file && - echo 3 > file && + echo 3 >file && test_tick && - echo 1 > file2 && - echo 1 > HEAD && + echo 1 >file2 && + echo 1 >HEAD && mkdir untracked && echo untracked >untracked/untracked && git stash --include-untracked && @@ -25,7 +25,7 @@ test_expect_success 'stash save --include-untracked some dirty working directory git diff-index --cached --quiet HEAD ' -cat > expect <expect < expect.diff <expect.diff < expect.lstree <expect.lstree < expect <expect < file3 && + echo 4 >file3 && git add file3 && test_tick && git stash -u ' blob=$(git rev-parse --short $(echo 4 | git hash-object --stdin)) -cat > expect <expect < /dev/null +git reset >/dev/null # Must direct output somewhere where it won't be considered an untracked file test_expect_success 'stash save --include-untracked -q is quiet' ' - echo 1 > file5 && - git stash save --include-untracked --quiet > .git/stash-output.out 2>&1 && + echo 1 >file5 && + git stash save --include-untracked --quiet >.git/stash-output.out 2>&1 && test_line_count = 0 .git/stash-output.out && rm -f .git/stash-output.out ' @@ -141,7 +141,7 @@ test_expect_success 'stash save --include-untracked -q is quiet' ' test_expect_success 'stash save --include-untracked removed files' ' rm -f file && git stash save --include-untracked && - echo 1 > expect && + echo 1 >expect && test_cmp expect file ' @@ -152,14 +152,14 @@ test_expect_success 'stash save --include-untracked removed files got stashed' ' test_path_is_missing file ' -cat > .gitignore <.gitignore < ignored && + echo ignored >ignored && mkdir ignored.d && echo ignored >ignored.d/untracked && git stash -u && @@ -169,7 +169,7 @@ test_expect_success 'stash save --include-untracked respects .gitignore' ' ' test_expect_success 'stash save -u can stash with only untracked files different' ' - echo 4 > file4 && + echo 4 >file4 && git stash -u && test_path_is_missing file4 ' @@ -214,7 +214,7 @@ test_expect_success 'stash push with $IFS character' ' test_path_is_file bar ' -cat > .gitignore <.gitignore <ignored.d/foo && - echo "!ignored.d/foo" >> .gitignore && + echo "!ignored.d/foo" >>.gitignore && git stash save --include-untracked && test_path_is_missing ignored.d/foo && git stash pop && From patchwork Tue Feb 2 09:33:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E48BC43381 for ; Tue, 2 Feb 2021 09:37:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B895F64F71 for ; Tue, 2 Feb 2021 09:36:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232971AbhBBJgo (ORCPT ); Tue, 2 Feb 2021 04:36:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232760AbhBBJfj (ORCPT ); Tue, 2 Feb 2021 04:35:39 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA98C061352 for ; Tue, 2 Feb 2021 01:34:03 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id g3so12155000plp.2 for ; Tue, 02 Feb 2021 01:34:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Fa4WF191om12EiQOY/vS3OYpTRVsVVT2Ao7zH3DjI8U=; b=rXcJCMYCOMNSj8QzvqLyoaYR97zG1bgPvLnMjgVHRlfl8SwSn/vcdbSEjBmlaFc6QB 0WJ3gS4CU6+rCLxB1LyRQ/z8ihpWNJqxZVZAgAGlMpOD2nfX7sZyV+yrt9Cvyk7ZMXnd gCuD0BBaWf6RNGI8cvI7c0pEv1iEV/MLU6cduN5UGec7vwQb4KiXDwqA0yBowDz5CXzE VoHVdU43G209aOJsQi+IsmYfnzMhJOCMBYEUvIN0HJLQCFf1YiM71CC5CpeKgFADpkle 1gwt6QSGRJS0ggzK0YadJAZX5UD59bKWoOUbraeMVX9l9AaBw69U03x6UaeNGOM3ROF2 dK4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fa4WF191om12EiQOY/vS3OYpTRVsVVT2Ao7zH3DjI8U=; b=h5YgeVBUJvqfQmSD2GZk9Mlnpu6P/WA3lIkjIVcUcbFLRL2q7d1KYwWAukoQkaWFuE srScyCt+z2yqz7mvUB80cQgRJoNDxJwkAx+N9rMjsXZgy3g9G3WflDGjEdQN2F1HXrun hpSYqkVhL7SZABYohTGLUC7xMSwW0L4g6sV8Bu/FZP4JBLNGM9FF/sXzT5aR69xyaO5v pMYozJ4jQI/YK1Y2b+YMqxyyqc7n1j/llTW2YeGanD63vK04lRiv3Z0EmLt7e0kqGPjo 7dHdUbUWDoFqMj00aySVsqdf4AltcvMd5yE9lfuAxE2lD/2wcfVRjvT+KzSpu2oYV3l3 ovVg== X-Gm-Message-State: AOAM533R8IhZODwoK5w+Oyf1jMMxTVlQjwpu0EYz1SBaXrZkwji87WX5 lYsvSZKkQlTt+5dB9bWoQHJ6x9MnxjU= X-Google-Smtp-Source: ABdhPJzkM/gaTuB41HY1laKttBeexRqWYGNdL/pPWHd1ClfXr0FFCzsMk6iJE1sOBFt3yj2IHerwdA== X-Received: by 2002:a17:90b:350b:: with SMTP id ls11mr3394803pjb.166.1612258443093; Tue, 02 Feb 2021 01:34:03 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.33.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:33:58 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 3/9] t3905: move all commands into test cases Date: Tue, 2 Feb 2021 01:33:20 -0800 Message-Id: <519840b1a280fd1a47c028ba9de776727ed77608.1612258145.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In order to modernize the tests, move commands that currently run outside of test cases into a test case. Where possible, clean up files that are produced using test_when_finished() but in the case where files persist over multiple test cases, create a new test case to perform cleanup. Signed-off-by: Denton Liu --- t/t3905-stash-include-untracked.sh | 147 +++++++++++++++-------------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index 1d416944b7..892a2c8057 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -25,48 +25,48 @@ test_expect_success 'stash save --include-untracked some dirty working directory git diff-index --cached --quiet HEAD ' -cat >expect <expect <<-EOF && + ?? actual + ?? expect + EOF + git status --porcelain >actual && test_cmp expect actual ' -tracked=$(git rev-parse --short $(echo 1 | git hash-object --stdin)) -untracked=$(git rev-parse --short $(echo untracked | git hash-object --stdin)) -cat >expect.diff <expect.lstree <expect.diff <<-EOF && + diff --git a/HEAD b/HEAD + new file mode 100644 + index 0000000..$tracked + --- /dev/null + +++ b/HEAD + @@ -0,0 +1 @@ + +1 + diff --git a/file2 b/file2 + new file mode 100644 + index 0000000..$tracked + --- /dev/null + +++ b/file2 + @@ -0,0 +1 @@ + +1 + diff --git a/untracked/untracked b/untracked/untracked + new file mode 100644 + index 0000000..$untracked + --- /dev/null + +++ b/untracked/untracked + @@ -0,0 +1 @@ + +untracked + EOF + cat >expect.lstree <<-EOF && + HEAD + file2 + untracked + EOF + test_path_is_missing file2 && test_path_is_missing untracked && test_path_is_missing HEAD && @@ -83,18 +83,21 @@ test_expect_success 'stash save --patch --all fails' ' test_must_fail git stash --patch --all ' -git clean --force --quiet +test_expect_success 'clean up untracked/untracked file to prepare for next tests' ' + git clean --force --quiet -cat >expect <expect <<-EOF && + M file + ?? HEAD + ?? actual + ?? expect + ?? file2 + ?? untracked/ + EOF + git stash pop && git status --porcelain >actual && test_cmp expect actual && @@ -102,7 +105,9 @@ test_expect_success 'stash pop after save --include-untracked leaves files untra test untracked = "$(cat untracked/untracked)" ' -git clean --force --quiet -d +test_expect_success 'clean up untracked/ directory to prepare for next tests' ' + git clean --force --quiet -d +' test_expect_success 'stash save -u dirty index' ' echo 4 >file3 && @@ -111,25 +116,24 @@ test_expect_success 'stash save -u dirty index' ' git stash -u ' -blob=$(git rev-parse --short $(echo 4 | git hash-object --stdin)) -cat >expect <expect <<-EOF && + diff --git a/file3 b/file3 + new file mode 100644 + index 0000000..$blob + --- /dev/null + +++ b/file3 + @@ -0,0 +1 @@ + +4 + EOF + git stash pop --index && + test_when_finished "git reset" && git diff --cached >actual && test_cmp expect actual ' -git reset >/dev/null - # Must direct output somewhere where it won't be considered an untracked file test_expect_success 'stash save --include-untracked -q is quiet' ' echo 1 >file5 && @@ -142,23 +146,22 @@ test_expect_success 'stash save --include-untracked removed files' ' rm -f file && git stash save --include-untracked && echo 1 >expect && + test_when_finished "rm -f expect" && test_cmp expect file ' -rm -f expect - test_expect_success 'stash save --include-untracked removed files got stashed' ' git stash pop && test_path_is_missing file ' -cat >.gitignore <.gitignore <<-EOF && + .gitignore + ignored + ignored.d/ + EOF + echo ignored >ignored && mkdir ignored.d && echo ignored >ignored.d/untracked && @@ -214,12 +217,12 @@ test_expect_success 'stash push with $IFS character' ' test_path_is_file bar ' -cat >.gitignore <.gitignore <<-EOF && + ignored + ignored.d/* + EOF + git reset HEAD && git add .gitignore && git commit -m "Add .gitignore" && From patchwork Tue Feb 2 09:33:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07B7FC433E6 for ; Tue, 2 Feb 2021 09:36:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA25164F79 for ; Tue, 2 Feb 2021 09:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233034AbhBBJgD (ORCPT ); Tue, 2 Feb 2021 04:36:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbhBBJfN (ORCPT ); Tue, 2 Feb 2021 04:35:13 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E78C061356 for ; Tue, 2 Feb 2021 01:34:09 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id q72so504011pjq.2 for ; Tue, 02 Feb 2021 01:34:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=B5MZdMNbM5AFSKMClKB4E4pNrhzrspPMYiL+ukzcmts=; b=p0eEJaXN2P+XsuTR4MCj6ZLZYRk/j7SNFR3TCc3+EzYH1wqDRgEX+urVpkGi48EACc /4pOJPhh6tj04C+/3tK2JWYUjGLMwcDSFe4nrsAwKHrp41elm3gQImFFGFHtka5fL8F7 Vdy/jRLmTTfZ0nnTqXz9wXPc+n+UOfT61pqmREjqrpYxRmuWzS/keeqv2UvxQM5DC39N rcUv8nC9jk2/wU//psIaj9uKUhghV2Nr2Z5ToaQhtLcKEadQ35g/DWSOFo1aMRo/eWL1 NyOyBtgkUx+1b+W+BCEU2mQ3T92w4Z+KyJBG1JzSgS1Kfd7H0TIu9giSKzQFdvb0kraG dq/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B5MZdMNbM5AFSKMClKB4E4pNrhzrspPMYiL+ukzcmts=; b=YvR1hzqxKwufosDEjEblxj6D/TYWcdpvNQHfFeVhDtWzmFSW82BoZtpnJ9npzhLpFN rR4MHuGEUwXocFiLW7OLJpKKnAoJJSi5tV4twSP4Im8L8VbcJPUnYehq29BayVDKPZ/Y kgrc8KC59OIo6F+8pWIapu5fTnZLgIdUuT6GSKoCOscaHwSkYQyLltsMImFQdCargBmO Ap8pNw5keGjNeRK2ELLSdSpiGlTFdalR8GlsRAF/z5urq7N2nta3fvCXIwCIvf6/ye5A HcYuAAl6QEo354c1LSFsFhXJKp3wcZ40BUlUu3ady1a+LcDkYwuZaqZo4PXqLYOd7xJm 4DVg== X-Gm-Message-State: AOAM533ofLG0xgiBgwzRe8RB2I0mhml90N+3k1UxjqabyNG+Wre0Uaxy PLJDqRYCwuqg/1CTeoOJcO5Q3l8SQXI= X-Google-Smtp-Source: ABdhPJyFcRfgm/XjX+eprei/p5WjYPzzDh25Qhg/4a/+TEd4tNmXkcsEF3jOVpHBbZBVv14Zb7V4nQ== X-Received: by 2002:a17:902:f686:b029:de:18c7:41f8 with SMTP id l6-20020a170902f686b02900de18c741f8mr21805648plg.65.1612258448409; Tue, 02 Feb 2021 01:34:08 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:34:04 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 4/9] t3905: remove nested git in command substitution Date: Tue, 2 Feb 2021 01:33:21 -0800 Message-Id: <4b72d39e01ab674cd6c9a15332021950b4e35b23.1612258145.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org If a git command in a nested command substitution fails, it will be silently ignored since only the return code of the outer command substitutions is reported. Factor out nested command substitutions so that the error codes of those commands are reported. Signed-off-by: Denton Liu --- t/t3905-stash-include-untracked.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index 892a2c8057..f008e5d945 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -36,8 +36,10 @@ test_expect_success 'stash save --include-untracked cleaned the untracked files' ' test_expect_success 'stash save --include-untracked stashed the untracked files' ' - tracked=$(git rev-parse --short $(echo 1 | git hash-object --stdin)) && - untracked=$(git rev-parse --short $(echo untracked | git hash-object --stdin)) && + one_blob=$(echo 1 | git hash-object --stdin) && + tracked=$(git rev-parse --short "$one_blob") && + untracked_blob=$(echo untracked | git hash-object --stdin) && + untracked=$(git rev-parse --short "$untracked_blob") && cat >expect.diff <<-EOF && diff --git a/HEAD b/HEAD new file mode 100644 @@ -117,7 +119,8 @@ test_expect_success 'stash save -u dirty index' ' ' test_expect_success 'stash save --include-untracked dirty index got stashed' ' - blob=$(git rev-parse --short $(echo 4 | git hash-object --stdin)) && + four_blob=$(echo 4 | git hash-object --stdin) && + blob=$(git rev-parse --short "$four_blob") && cat >expect <<-EOF && diff --git a/file3 b/file3 new file mode 100644 From patchwork Tue Feb 2 09:33:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD6EBC433DB for ; Tue, 2 Feb 2021 09:38:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8279764D99 for ; Tue, 2 Feb 2021 09:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231256AbhBBJid (ORCPT ); Tue, 2 Feb 2021 04:38:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232996AbhBBJgV (ORCPT ); Tue, 2 Feb 2021 04:36:21 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82790C061221 for ; Tue, 2 Feb 2021 01:34:14 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id d2so1987840pjs.4 for ; Tue, 02 Feb 2021 01:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gNSRZvmx9+OCMyIXehfEVMJ0vxwEygopOVzVXTd4+OE=; b=jdgLH9PiwnGYPOeRs69KTw2M6dstJKfYLigeESORXxXwzSK0BVbH76Q5LKAOOxitEw 2yev8xcLieOwxzay2/aA7n/Ye+Cpyw5hK5Y6RK+CgDy/E8Fs8ZzQVmDb1xsru3tiWn1R wQI9jmYjP0GKaYhGYBmSrhAx75UjlbmfrZ2lV1AJxhV+bMdSFruYPQ4bLVsuyN0gf5Qz rvuTYTpI2PCzZewqdE7g7Ngr4gBA+XDUjCW8risak8hI8kOrHJ7rONnjvGv1ep5PNeSp 9rDoi3j5dVnJun446lJwBa06MscQVLLTiSwt+fFEnLwF4hnya33fMn8hg9aBFKw2YYLD V3AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gNSRZvmx9+OCMyIXehfEVMJ0vxwEygopOVzVXTd4+OE=; b=lx5x+W2KAys9gWhfdpukzYnNDzZ6Z3DngAMVtmH8LAe9DfsO5uoyl7dQbGXsqXOSW3 jY2aARYP6IztfEi3rX4iLZiIkMtEAAx011x/FGkRChuhBA53vNsUHxjP0I/P1oTbNNBU WrtCpGXYDCrUyVD+QLhBhnOoimBkQeRZSnbeRu/FkNXePRw+pwDtM7MpbrlS12MWuFQj FLNxpvxVsSJRt5iVylCj0OQmZfD5RphmWEDCtamY9EjglbgmN65o3BVkcrThhQL8BVdn /Lz7gIL/nkUrHpPFbxoxWFBrlgFU4/sWNINc2zI5k5nbvDY7cBhi9PlAVUJQW9VodGAJ fhkw== X-Gm-Message-State: AOAM531va6NiSvVwlavedvTVxxrZ+ZxxFPeE15fLBX6QAK18QwVa8mkj dpXLxOLlfPS2+ONbtHwPeHuvVlEzrI0= X-Google-Smtp-Source: ABdhPJwBATCoGOBc7o6tuO6S72lo8IzmEATYGLmSFZgsb7SEhdOYZ6Bcl02rzW4ZB7L+APGkYnvjHA== X-Received: by 2002:a17:90a:ca8f:: with SMTP id y15mr3364642pjt.119.1612258453927; Tue, 02 Feb 2021 01:34:13 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.34.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:34:09 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 5/9] t3905: replace test -s with test_file_not_empty Date: Tue, 2 Feb 2021 01:33:22 -0800 Message-Id: <7fe27ab620457af9b777f6087dc5c235fb87eb01.1612258145.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In order to modernize the test script, replace `test -s` with test_file_not_empty(), which provides better diagnostic output in the case of failure. Signed-off-by: Denton Liu --- t/t3905-stash-include-untracked.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index f008e5d945..c87ac24042 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -169,9 +169,9 @@ test_expect_success 'stash save --include-untracked respects .gitignore' ' mkdir ignored.d && echo ignored >ignored.d/untracked && git stash -u && - test -s ignored && - test -s ignored.d/untracked && - test -s .gitignore + test_file_not_empty ignored && + test_file_not_empty ignored.d/untracked && + test_file_not_empty .gitignore ' test_expect_success 'stash save -u can stash with only untracked files different' ' @@ -189,9 +189,9 @@ test_expect_success 'stash save --all does not respect .gitignore' ' test_expect_success 'stash save --all is stash poppable' ' git stash pop && - test -s ignored && - test -s ignored.d/untracked && - test -s .gitignore + test_file_not_empty ignored && + test_file_not_empty ignored.d/untracked && + test_file_not_empty .gitignore ' test_expect_success 'stash push --include-untracked with pathspec' ' From patchwork Tue Feb 2 09:33:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6BF1C433DB for ; Tue, 2 Feb 2021 09:40:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5671464EDC for ; Tue, 2 Feb 2021 09:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbhBBJkD (ORCPT ); Tue, 2 Feb 2021 04:40:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233069AbhBBJge (ORCPT ); Tue, 2 Feb 2021 04:36:34 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D157C0611C1 for ; Tue, 2 Feb 2021 01:34:20 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id g3so12155401plp.2 for ; Tue, 02 Feb 2021 01:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AKVyUTQ0PTfwwq76gRTHowmfpb1YnfKrY/iiF8w8GJ8=; b=r79VgWQ1SPARulh/JRIyUZ+ckvvqMN4nZkRQ07O9YDvX9NIrILoZE9zM3GgAepfXsY p+U+a+TT98nOhNVADiC5CDoIBo2hiU35hfRh7iSsyAQYXdJDdXg4dNv8xOXk0G09xGxa cNM0PMx/BxrTbmlukGLKi18zcBu7nmsm4LqW3dR8hz08pJwhATjKBccgmpyvr+jJv7Jv iNMVVC7GPLIQnLDYw3geUTRueVQ/2davGeuyFzVt2xYeYp/gaxbcJPzUPbAwS0ZWB+M+ syQxlv1eaVRX228blvza7naW2+CMvrbfDFqLIWA1rROgi/Sy6NEsgbWBFQaMb8+Ijy3L pXvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AKVyUTQ0PTfwwq76gRTHowmfpb1YnfKrY/iiF8w8GJ8=; b=Sm7JTeEHwymtWbVrBk9xHsIq3jJyyGqpT7nINT+k7mnGjuUTUIr5J1/1TH/pyyErYk 4MqMhAbQ/TmhzkjxMgZXBgQ5XYwHvlseFHGUBknVVx2JdJb8MEnp22NvwrEp0lo0Vx/G C+ajNTPtn1GD8i477rFed0ZxqB3cmMSVEw1Q/7op0m0inCYbFY0QGeV5mq7KMg2LxZv5 gJXDhZRVGFnrd78yLSYqPRhBhu8nYuvg4UWCirYKNA2iWygNsDy6RhyECok6JOQ3hJUF ySP7FTkFfH9zCJyGEeJ8GW19eEZlmYNtk4iJoSZd0/Je3Ux3Q4IKDxPBYRGhKPviqhcG ku7g== X-Gm-Message-State: AOAM532/pvnhqOOhGgcL1I9wTbRQmTUgt6KmLRLANiIpFWefF0X8l+E8 3XejySCeHPHBilmxDlWSWgx4Bvj1OVM= X-Google-Smtp-Source: ABdhPJz+Sdtly9YNZDG5D7CVRdwvomRi5P0VwCQ463yq47Ylu3v0UlHDrqv5eYZFA7VbnO3RvAamnA== X-Received: by 2002:a17:90b:358f:: with SMTP id mm15mr3430630pjb.13.1612258459939; Tue, 02 Feb 2021 01:34:19 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.34.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:34:14 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 6/9] t3905: use test_cmp() to check file contents Date: Tue, 2 Feb 2021 01:33:23 -0800 Message-Id: <4a5dd83ff4269c10e20e0af4867d3c574b04edf8.1612258145.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Modernize the script by doing file content comparisons using test_cmp() instead of `test x = "$(cat file)"`. Signed-off-by: Denton Liu --- t/t3905-stash-include-untracked.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index c87ac24042..b26a97aef4 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -103,8 +103,10 @@ test_expect_success 'stash pop after save --include-untracked leaves files untra git stash pop && git status --porcelain >actual && test_cmp expect actual && - test "1" = "$(cat file2)" && - test untracked = "$(cat untracked/untracked)" + echo 1 >expect_file2 && + test_cmp expect_file2 file2 && + echo untracked >untracked_expect && + test_cmp untracked_expect untracked/untracked ' test_expect_success 'clean up untracked/ directory to prepare for next tests' ' From patchwork Tue Feb 2 09:33:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FD7DC433E9 for ; Tue, 2 Feb 2021 09:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC2E564EDE for ; Tue, 2 Feb 2021 09:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232911AbhBBJjS (ORCPT ); Tue, 2 Feb 2021 04:39:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233075AbhBBJgh (ORCPT ); Tue, 2 Feb 2021 04:36:37 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35E85C0611C2 for ; Tue, 2 Feb 2021 01:34:25 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id s23so13254249pgh.11 for ; Tue, 02 Feb 2021 01:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BjOmTy4dNmgRmOu+FOU2Diqsqn48K0alvnBzauFVVJY=; b=it9Ko8y6oe4GUZ8pPWO4UFAukV6NNrzvu40KckXYSkJ+r+R77ZmnHyVeCmzMWugV9u Kxk4M8xfafW+aPKv8pZT9oRx1jEwlXfNPrbqvaz6altqJl+58F6WRwRUjIqISRoHstTw LSG4pb2XBRGICGaZHbdxZ4QK8QM10//lXZUto60PQYNpcz2kOyzH/bOyEfANhKgLx0ow /7Z4qTmstKC5HgUkCjoJPMd7aMyZWTwx8vYnuGFEkYpld+fEgAnDIMfpRtMT0E48Tq89 345SChESvMm2yw8vsLJlec1Ek7oAhXemNqTVDZZqJimVOIxvTKUwTvhyU90dTA1cAXVa IaEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BjOmTy4dNmgRmOu+FOU2Diqsqn48K0alvnBzauFVVJY=; b=IymL2dgzeTXoSyQjfTRM3A5iP5PELDc2mqZJcrHZaAXj3xbC/rMzDC6kl+Rijoaiwl Lo8dfx/743AIrB5S7oSfzFcFuf3gg9VOCl0cKp5fwy8voR2ndg42caXKPUjHTgG3Bxsn ZShFlqtUWzXaqnx4rTCiIrGNQV6VRxZuaOdSNkjOipvhf2HzUssTOzoVxRQpTiiR0eTd zdLmWNx/qaOGTA2oFa4/QVI3r0AYOllNU7BvvSo8tm+Z/XHKQHM+pD3rii6191OKPju9 zDKOF2uwhdOQjJuHbB+gCIKQ4XtjuFM2Hp2viZFdmCzjix14fsx3uAz+FLwRUfTqkJZD TAIw== X-Gm-Message-State: AOAM531nfib6XNDJRtiaVNZr5lls0V0SeA66omaVUDhf7BX98JYtnldL kr7FxJYpLkppN5dtcFuyERlbuoPAOjc= X-Google-Smtp-Source: ABdhPJy3ld2XmaMXCqZds0xdLLD4vTDruUai29ayptGE5o+k3ABTbS4gMtb1pBO+5WV5Vp+UIelWzA== X-Received: by 2002:a63:1519:: with SMTP id v25mr21145509pgl.217.1612258464589; Tue, 02 Feb 2021 01:34:24 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.34.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:34:20 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 7/9] stash: declare ref_stash as an array Date: Tue, 2 Feb 2021 01:33:24 -0800 Message-Id: X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Save sizeof(const char *) bytes by declaring ref_stash as an array instead of having a redundant pointer to an array. Signed-off-by: Denton Liu --- builtin/stash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/stash.c b/builtin/stash.c index 9bc85f91cd..6f2b58f6ab 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -87,7 +87,7 @@ static const char * const git_stash_save_usage[] = { NULL }; -static const char *ref_stash = "refs/stash"; +static const char ref_stash[] = "refs/stash"; static struct strbuf stash_index_path = STRBUF_INIT; /* From patchwork Tue Feb 2 09:33:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E186CC433DB for ; Tue, 2 Feb 2021 09:38:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 994CC64D99 for ; Tue, 2 Feb 2021 09:38:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbhBBJiu (ORCPT ); Tue, 2 Feb 2021 04:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232949AbhBBJgm (ORCPT ); Tue, 2 Feb 2021 04:36:42 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ADF1C0611C3 for ; Tue, 2 Feb 2021 01:34:30 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id e12so2939864pls.4 for ; Tue, 02 Feb 2021 01:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Mb24iNs3CH80TkM1vK+07ZCcBQ40LSAJhO9Zt4TM7UA=; b=ld6tD1BaJUi+LxzM9SH8sgsQk0IndgxM8mfoehP+nW3OjXtTfrKj9lmnWwwOyRwfA8 ApHVJcSChotqg7U7TklNRzXhzaHL/RXhdfiPrIiBLLk8wv7tEMOwVbRSJ+hdhRjXHqOz iCaSk/eAsQrQGkzTc2UDHGlguYfJOQpRHPCRBgOgK2r3JNMKssXqkissmgCKzgNwSV3z SvYPy9sqU69bR8jH+QMDCNFNB/tgTHqJTVKS6Ng+CGOc72LAyRDjVxRBssAhPKYVjtt+ rfabh+iFVWz11f2UlxiNrMzFqe4UcCcc3w/BL+WMa3+9P7tE4AD5RpdS6tWCCoOUpjfF 62MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mb24iNs3CH80TkM1vK+07ZCcBQ40LSAJhO9Zt4TM7UA=; b=sdjw6Pvsoomwn0zGmm0UhChT8IQrPr8lGJSskzXGc12thyG5w8wAkmG+z2/xolrZnK /hWD7ndbVy8dQWnwBtnSJ5nIGwh6+Gb/bIqk+a8KYcUHpxh5BEdxBzn2EYK/Ebp6KLuQ 9D6+KkMxp3ElYX9NIOUgx0olystqgWkDmDtbNVH4U6zl3MUYT/g0d7ti2QDlYixbzwPg kijbGV8CZVYs38GLNpyvXP8vzfDO9ntnPa6ydYsySwTBl0pipSWA6JU9vaSMqrZz+RL9 cWBBpff/bHZpMtk/00vEsBicN7sZfy5mL4wkdVFjfqEM0VgbJw4ul8RM9rVrFdgIbAi6 8l8g== X-Gm-Message-State: AOAM530kK0JzHWMJNQXDWW9a1ZB9VMxqN4IOg6eoXibd8Oq6YMcfwcmM hlkNgs8RxQPvVOSHl4mY0vko5/JrcGY= X-Google-Smtp-Source: ABdhPJyFrjNws+gTnIDIrYLjKBMt0i6sxgcxNQYsvFdpZSVm9ikJzN7UFLmq8nYqCAmGgkqF87ZBkQ== X-Received: by 2002:a17:902:223:b029:da:af1e:b112 with SMTP id 32-20020a1709020223b02900daaf1eb112mr21926512plc.83.1612258469253; Tue, 02 Feb 2021 01:34:29 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.34.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:34:25 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 8/9] stash show: teach --include-tracked and --only-untracked Date: Tue, 2 Feb 2021 01:33:25 -0800 Message-Id: X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Stash entries can be made with untracked files via `git stash push --include-untracked`. However, because the untracked files are stored in the third parent of the stash entry and not the stash entry itself, running `git stash show` does not include the untracked files as part of the diff. Teach stash the --include-tracked option, which also displays the untracked files in a stash entry from the third parent (if it exists). Do this by just concatenating the diff of the third parent against an empty tree. One limitation of this is that it would be possible to manually craft a stash entry which would present duplicate entries in the diff by duplicating a file in the stash and in the third parent. This seems like an instance of "Doctor, it hurts when I do this! So don't do that!" so this can be written off. Also, teach stash the --only-untracked option which only shows the untracked files of a stash entry. This is similar to `git show stash^3` but it is nice to provide a convenient abstraction for it so that users do not have to think about the underlying implementation. Signed-off-by: Denton Liu --- Documentation/git-stash.txt | 16 +++-- builtin/stash.c | 20 +++++- contrib/completion/git-completion.bash | 2 +- t/t3905-stash-include-untracked.sh | 84 ++++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 6 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 46ee37b35a..a9956e5c51 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -83,7 +83,7 @@ stash@{1}: On master: 9cc0589... Add git-stash The command takes options applicable to the 'git log' command to control what is shown and how. See linkgit:git-log[1]. -show [] []:: +show [-u|--include-untracked|--only-untracked] [] []:: Show the changes recorded in the stash entry as a diff between the stashed contents and the commit back when the stash entry was first @@ -160,10 +160,18 @@ up with `git clean`. -u:: --include-untracked:: - This option is only valid for `push` and `save` commands. +--no-include-untracked:: + When used with the `push` and `save` commands, + all untracked files are also stashed and then cleaned up with + `git clean`. + -All untracked files are also stashed and then cleaned up with -`git clean`. +When used with the `show` command, show the untracked files in the stash +entry as part of the diff. + +--only-untracked:: + This option is only valid for the `show` command. ++ +Show only the untracked files in the stash entry as part of the diff. --index:: This option is only valid for `pop` and `apply` commands. diff --git a/builtin/stash.c b/builtin/stash.c index 6f2b58f6ab..7a8770676b 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -795,7 +795,18 @@ static int show_stash(int argc, const char **argv, const char *prefix) struct rev_info rev; struct strvec stash_args = STRVEC_INIT; struct strvec revision_args = STRVEC_INIT; + enum { + UNTRACKED_NONE, + UNTRACKED_INCLUDE, + UNTRACKED_ONLY + } show_untracked = UNTRACKED_NONE; struct option options[] = { + OPT_SET_INT('u', "include-untracked", &show_untracked, + N_("include untracked files in the stash"), + UNTRACKED_INCLUDE), + OPT_SET_INT_F(0, "only-untracked", &show_untracked, + N_("only show untracked files in the stash"), + UNTRACKED_ONLY, PARSE_OPT_NONEG), OPT_END() }; @@ -803,6 +814,10 @@ static int show_stash(int argc, const char **argv, const char *prefix) git_config(git_diff_ui_config, NULL); init_revisions(&rev, prefix); + argc = parse_options(argc, argv, prefix, options, git_stash_show_usage, + PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN | + PARSE_OPT_KEEP_DASHDASH); + strvec_push(&revision_args, argv[0]); for (i = 1; i < argc; i++) { if (argv[i][0] != '-') @@ -845,7 +860,10 @@ static int show_stash(int argc, const char **argv, const char *prefix) rev.diffopt.flags.recursive = 1; setup_diff_pager(&rev.diffopt); - diff_tree_oid(&info.b_commit, &info.w_commit, "", &rev.diffopt); + if (show_untracked != UNTRACKED_ONLY) + diff_tree_oid(&info.b_commit, &info.w_commit, "", &rev.diffopt); + if (show_untracked != UNTRACKED_NONE && info.has_u) + diff_root_tree_oid(&info.u_tree, "", &rev.diffopt); log_tree_diff_flush(&rev); free_stash_info(&info); diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 4b1f4264a6..64ef6ffa21 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3051,7 +3051,7 @@ _git_stash () __gitcomp "--name-status --oneline --patch-with-stat" ;; show,--*) - __gitcomp "$__git_diff_common_options" + __gitcomp "--include-untracked --only-untracked $__git_diff_common_options" ;; branch,--*) ;; diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index b26a97aef4..978bc97baf 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -297,4 +297,88 @@ test_expect_success 'stash -u with globs' ' test_path_is_missing untracked.txt ' +test_expect_success 'stash show --include-untracked shows untracked files' ' + git reset --hard && + git clean -xf && + >untracked && + >tracked && + git add tracked && + git stash -u && + + cat >expect <<-EOF && + tracked | 0 + untracked | 0 + 2 files changed, 0 insertions(+), 0 deletions(-) + EOF + git stash show --include-untracked >actual && + test_cmp expect actual && + git stash show -u >actual && + test_cmp expect actual && + git stash show --no-include-untracked --include-untracked >actual && + test_cmp expect actual && + git stash show --only-untracked --include-untracked >actual && + test_cmp expect actual && + + cat >expect <<-EOF && + diff --git a/tracked b/tracked + new file mode 100644 + index 0000000..e69de29 + diff --git a/untracked b/untracked + new file mode 100644 + index 0000000..e69de29 + EOF + git stash show -p --include-untracked >actual && + test_cmp expect actual && + git stash show --include-untracked -p >actual && + test_cmp expect actual +' + +test_expect_success 'stash show --only-untracked only shows untracked files' ' + git reset --hard && + git clean -xf && + >untracked && + >tracked && + git add tracked && + git stash -u && + + cat >expect <<-EOF && + untracked | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + EOF + git stash show --only-untracked >actual && + test_cmp expect actual && + git stash show --no-include-untracked --only-untracked >actual && + test_cmp expect actual && + git stash show --include-untracked --only-untracked >actual && + test_cmp expect actual && + + cat >expect <<-EOF && + diff --git a/untracked b/untracked + new file mode 100644 + index 0000000..e69de29 + EOF + git stash show -p --only-untracked >actual && + test_cmp expect actual && + git stash show --only-untracked -p >actual && + test_cmp expect actual +' + +test_expect_success 'stash show --no-include-untracked cancels --{include,show}-untracked' ' + git reset --hard && + git clean -xf && + >untracked && + >tracked && + git add tracked && + git stash -u && + + cat >expect <<-EOF && + tracked | 0 + 1 file changed, 0 insertions(+), 0 deletions(-) + EOF + git stash show --only-untracked --no-include-untracked >actual && + test_cmp expect actual && + git stash show --include-untracked --no-include-untracked >actual && + test_cmp expect actual +' + test_done From patchwork Tue Feb 2 09:33:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12061229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80C52C433E0 for ; Tue, 2 Feb 2021 09:39:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BB0664EDC for ; Tue, 2 Feb 2021 09:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbhBBJi6 (ORCPT ); Tue, 2 Feb 2021 04:38:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhBBJgu (ORCPT ); Tue, 2 Feb 2021 04:36:50 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9831BC0613ED for ; Tue, 2 Feb 2021 01:34:35 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id w14so13961455pfi.2 for ; Tue, 02 Feb 2021 01:34:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kqwdb8r6AYGlkBimMW+sv/XZ+sfF5CnrUqX2tByesZw=; b=Z8kDvKMCBIdzsZGyBdtSeLe/zri1ZD2MtpwNktdqDEILJyrkklxZSEHMq+A4Iy91YK dr2IJrGcsIhHWfCiUYCQf2rHFstWcUIW0oxnWOOXGBUWW5FzqxadZYOX80lVRbopjsAt aRBORfrt4EyYKITI7NOn3a/9HRZA/6TCNN4UQ2JphWs8jrvJE0DsUblE2HjNvQZdl8MW w+JEpukuqgTn99TjSzTeeqG1lCz+VjZrA3ybMjPaCUhejB+MG9OLtpcmhhIg9eTBaBjF LXwf/CmOAqHvYq0DRIft26sSz3hit6AFKl9kmhS8wyE38GFftXmVXrvhKWTSY14XBhUh MhRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kqwdb8r6AYGlkBimMW+sv/XZ+sfF5CnrUqX2tByesZw=; b=IMJGtmIO8URZ4E5BI9cPP78yo8lr9CSocABOSGnHbe9rysUZyrN17iQyM3p9NxEGjh 5MTrYXialpAkDVvDzp/MVIa2MlRqRscPhdwSDSs3whUyPqQ81j+4+A6NyYLPmbhdvZU6 0VmKfuz7BcqxIf6JieXBohOHBMzzimU8Nv1srAt6ZX+2Bzce9LESR2L5XT/WmJN38Avm 2w8smOpMOxT601DVyE673Ja804t7JTJDaNW4roxFYVgCor54zQJfFmEDhtkvAxslxCoG oJQ1Cl+1T7CZtscNsBb4F4nd2Zc2SAcM4bxuIJ7ukZN8GOOT3R7y9S7Igu41QkdTuGTQ whGw== X-Gm-Message-State: AOAM533MDO8K/VUyoUUgF8Gf+LmRk9m9M46KRnXjZ+in45xdXlP9+sUx 6naK1Xh0JyXeqJVnzD1pJOfQQ3+7CqY= X-Google-Smtp-Source: ABdhPJyxT6oJII7D3c+kDv4x+D50DW8QbwVIVsdEqrNGrCbqPNwtYhiEEza8NYqMGrQb42JL3+9gJg== X-Received: by 2002:a05:6a00:15d2:b029:1b7:30c1:8495 with SMTP id o18-20020a056a0015d2b02901b730c18495mr20100355pfu.32.1612258474904; Tue, 02 Feb 2021 01:34:34 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id e21sm20584462pgv.74.2021.02.02.01.34.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 01:34:30 -0800 (PST) From: Denton Liu To: Git Mailing List Subject: [PATCH 9/9] stash show: learn stash.showIncludeUntracked Date: Tue, 2 Feb 2021 01:33:26 -0800 Message-Id: <2c5d5d9dd47f1c6ba49312204d155d404d5fdc4f.1612258145.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- Documentation/config/stash.txt | 5 +++++ Documentation/git-stash.txt | 4 ++-- builtin/stash.c | 8 ++++++++ t/t3905-stash-include-untracked.sh | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Documentation/config/stash.txt b/Documentation/config/stash.txt index 00eb35434e..413f907cba 100644 --- a/Documentation/config/stash.txt +++ b/Documentation/config/stash.txt @@ -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. diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index a9956e5c51..e18c1deb97 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -91,8 +91,8 @@ show [-u|--include-untracked|--only-untracked] [] []:: 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] []:: diff --git a/builtin/stash.c b/builtin/stash.c index 7a8770676b..784fb518be 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -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; @@ -842,6 +847,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; diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh index 978bc97baf..8bcd4c5ca8 100755 --- a/t/t3905-stash-include-untracked.sh +++ b/t/t3905-stash-include-untracked.sh @@ -318,6 +318,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