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

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 18, 2020, 16:57 UTC
Message-ID
<xmqq4ksd5ggq.fsf@gitster.c.googlers.com>
In-Reply-To
<20200518135656.GB1980@danh.dev>
Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
Show 20 quoted lines
> I've written some test and concluded that we'll need this fix-up
> to make sure git-format-patch(1) doesn't generate broken patch:
>
> ----------------8<----------------
>  builtin/log.c            |  1 +
>  t/t4045-diff-relative.sh | 11 ++++++++---
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/log.c b/builtin/log.c
> index d104d5c688..5949a4883e 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1744,6 +1744,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  	rev.diff = 1;
>  	rev.max_parents = 1;
>  	rev.diffopt.flags.recursive = 1;
> +	rev.diffopt.flags.relative_name = 0;
>  	rev.subject_prefix = fmt_patch_subject_prefix;
>  	memset(&s_r_opt, 0, sizeof(s_r_opt));
>  	s_r_opt.def = "HEAD";
Hmph, what do you exactly mean by "broken patch"?
I actually do not mind people who set "diff.relative" to do
    $ git config diff.relative true
    $ cd t && git format-patch -1 --stdout

to get an incomplete patch that covers only the t/ subdirectory, as long as they can ask Git to optionally get the full view with

    $ cd t && git format-patch -1 --stdout --no-relative
Note: this is not limited to format-patch but all the commands in
the diff family like "log --stat", "show", etc.

Of course, diff.relative configuration would have no use for me personally and I suspect it would be useless for many people, but those who work inside a deeply nested project (java perhaps?) it would be handy and it makes sense to match the default behaviour between "diff", "show" and "format-patch" when the configuration is active, as long as they have a way to contermand from the command line.

Previous: Đoàn Trần Công DanhNext: Đoàn Trần Công Danh
Message 18 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.