From: Phillip Wood <phillip.wood123@gmail.com>
To: "Martin Ågren" <martin.agren@gmail.com>,
"Phillip Wood" <phillip.wood@dunelm.org.uk>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 1/2] stash: allow "git stash -p <pathspec>" to assume push again
Date: Fri, 6 Jun 2025 16:26:47 +0100 [thread overview]
Message-ID: <ffafdfe8-7754-4aa7-b2bc-ef85452f8afb@gmail.com> (raw)
In-Reply-To: <CAN0heSpGtLW8B-wtoMgW7gunMMeVTL1jhk8xN1LBbeeG4f1Fxw@mail.gmail.com>
Hi Martin
On 06/06/2025 12:31, Martin Ågren wrote:
> On Tue, 20 May 2025 at 11:27, Phillip Wood <phillip.wood123@gmail.com> wrote:
>>
>> +test_expect_success 'stash -p <pathspec> stash and restores the file' '
>> + cat file >expect-file &&
>> + echo changed-file >file &&
>> + echo changed-other-file >other-file &&
>> + echo a | git stash -p file &&
>> + test_cmp expect-file file &&
>> + echo changed-other-file >expect &&
>> + test_cmp expect other-file &&
>> + git stash pop &&
>> + test_cmp expect other-file &&
>> + echo changed-file >expect &&
>> + test_cmp expect file
>> +'
>
> This only exercises the patch machinery fairly trivially: all hunks are
> added. The implementation under test could miss `-p` completely and
> behave as `git stash push -- file` or some variant of it, and this test
> would continue to pass. (Confirmed by editing the test to not use `-p`
> and seeing it run successfully.)
>
> It might be worthwhile to set up some more elaborate scenario where you
> pick only some hunks, e.g., this (whitespace-damaged) diff:
I avoided doing this because we already have tests that check "git stash
push -p" works correctly when staging a selection of hunks and so I
didn't think it was worth the extra complexity here when I was only
interested it whether we parsed '-p' correctly. However you're right
that the test passes if we ignore '-p' completely so I agree it is worth
changing it. I'll send a re-roll.
Thanks for your thoughtful review
Phillip
>
> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> index d24559a328..3b28504126 100755
> --- a/t/t3903-stash.sh
> +++ b/t/t3903-stash.sh
> @@ -1178,16 +1178,19 @@ test_expect_success 'stash -- <pathspec>
> stashes and restores the file' '
> '
>
> test_expect_success 'stash -p <pathspec> stash and restores the file' '
> - cat file >expect-file &&
> - echo changed-file >file &&
> + test_write_lines b c >file &&
> + git commit -m "a few lines" -- file &&
> + test_write_lines a b c d >file &&
> + test_write_lines b c d >expect-file &&
> echo changed-other-file >other-file &&
> - echo a | git stash -p file &&
> + test_write_lines s y n | git stash -p file &&
> test_cmp expect-file file &&
> echo changed-other-file >expect &&
> test_cmp expect other-file &&
> + test_write_lines b c >file &&
> git stash pop &&
> test_cmp expect other-file &&
> - echo changed-file >expect &&
> + test_write_lines a b c >expect &&
> test_cmp expect file
> '
>
>
> Martin
next prev parent reply other threads:[~2025-06-06 15:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 14:58 [PATCH] stash: allow "git stash -p <pathspec>" to assume push again Phillip Wood
2025-05-16 19:10 ` Junio C Hamano
2025-05-20 9:21 ` Phillip Wood
2025-05-20 9:26 ` [PATCH v2 0/2] stash: fix and improve "git stash -p <pathspec>" Phillip Wood
2025-05-20 9:26 ` [PATCH v2 1/2] stash: allow "git stash -p <pathspec>" to assume push again Phillip Wood
2025-06-06 11:31 ` Martin Ågren
2025-06-06 15:26 ` Phillip Wood [this message]
2025-05-20 9:27 ` [PATCH v2 2/2] stash: allow "git stash [<options>] --patch <pathspec>" to assume push Phillip Wood
2025-06-06 11:32 ` Martin Ågren
2025-05-21 13:04 ` [PATCH v2 0/2] stash: fix and improve "git stash -p <pathspec>" Junio C Hamano
2025-06-03 22:11 ` Junio C Hamano
2025-06-06 11:39 ` Martin Ågren
2025-06-07 9:45 ` [PATCH v3 " Phillip Wood
2025-06-07 9:45 ` [PATCH v3 1/2] stash: allow "git stash -p <pathspec>" to assume push again Phillip Wood
2025-06-07 9:45 ` [PATCH v3 2/2] stash: allow "git stash [<options>] --patch <pathspec>" to assume push Phillip Wood
2025-06-07 12:56 ` [PATCH v3 0/2] stash: fix and improve "git stash -p <pathspec>" Martin Ågren
2025-06-09 9:42 ` Phillip Wood
2025-06-10 9:56 ` Martin Ågren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffafdfe8-7754-4aa7-b2bc-ef85452f8afb@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=martin.agren@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).