git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] t3206-range-diff.sh: cover single-patch case

From
Stefan Beller <sbeller@google.com>
Date
Sep 11, 2018, 21:09 UTC
Message-ID
<CAGZ79kYZWRS3p+dP-3AtDSs0JqCCOd1rycugRZawpbkB0ydw3A@mail.gmail.com>
In-Reply-To
<58347a962438852be0d37c3957686ea5000b2dbd.1536697263.git.gitgitgadget@gmail.com>

On Tue, Sep 11, 2018 at 1:21 PM Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 27 quoted lines
>
> From: Derrick Stolee <dstolee@microsoft.com>
>
> The commit 40ce4160 "format-patch: allow --range-diff to apply to
> a lone-patch" added the ability to see a range-diff as commentary
> after the commit message of a single patch series (i.e. [PATCH]
> instead of [PATCH X/N]). However, this functionality was not
> covered by a test case.
>
> Add a simple test case that checks that a range-diff is written as
> commentary to the patch.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
>  t/t3206-range-diff.sh | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
> index 3d7a2d8a4d..05ef3263d2 100755
> --- a/t/t3206-range-diff.sh
> +++ b/t/t3206-range-diff.sh
> @@ -154,4 +154,9 @@ do
>         '
>  done
>
> +test_expect_success 'format-patch --range-diff as commentary' '
> +       git format-patch --stdout --range-diff=HEAD~1 HEAD~1 >actual &&

This is an interesting use of range-diff, as it basically tells us "Range-diff: This is a new patch", but it works to make sure there is a range diff section. (I shortly wondered if we would ever omit the range diff for "obvious" cases or word it differently)

> +       grep -A 1 -e "\-\-\-" actual | grep "Range-diff:"
So the first grep finds the three dashes, presumably those
after the commit message/ but others as well, e.g. in
    --- a/<path>
    +++ b/<path>
and then the second grep should find the string "Range-diff".
By having the greps chained with a pipe, only one return
code can be delivered to the test suite, and as we get the last
commands return code, we get reported if we found the string
in the preselected part.

I was wondering if we could get away with just one command to check for that multi line pattern

    sed -n -e '/---/,/^Range/p' actual

seems to detect that pattern, and prints from there on to the rest of the file.

Show 5 quoted lines
> +'
> +
>  test_done
> --
> gitgitgadget
Previous: Junio C HamanoNext: Eric Sunshine
Message 5 of 11 in “Add coverage for 'git format-patch --range-diff' single-patch case”
  1. 0/1 Add coverage for 'git format-patch --range-diff' single-patch caseDerrick Stolee via GitGitGadget, Sep 11, 2018
  2. 1/1 t3206-range-diff.sh: cover single-patch caseDerrick Stolee via GitGitGadget, Sep 11, 2018
  3. Junio C HamanoSep 11, 2018
  4. Junio C HamanoSep 11, 2018
  5. Stefan BellerSep 11, 2018
  6. Eric SunshineSep 11, 2018
  7. Derrick StoleeSep 12, 2018
  8. Derrick StoleeSep 11, 2018
  9. Eric SunshineSep 11, 2018
  10. 0/1 Add coverage for 'git format-patch --range-diff' single-patch caseDerrick Stolee via GitGitGadget, Sep 12, 2018
  11. 1/1 t3206-range-diff.sh: cover single-patch caseDerrick Stolee via GitGitGadget, Sep 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.