From patchwork Tue Feb 9 07:28:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077289 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.8 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 E2346C433E0 for ; Tue, 9 Feb 2021 07:30:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D51A64DED for ; Tue, 9 Feb 2021 07:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbhBIHaB (ORCPT ); Tue, 9 Feb 2021 02:30:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230130AbhBIH3x (ORCPT ); Tue, 9 Feb 2021 02:29:53 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72249C061788 for ; Mon, 8 Feb 2021 23:29:13 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id fa16so1071451pjb.1 for ; Mon, 08 Feb 2021 23:29:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+HKMN71wmGmq9slNxE+amiaOwcu+ls8b82iXnJPWlUg=; b=TLeO/NdpW/UA6ppuf/gLDcVZAuc6bnViYP6rQvg8n4pC7g6rxo+8I6Oq1yI1ylX7Fv V19MT0irm3MjPrWRV9YjIpzFWpx2d1mh1mY+dNTfLdqoJT8vp/wFcaT5o+LDeusr90et ATCm4o6QKhrVaxaX9sN547fgwems/bXzoHHSuXyCj2GIvX92BEnL6I+OI+/hmY6fW42V fsiSKjOYo2UlHIqdhmbhRLqpBUcVKrymQ8X5B0OT079uaVm54Elxy2FspxLATyF4aqMa QSIgv5evXAjT+oJudsNM9MZR1yCFFa4Bn6OiGLCkLejAyYDIqWEuvG44syDwKn5jb2AG 25dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+HKMN71wmGmq9slNxE+amiaOwcu+ls8b82iXnJPWlUg=; b=OJn7S57m4TptzbQkeACUxBYzlBRdULkqopkGnor8pN0OxIFM8Mb+oVkkYvEdMWeUTH IOQyRxKY0leFL65shP9j+cwZUwi1rOkS7EPbFHrWBKQamJQwgaSag1jM5YcQEOvBzm7P 0/GowrCwfdIAjZYYJ8F6o2FL/M25uLWBE2HF6ZkbRrcZIVPedBUIaeAOO+dCxx7ftGxK WWCpwSiFckWVhmo5ZhHhRH9M+FD9+VR+SCiXAm+T/QD5VRZ0d0GEkBt7J+TI7K5keW60 CJRHadfjpaAGGliBgO67QzezslHZLGLc9S+m2ghm5q/KzHoDfv8FYQv5HO8bK05QkvV2 iy4A== X-Gm-Message-State: AOAM530dH3Mz1+iCYJGK2Ph3OHPu33r+hnrXCbkaV0O3ebVITGyp8L2X JdSIIppLKpd3xejg1i/jYUdYIl9nnfU= X-Google-Smtp-Source: ABdhPJyZ5uu0tflfNq9e4R279+A2F/PBiAWqqAtywaacdpYc2ifdxP58QYXYRXM7oa7J48Wejansiw== X-Received: by 2002:a17:90a:5ae6:: with SMTP id n93mr2868438pji.146.1612855752837; Mon, 08 Feb 2021 23:29:12 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:12 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 1/9] git-stash.txt: be explicit about subcommand options Date: Mon, 8 Feb 2021 23:28:47 -0800 Message-Id: <5697f14f1c67abbb529b450c8f2a02f2bc59963f.1612855690.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..04e55eb826 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 9 07:28:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077291 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 50CF5C433DB for ; Tue, 9 Feb 2021 07:30:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FF0A64EB8 for ; Tue, 9 Feb 2021 07:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbhBIHaF (ORCPT ); Tue, 9 Feb 2021 02:30:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbhBIH3y (ORCPT ); Tue, 9 Feb 2021 02:29:54 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F698C06178A for ; Mon, 8 Feb 2021 23:29:14 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id g3so9270319plp.2 for ; Mon, 08 Feb 2021 23:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BU0Hi7RAV2KElXGBIE71hMJoCEINqunWPtqs8tMqIso=; b=Ce6aISntrpWryYOiRG8OCTkQwrV4okWE1faZOVTg86jpb931kbbnRwSioGlqoOC4bh d0PZphIStg1CtOgxZcnArKzaZvfQSl0ZbP/IGelH5NIZN/YzxS3Q7slgwskC1yODLft2 zIU6LKNKS7VQh5YDv5bSZlVN9GL7P2oxdc7U+bbKF5EmPXa8LtXiJMov51oSP9+9o0kF HjVgl7nGj8QnfjQnFs61mcJAfM6VoYJG7q7Y9FWcE0JX3wM2J57XxUjrODCWqRC/p9sF og4KTCnhL276kJfG+nkAvB0T7O5jEowCPsewpG9/mPbgC7pEH+/KsHpb+u/DpsNeIRGN O7Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BU0Hi7RAV2KElXGBIE71hMJoCEINqunWPtqs8tMqIso=; b=cgQ4Q3ZQGXEca1AjtKxr1rnOZTYsntky96eHe9+OO+iTcNZJSH8Rv32daQs4BTSNK+ 3fVq3mnFejT7psNqRJt0YS/RgEVT2vxxQKT1XnI81oqf4wBMR8u5SDUvV2ueMXh7IU1e saWgphrQ9bQ5qEUS56YXaxHiPU/hR4WLTF4YcIO97LQHYrcaNLz8U1D5kD0xzuJPi0dY zg/FlAkG7mDZVDWwhjzmzy11MRcKnYU1GJFOx5GG8k5+cRR+X0c35cuuDgp+h7/zW60F cmRRVkuGGGofzDRj0iOHnJ/YKtvCgkk0EFPFyLA7TuQzqNvkK4HfQG9oXiEc5M2oOn4Z 0XvA== X-Gm-Message-State: AOAM5330cubJVJyCMF764alKAoDKYRRPK/c48vGI0vq/n5oQiAMRrNoS Z8h/TKCvmDghJcbidDn91LYFJ2Y/61g= X-Google-Smtp-Source: ABdhPJw6qLKi+CFay/qMGjalXLQxpfl48f41bbTBSOqqhVR6Kyt3Ya9eJasYIf1uIXM/HPiO9i0gyw== X-Received: by 2002:a17:90a:b292:: with SMTP id c18mr2786970pjr.134.1612855753779; Mon, 08 Feb 2021 23:29:13 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:13 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 2/9] t3905: remove spaces after redirect operators Date: Mon, 8 Feb 2021 23:28:48 -0800 Message-Id: <45ed17bfe2dad4702904a07a4a77a8d219df8379.1612855690.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 9 07:28:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077293 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 4C9B6C433DB for ; Tue, 9 Feb 2021 07:30:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17A1564EB8 for ; Tue, 9 Feb 2021 07:30:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbhBIHaZ (ORCPT ); Tue, 9 Feb 2021 02:30:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhBIH3z (ORCPT ); Tue, 9 Feb 2021 02:29:55 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1764C06178B for ; Mon, 8 Feb 2021 23:29:15 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id nm1so1064924pjb.3 for ; Mon, 08 Feb 2021 23:29:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fa4WF191om12EiQOY/vS3OYpTRVsVVT2Ao7zH3DjI8U=; b=SUGbEO0LvwwPrtXkJZRLXHs1DF/8wIL35319m5QYgvOvqIh1wx0oD5aG2q0EXsfJeJ Z1+6/rEOnoRz8ZNI3AaPlph12vip9BRurqhheBwRlpEn3LIdh6x7OLFC7yhbHVsr7TfO GEHGc8IPB0DUSZkLOVcOGs0+NhXQMScos16tVwjIPuTBiNQc26/woTtAVpILqpL/OYUb Rx4AE8P7oS+6ryKzes8SZxC/v8f4fhHPrOH5qMZW7DCy7+7CwrFgnsTqB13HL1Qimcba F7NCW0zErVB7nfWoBaFJy+TGh6BKWg5IelIYJ2yvyVi81RyYFDBaubanPEWebJfOhRGU t2Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fa4WF191om12EiQOY/vS3OYpTRVsVVT2Ao7zH3DjI8U=; b=QoIWF8zFMjJ6YlIcrZjLVRUinu/ROq/gIlhN5ZEVtRrMV/u1d7sKo4I3ZcGO+F5PxH P7iNXU/DNLBaOFsK2ojcSjKdL/kiyOgNStdegMimilrDXQWdM74W7XoBTbYQdTDpkyJa LXy9hM6+eUjlWYh3jbuu0GaDeCQA+7IpnQksKrEkMjNG9YShjNfSKJNdF5u0NQ++ImWr ADmNh10CV1PwvS79a0reDU/+oDcdW1cvReocusmi5AROLcZam3xgpKZhR7tY1BAW0OPy 9QmKIHdVjyTf6ISNf7WVDXwtVHk0JIS0N/YPsik/zv4c8Lxw1nPi6YmFjFlJb/vFjQxM J92A== X-Gm-Message-State: AOAM530kRmgCdvv5Zdn+tZkYx19JyZWkqnVcv6LR1ETuxmIqzUTdy87T k4f+vxsYglnFqu3yq59JGsp2HWMaMtw= X-Google-Smtp-Source: ABdhPJzc4syi3CZ0vWZ4tEq9XvmcMol3GMA6zkByPIiip/WzQL6kYdz+G0jOGjMenE/exLEu1ousAg== X-Received: by 2002:a17:90a:4546:: with SMTP id r6mr2767610pjm.213.1612855755042; Mon, 08 Feb 2021 23:29:15 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:14 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 3/9] t3905: move all commands into test cases Date: Mon, 8 Feb 2021 23:28:49 -0800 Message-Id: <5bda09b4bd55168f6e69f20026d0112b1a43f45f.1612855690.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 9 07:28:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077295 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 B68A4C433E0 for ; Tue, 9 Feb 2021 07:30:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AE7664EB8 for ; Tue, 9 Feb 2021 07:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbhBIHa1 (ORCPT ); Tue, 9 Feb 2021 02:30:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbhBIH35 (ORCPT ); Tue, 9 Feb 2021 02:29:57 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F487C06178C for ; Mon, 8 Feb 2021 23:29:16 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id gx20so1140149pjb.1 for ; Mon, 08 Feb 2021 23:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B5MZdMNbM5AFSKMClKB4E4pNrhzrspPMYiL+ukzcmts=; b=oDpDOcxj/d0Hs7qkveYH7TRddBYKkzOfRtzcutlQPC9LQ2cWhCugzFl7c5ko2bZJfY AXedsK/UXg8qkb6Cahnrz8fEH0mz+WZ5x5FXRkSvZF+26OEaDkfJFG1adJL0DVD9W1CG rN/SMBEBChzvNw4yTmRrAmAJoF0d2ZXVu7f+qfhSil5I7MQNSaFyjtcGJkLsUNY8rnRo n1AAqz3NyBV5HsM33LlRE8EShyW83VGE/vhwM+Bd6h0tFxmkAxROFLLJvfyOYhIdgZ11 seCODSUKvb1aRSpMKpiIFz1n7wiSeW8CpZfVb+AcrBSRgtZrxuHBCQCR7rYoQegH5ltm Kw3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B5MZdMNbM5AFSKMClKB4E4pNrhzrspPMYiL+ukzcmts=; b=jaWb1SUHLs0fokC09hCXZ/Y1jIlkm4OA1B1mt6YUD//l4GqwyPnFxcyPBr3l+xb0RU U/EZJZppCoX5jHwvvz9mfbLyV+YL5yeVxNYwlUTnYAKCXaM8cZmE2389IgId02eMs6oh kMHxZ7BSSrx4DMghsuzfgo2/EHJBke7qs3GCnqnBwaxFrOeFEuR4B7Q+rjrfJOZbFVzS FcTF1tvdOySXGQqbBjmi8AFPAhdqZ7V087DclJkYlyjBg3Bsfkcta6QoC4Efvee2/wWr g8KmGs0LjHqo68TUfcEaPkMEmPactkeK8ZzNL3JfW6VKf4bZx4eTYOnSf+856esQE/kL DSrQ== X-Gm-Message-State: AOAM532kN1/yX+/1awfu9716q0somLHlB3Xn/fd2ijOaiK14ZSPwWvQu qJzRubjkL1OjP6hO/BaRfuFb07PcKT4= X-Google-Smtp-Source: ABdhPJyQzGr6Rj3oqXdsnDJLHMotdaBfBLIkTINMjYeVYjmUfG0gQflgbTnqGY+S/Fa+XQolmn08JQ== X-Received: by 2002:a17:90a:7187:: with SMTP id i7mr2835685pjk.216.1612855755945; Mon, 08 Feb 2021 23:29:15 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:15 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 4/9] t3905: remove nested git in command substitution Date: Mon, 8 Feb 2021 23:28:50 -0800 Message-Id: <57c21e2461eea8a37456d211f38fb668278cb2ed.1612855690.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 9 07:28:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077297 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 5A96EC433DB for ; Tue, 9 Feb 2021 07:31:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A43B64EB8 for ; Tue, 9 Feb 2021 07:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbhBIHar (ORCPT ); Tue, 9 Feb 2021 02:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbhBIHae (ORCPT ); Tue, 9 Feb 2021 02:30:34 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8AA0C061793 for ; Mon, 8 Feb 2021 23:29:17 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id e9so9263367plh.3 for ; Mon, 08 Feb 2021 23:29:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gNSRZvmx9+OCMyIXehfEVMJ0vxwEygopOVzVXTd4+OE=; b=VzwERgGIZYSylXTltmjnS5PIAiB/cM+urjkF8Mm6jPs9WvQU9+wLhRpNlGxoB5jc6Q H0DjuRIYawB0qbuJlICDPY3BPqEZiJRbkTgJmabqs56HDhz0QQoUWL3g+tLRV5ZM9oh5 y7sKlbIucd/5E+Y1My/gqaAF9Etp5fkkN/ttnWTWo2pZVrGsOGQC0DoYXhiYvGEy3YMn YcFgio75V8NFuBJgCC0nixyOu6tZFqd0eKaV8+anpGfdlm7GuXdV1ZhC5O+4ldpqlbeS XcFUV8vyam/ZBKROL4ZnA/7wzWaQ57cU+CcHevGPVK8FmNj0t9U8yvT3RJvsii4xdy8Z I/mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gNSRZvmx9+OCMyIXehfEVMJ0vxwEygopOVzVXTd4+OE=; b=Xz3WhJIRI2LBIaOk4MiySYJj5inAvl/5J1mpcVTjm+fr6Hk5ubas7w/W1x1uG5m/L6 i4+0JqrxeSTFdXRx+Ej5GRSAHYfYYSkHRrfrzRqqYpJcemwV0jKGdIaaF8RHmmALsWHW PgDhTFrM2LCLv8vTquQKQUeNl7KeRnK9NTCt6ojn2xt2Ahxm+MsQ/epDeb2NGItAtypP tYybzmxNOk+ZNYUtfeMfbrJbs0PiwKO+DgAxHug0I16zCHn8qxMa+Yswh/boVffdFW5C RlD3kz7ioIahtFCSNZ/gCsTdQcgyPL6kyn0+MdWXU+dtiQ7fAT2nJWCBvGUR4Nu4S+If CjWw== X-Gm-Message-State: AOAM530KT1GmgoQiTmY0PMbvtOK1gn12Qt/nmT6WEX/kcd30UQ5Av2l2 P0K4Fiyu9Vrgbki0UUGfUacFYZscTtU= X-Google-Smtp-Source: ABdhPJwIzSGRVh0eU4MNIznOm6FAIp+T9MZBbqpHJ7O+rzA2gsiNckqE/jIUg4IIZSNCOQmARZS8WQ== X-Received: by 2002:a17:90a:9414:: with SMTP id r20mr2875839pjo.158.1612855756934; Mon, 08 Feb 2021 23:29:16 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:16 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 5/9] t3905: replace test -s with test_file_not_empty Date: Mon, 8 Feb 2021 23:28:51 -0800 Message-Id: <2530883b6ca664d22ec54c4dd4fd3137c52bcd6c.1612855690.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 9 07:28:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077299 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 9FCDDC433E0 for ; Tue, 9 Feb 2021 07:31:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 652A164EBD for ; Tue, 9 Feb 2021 07:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbhBIHbB (ORCPT ); Tue, 9 Feb 2021 02:31:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbhBIHae (ORCPT ); Tue, 9 Feb 2021 02:30:34 -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 6BCFAC061794 for ; Mon, 8 Feb 2021 23:29:18 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id j11so9240149plt.11 for ; Mon, 08 Feb 2021 23:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AKVyUTQ0PTfwwq76gRTHowmfpb1YnfKrY/iiF8w8GJ8=; b=u2GWuPcc2N9TI6iQAkS8uVR5uaPNta5x2M3jtTt2FGovjUgPVevUMYEZrWk1Wtw7hr 9tFdthLHBa7MFLv0ho3bHBNGm0u+2OUCM6FxrHGe/fOpuRbp317D4ZmRbIVPx4YXNvlI miXRRn/9YNnv1xGoP37YSULvsEu6mZGIo7Z7DsdbeXCaJXWWvYJAsAF5M2VGvcTvCqR3 ae2tDg9PVO27Pmmm1jviGWJVBKi6XrjZpJCWbPgHOsMk5XJiAlDitiro6MpiHx8nWQu8 muQnPV/DfstYfZkUdgWQJgXU3TUEytQXvRjSuplwNcazeSqDpywkfPfGvdxnXM/agPGX H0Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AKVyUTQ0PTfwwq76gRTHowmfpb1YnfKrY/iiF8w8GJ8=; b=k1snr4hOWIkszzdcE7vbanhMhQ45dQ9LCP8AMbfXMAnStQEAAtMVkYnHBldwiIIDFG Q468H19JTvyC71kcxNYvMfHQd2F5kn6h4uLJ5iQjlfig6eDPhDIprOIT0/i87J3uX5aT rlwivz1D8rYnMd9zBNTGM5KX8X+UThAo1B5WJLsYctHMsKgpIr0z9X3pNlsLnvdPxBcz lW1X4PM8dsr2DpRQK8y3Y5SGiaWliMIhCfpWOYUwLrNMKU2SxPKu4tq7RUW857+u3ax2 h4zX6D0hTCWmABaDYqrilJkGKwudh9AbrnfdE8R9q4OtUjWr0TZ83K3TTD+0X4Uuwrwa YrSQ== X-Gm-Message-State: AOAM532BznKApUPWpJYF10dsujcJaQBPxAv6RFAbf+eGnYEwzU06SA5o TsCiV7+2xyxGrh2oY086lvAT+A0ZxG0= X-Google-Smtp-Source: ABdhPJymEifGYzXapjhqwpfTegG6Vm1gXqE7uVs0sv9nNHjdpa3qVo4kbHC4OHJmjocF1fXI4SOypA== X-Received: by 2002:a17:90a:3fcf:: with SMTP id u15mr2862400pjm.127.1612855757845; Mon, 08 Feb 2021 23:29:17 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:17 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 6/9] t3905: use test_cmp() to check file contents Date: Mon, 8 Feb 2021 23:28:52 -0800 Message-Id: <80194bcfa5bc250e64a0d197790dd8eac93d395d.1612855690.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 9 07:28:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077303 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.8 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 914BBC433DB for ; Tue, 9 Feb 2021 07:31:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4ADEA64EBD for ; Tue, 9 Feb 2021 07:31:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbhBIHbu (ORCPT ); Tue, 9 Feb 2021 02:31:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230395AbhBIHag (ORCPT ); Tue, 9 Feb 2021 02:30:36 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEBC3C061797 for ; Mon, 8 Feb 2021 23:29:19 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id e9so1140605pjj.0 for ; Mon, 08 Feb 2021 23:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BjOmTy4dNmgRmOu+FOU2Diqsqn48K0alvnBzauFVVJY=; b=groUTex3h6hiJwNy1I79+y8Qx0DPPGuOvzHkLDjjnPkCvwzfTltaUqu6InwRTzXpUa bwRs5nCCky0LYeGjOfccil0prsmxgXJ9l0QtO3N9JsIN3rj2G0z4upGYD7SUYUbmQn9V pAWtlklihUiXKXPgdU8gjGpsyeEERLzJR7elk0IPkDkjPFuNQZN3VE283vwKhe1eCeDV 82kA2VoJVsG7UWbs3pEry4lxp9qB6UP5+Ont2X11kS2il/TXet8qMK6D5qVaWvecZ+mA aVA+rg9kptkC2yonBgnAY6p3/3khU95M1nJp66ItZgUXufiD1U9eDUKZJPznDa0EwdX6 x6dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BjOmTy4dNmgRmOu+FOU2Diqsqn48K0alvnBzauFVVJY=; b=REV/P+ohkd/ee7j1UEyS1CHh1J09o2944foVle0AgcoNhFLhE55liJTcdJXGvU19AL uGJmNjlBsgUp2sRUR1gO3X+g3DzdImHWXoxfmGo9/laAulDkCSTMBVCkLLZhpsZCx0t7 frJhqjBYpXQZvdu86OdmTj/YZpVL9JMdbpi1AXe0+ZUM004K6pPiFgxj1YYvDSVL9teX 753BRr6OwL195fUjRIaoD26JU84RXHUhtXjIJva105H8vOawAsWlP3PsYBuAmBDuAtBT Tlh6HvNVGK1alMLS73/q7M39UXB+xwFn04CCnNsOnw3ycwfXUguHomxKvKzwO0FWS0K7 RYHw== X-Gm-Message-State: AOAM530QiIEpyvWf++AG1xnNgk3mR8eb4xtbTt3oERPRImZCi+r+9FVV 9VsXrZXdia24io7R1bQqShzMqHunLjA= X-Google-Smtp-Source: ABdhPJyVIwA4+nuAjbWdTHpV6JN0gCqOUb5O7+xAi7Hkh14h8S3ZYJHWEpqAH+sonr1kZJAZpu0b2A== X-Received: by 2002:a17:90b:4a09:: with SMTP id kk9mr2937471pjb.15.1612855758937; Mon, 08 Feb 2021 23:29:18 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:18 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 7/9] stash: declare ref_stash as an array Date: Mon, 8 Feb 2021 23:28:53 -0800 Message-Id: <2f03d38b36665fe258444ce58f1e138be7b97e13.1612855690.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 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 9 07:28:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077301 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 B6727C433DB for ; Tue, 9 Feb 2021 07:31:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D7DE64EBE for ; Tue, 9 Feb 2021 07:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbhBIHbk (ORCPT ); Tue, 9 Feb 2021 02:31:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbhBIHag (ORCPT ); Tue, 9 Feb 2021 02:30:36 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19442C0617A7 for ; Mon, 8 Feb 2021 23:29:21 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d13so9269226plg.0 for ; Mon, 08 Feb 2021 23:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=REnViNvTDqX6po4FJ2W8C049KBED9Iv0K3XEnhuO300=; b=FK8nyThILkC8GWW8wXIlmt/yJrGy5dehxINXOFaQY2HRP/c41WHbT6MYY5x0CNpV+C /xNo68p0evR5QPh17wl1gYKqEsQqFSYNyY8+mGEJJHUlctqieW5evBy+WNdRkHXsv0+Y 8EVCwkC8N7trGHUhkGukp9SrgatoaBQJmVX2HtmtnNAIV5Xve5ueBb7yq+Vy/bOFFYB4 ukeeJAmfWSSVkCS2Hlo9jNEXTuHSySfqA5/QEOnGVDi3mqSk4fKTYxvwDnFdCTh5KU4w lOQWFq+o2q1MSUsM2Nay9Vu+DRjhiUmy4FcZXelvLTXlju6dw/UMVFxg9b6G5C2Sq+g2 nXuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=REnViNvTDqX6po4FJ2W8C049KBED9Iv0K3XEnhuO300=; b=f/EQ7nuM2sTr87ODSOM94Yp9ejvLSxEiqmRrGxDoPxj/zHFb6W14xR3w2eoskcNcgC UgiViHo3FDO7sfxVdxq1O+LW8+nRSS5ImqmEK7jspyLajk4PluNtLJO6l4u21cZXZbQh dIizIO0smiYOJqy5vNDnCJuPGum9IrRYeVVAGAfS8IUpc/L4wmTLoT0QnRsM+Owzga+b 3JQS5TJKuNv+UOIeofgo+hEoOxnCCkSi/Sgfae6Qy1ubLf1UpWRU3tSW8Mzl+FMWnUgK wFiOqhdltWuAsI1LwlDX491TbkY1nIh7UpSVFEE24j9ysizvZLCRvCuLF4jz7bE9x2FF rgqQ== X-Gm-Message-State: AOAM532kWF4pMYR2nY4jjErjdj8mcyGgcu3Q+6LwgWG3BfD4acqKdJzW xlklD1Qzeo5hG+GKDteO3/os/lQPlEE= X-Google-Smtp-Source: ABdhPJx3n+lVRr/RpgT5m7dmEPV4B6G0IWreR+lTkU2d3xGbcsjnaynJeDvZ/aNohNU/c1GVGdd+jg== X-Received: by 2002:a17:902:b190:b029:df:fff2:c345 with SMTP id s16-20020a170902b190b02900dffff2c345mr19471772plr.17.1612855760188; Mon, 08 Feb 2021 23:29:20 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:19 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 8/9] stash show: teach --include-untracked and --only-untracked Date: Mon, 8 Feb 2021 23:28:54 -0800 Message-Id: <88d47912595b5650fbca595a6dd5b7b943a93301.1612855690.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 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-untracked option, which also displays the untracked files in a stash entry from the third parent (if it exists). Do this via something like GIT_INDEX_FILE=... git read-tree stash stash^3 and diffing the resulting tree object against the stash base. One improvement that this could use for the future is performing the action without writing anything to disk as one would expect this to be a read-only operation. This can be fixed in the future, however. Another limitation of this is that it would be possible to manually craft a stash entry where duplicate untracked files in the stash entry will mask tracked files. 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 | 77 ++++++++++++++++++++++- contrib/completion/git-completion.bash | 2 +- t/t3905-stash-include-untracked.sh | 84 ++++++++++++++++++++++++++ 4 files changed, 173 insertions(+), 6 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 04e55eb826..9d4b9f0b5c 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..f7220fad56 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -787,6 +787,47 @@ static int git_stash_config(const char *var, const char *value, void *cb) return git_diff_basic_config(var, value, cb); } +static int merge_track_untracked(struct object_id *result, const struct stash_info *info) +{ + int ret = 0; + struct index_state istate = { NULL }; + struct child_process cp_read_tree = CHILD_PROCESS_INIT; + + if (!info->has_u) { + oidcpy(result, &info->w_commit); + return 0; + } + + /* + * TODO: is there a way of doing this all in-memory without writing + * anything to disk? + */ + remove_path(stash_index_path.buf); + + cp_read_tree.git_cmd = 1; + strvec_push(&cp_read_tree.args, "read-tree"); + strvec_push(&cp_read_tree.args, oid_to_hex(&info->w_commit)); + strvec_push(&cp_read_tree.args, oid_to_hex(&info->u_tree)); + strvec_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s", + stash_index_path.buf); + + if (run_command(&cp_read_tree)) { + ret = -1; + goto done; + } + + if (write_index_as_tree(result, &istate, stash_index_path.buf, 0, + NULL)) { + ret = -1; + goto done; + } + +done: + discard_index(&istate); + remove_path(stash_index_path.buf); + return ret; +} + static int show_stash(int argc, const char **argv, const char *prefix) { int i; @@ -795,7 +836,21 @@ 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; + struct object_id *before = NULL; + struct object_id *after = NULL; + struct object_id untracked_merged_tree; + 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 +858,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 +904,23 @@ 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); + switch (show_untracked) { + case UNTRACKED_NONE: + before = &info.b_commit; + after = &info.w_commit; + break; + case UNTRACKED_ONLY: + before = NULL; + after = &info.u_tree; + break; + case UNTRACKED_INCLUDE: + if (merge_track_untracked(&untracked_merged_tree, &info) < 0) + die(_("unable merge stash index with untracked files index")); + before = &info.b_commit; + after = &untracked_merged_tree; + break; + } + diff_tree_oid(before, after, "", &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 9 07:28:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 12077305 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 3FA67C433DB for ; Tue, 9 Feb 2021 07:32:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E42BF64EB8 for ; Tue, 9 Feb 2021 07:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230395AbhBIHcC (ORCPT ); Tue, 9 Feb 2021 02:32:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbhBIHaj (ORCPT ); Tue, 9 Feb 2021 02:30:39 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D55C3C0617A9 for ; Mon, 8 Feb 2021 23:29:21 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id g3so9270484plp.2 for ; Mon, 08 Feb 2021 23:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uLiWm6iDaHdSP2hf/1tCnjQIYyR9mFiDO5xDNC6TE7w=; b=MmBZ/rg+l2oO4TCyLVRXcjteY+20qRinMZhpoNiNHNlDg6uw9x61iLqppT19UMgq2x XUu+RHiKBlarPxxOQjxw/esQI0Nf/lmUD578uVrDwuTWG490tae5q+lOa8DB8X+eKrLb W5Jkq80Hqp0WEJtn9OQsjq2LbSBHcxc2VLCNhK4UjZm14lnMS9VMIjwMHrXk27mZTqes 4n7ur56OIitCoLYGis48S7T9b6fRUIbiR8AqPuBOF0oE0f11x1IZgqyoGegbqsLADHke UoIk9FycBo1J52YA2diefoc6pfhA2RxVEDZ2+WtSu0c5BK8aJ09K3HR89Xc2SOvVHe7T BbRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uLiWm6iDaHdSP2hf/1tCnjQIYyR9mFiDO5xDNC6TE7w=; b=bSzpty4+UdK0B+IEkYGxvJaPO1NCo8fNsfBODeRMCBqkK9WwrAGBYbPN5L7lEBUmnZ ccmR0ecBz6/gyhERtDtTIQ3z95DNULIwqao4e3tjbOmFhM2/QQq4sOzDpba+QloBKfHd uf72h+ddfmpZGVXHJvlM/+BMFFNt56QXtodn+uRZKWm4qk1K/52XFhDSwBPyiy6jkZjI Vv+BLu+ZQZ7paPxR5/ecZLjkLF5efeOqqDIzIz/obmvOxqCqlI5UPscVy9UeJ6W98KWg Z9Hrm2GsvbQ9I3JhC1RppYrD0tv0K5ol2jxsWAMsyeIOEJiggjeIoNI2KOWXj5XDcG/A EyCw== X-Gm-Message-State: AOAM532uxiI9pOFcRZLS3K+QNMFVrDcuN+0uieFlQJUGUgYLHS5LOUNm w8TEwlbtnQzq/TkCkaP2oDiT8e3icGc= X-Google-Smtp-Source: ABdhPJxjFkvqjGn7LjGrLC52JwUHnP8AdNKWxCrXJYH55ctW4v+p4jWaAWWqxYPeyv/QjypP4Qz1TQ== X-Received: by 2002:a17:902:7c98:b029:e1:8840:8abd with SMTP id y24-20020a1709027c98b02900e188408abdmr19430799pll.12.1612855761183; Mon, 08 Feb 2021 23:29:21 -0800 (PST) Received: from archbookpro.hsd1.ca.comcast.net ([2601:647:4201:c540::414c]) by smtp.gmail.com with ESMTPSA id w4sm5670443pfn.45.2021.02.08.23.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:29:20 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Junio C Hamano , Eric Sunshine Subject: [PATCH v2 9/9] stash show: learn stash.showIncludeUntracked Date: Mon, 8 Feb 2021 23:28:55 -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 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 9d4b9f0b5c..d004e9abdb 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 f7220fad56..53428e9e64 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; @@ -886,6 +891,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