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

Re: [PATCH v5] diff: add config option relative

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 18, 2020, 16:19 UTC
Message-ID
<CAPig+cRNCdtK9SSMSXj83tTCV1n+YW3-a0EnfM_VVVCry8rXCg@mail.gmail.com>
In-Reply-To
<20200518094021.GA2069@spk-laptop>
On Mon, May 18, 2020 at 5:40 AM Laurent Arnoud <laurent@spkdev.net> wrote:
Show 32 quoted lines
> The `diff.relative` boolean option set to `true` show only changes on
> the current directory and show relative pathnames to the current
> directory.
>
> Teach --no-relative to override earlier --relative
>
> Signed-off-by: Laurent Arnoud <laurent@spkdev.net>
> ---
> diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh
> +check_diff_relative_option () {
> +       dir=$1
> +       shift
> +       expect=$1
> +       shift
> +       relative_opt=$1
> +       shift
> +       short_blob=$(git rev-parse --short "$blob_file2")
> +       cat >expected <<-EOF
> +       diff --git a/$expect b/$expect
> +       new file mode 100644
> +       index 0000000..$short_blob
> +       --- /dev/null
> +       +++ b/$expect
> +       @@ -0,0 +1 @@
> +       +other content
> +       EOF
> +       test_expect_success "config diff.relative $relative_opt -p $*" "
> +               test_config -C $dir diff.relative $relative_opt &&
> +               git -C '$dir' diff -p $* HEAD^ >actual &&
> +               test_cmp expected actual
> +       "
> +}

Let's move all the setup code into the test itself so that a failure of git-rev-parse will be caught. For instance:

check_diff_relative_option () {
   dir=$1
   shift
   expect=$1
   shift
   relative_opt=$1
   shift
   test_expect_success "config diff.relative $relative_opt -p $*" "
       short_blob=$(git rev-parse --short $blob_file2) &&
       cat >expected <<-EOF &&
       diff --git a/$expect b/$expect
       new file mode 100644
       index 0000000..$short_blob
       --- /dev/null
       +++ b/$expect
       @@ -0,0 +1 @@
       +other content
       EOF
       test_config -C $dir diff.relative $relative_opt &&
       git -C '$dir' diff -p $* HEAD^ >actual &&
       test_cmp expected actual
   "
}
Same comment applies to the other new function added by this patch.
Previous: Laurent ArnoudNext: Laurent Arnoud
Message 36 of 39 in “diff: add config option relative”
  1. diff: add config option relativeLaurent Arnoud, May 15, 2020
  2. Philip OakleyMay 15, 2020
  3. Laurent ArnoudMay 16, 2020
  4. brian m. carlsonMay 15, 2020
  5. Junio C HamanoMay 16, 2020
  6. Laurent ArnoudMay 16, 2020
  7. Laurent ArnoudMay 16, 2020
  8. Phillip WoodMay 16, 2020
  9. Laurent ArnoudMay 16, 2020
  10. Đoàn Trần Công DanhMay 17, 2020
  11. Danh DoanMay 17, 2020
  12. Junio C HamanoMay 17, 2020
  13. Laurent ArnoudMay 18, 2020
  14. Shourya ShuklaMay 18, 2020
  15. Đoàn Trần Công DanhMay 18, 2020
  16. Laurent ArnoudMay 18, 2020
  17. Đoàn Trần Công DanhMay 18, 2020
  18. Junio C HamanoMay 18, 2020
  19. Đoàn Trần Công DanhMay 18, 2020
  20. Junio C HamanoMay 18, 2020
  21. Đoàn Trần Công DanhMay 19, 2020
  22. Junio C HamanoMay 19, 2020
  23. diff: add config option relativeLaurent Arnoud, May 19, 2020
  24. Đoàn Trần Công DanhMay 19, 2020
  25. diff: add config option relativeLaurent Arnoud, May 22, 2020
  26. Đoàn Trần Công DanhMay 23, 2020
  27. Laurent ArnoudMay 22, 2020
  28. Junio C HamanoMay 18, 2020
  29. Laurent ArnoudMay 18, 2020
  30. Junio C HamanoMay 18, 2020
  31. Junio C HamanoMay 18, 2020
  32. Eric SunshineMay 18, 2020
  33. Đoàn Trần Công DanhMay 18, 2020
  34. Junio C HamanoMay 18, 2020
  35. Laurent ArnoudMay 18, 2020
  36. Eric SunshineMay 18, 2020
  37. Laurent ArnoudMay 18, 2020
  38. Laurent ArnoudMay 18, 2020
  39. Junio C HamanoMay 17, 2020

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.