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

Re: [PATCH v4] format-patch: allow a non-integral version numbers

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 15, 2021, 23:41 UTC
Message-ID
<CAPig+cSd-e76bOQY8yoZnRDbuQbZ_FNHJ5TV6BC+dAofPmk7DQ@mail.gmail.com>
In-Reply-To
<pull.885.v4.git.1614928211635.gitgitgadget@gmail.com>

On Fri, Mar 5, 2021 at 2:10 AM ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 17 quoted lines
> Usually we can only use `format-patch -v<n>` to generate integral
> version numbers patches, but sometimes a same fixup should be
> labeled as a non-integral version like `v1.1`, so teach `format-patch`
> to allow a non-integral version which may be helpful to send those
> patches.
>
> `<n>` can be any string, such as `-v1.1`.  In the case where it
> is a non-integral value, the "Range-diff" and "Interdiff"
> headers will not include the previous version.
>
> Signed-off-by: ZheNing Hu <adlternative@gmail.com>
> ---
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
> @@ -221,6 +221,7 @@ populated with placeholder text.
>         `--reroll-count=4` may produce `v4-0001-add-makefile.patch`
>         file that has "Subject: [PATCH v4 1/20] Add makefile" in it.
> +       now can support non-integrated version number like `-v1.1`.

Let's drop "now" from the beginning of the sentence since it is only meaningful for people who have read this documentation previously, but not for people newly learning about the option. Perhaps just say:

    `<n>` may be a fractional number.
Show 10 quoted lines
> diff --git a/builtin/log.c b/builtin/log.c
> @@ -1862,11 +1863,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
> -       if (0 < reroll_count) {
> +       if (reroll_count_string) {
>                 struct strbuf sprefix = STRBUF_INIT;
> +
> +               strtol_i(reroll_count_string, 10, &reroll_count);
> +               strbuf_addf(&sprefix, "%s v%s",
> +                           rev.subject_prefix, reroll_count_string);
> +               rev.reroll_count = reroll_count_string;

This code can be confusing to readers since it appears to ignore the result of strtol_i(), and it's difficult for the reader to understand the difference between `reroll_count` and `reroll_count_string` and why you need both variables. I was going to suggest that you write an /* in-code comment */ here explaining why you don't care if the reroll count parsed correctly as a number. However, now that I'm examining the code again, I think it would be clearer if you move the strtol_i() call into the diff_title() function since -- following your changes -- that function is the only code which cares whether `reroll_count` can be parsed as a number (the rest of the code, after your change, just uses it as a string).

Previous: ZheNing Hu via GitGitGadgetNext: ZheNing Hu
Message 19 of 49 in “format-patch: allow a non-integral version numbers”
  1. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Feb 25, 2021
  2. Eric SunshineFeb 25, 2021
  3. ZheNing HuFeb 27, 2021
  4. Junio C HamanoFeb 25, 2021
  5. ZheNing HuFeb 27, 2021
  6. Đoàn Trần Công DanhMar 17, 2021
  7. Junio C HamanoMar 17, 2021
  8. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 1, 2021
  9. Junio C HamanoMar 3, 2021
  10. Denton LiuMar 3, 2021
  11. Junio C HamanoMar 4, 2021
  12. ZheNing HuMar 4, 2021
  13. Eric SunshineMar 4, 2021
  14. Denton LiuMar 4, 2021
  15. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 4, 2021
  16. Denton LiuMar 4, 2021
  17. ZheNing HuMar 5, 2021
  18. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 5, 2021
  19. Eric SunshineMar 15, 2021
  20. ZheNing HuMar 16, 2021
  21. Eric SunshineMar 16, 2021
  22. Junio C HamanoMar 17, 2021
  23. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 16, 2021
  24. Eric SunshineMar 16, 2021
  25. ZheNing HuMar 17, 2021
  26. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 18, 2021
  27. Eric SunshineMar 19, 2021
  28. ZheNing HuMar 19, 2021
  29. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 19, 2021
  30. Junio C HamanoMar 19, 2021
  31. ZheNing HuMar 20, 2021
  32. Junio C HamanoMar 19, 2021
  33. ZheNing HuMar 20, 2021
  34. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 20, 2021
  35. Junio C HamanoMar 20, 2021
  36. ZheNing HuMar 21, 2021
  37. Eric SunshineMar 21, 2021
  38. Junio C HamanoMar 21, 2021
  39. Eric SunshineMar 21, 2021
  40. Denton LiuMar 24, 2021
  41. ZheNing HuMar 21, 2021
  42. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 21, 2021
  43. Eric SunshineMar 23, 2021
  44. Junio C HamanoMar 23, 2021
  45. ZheNing HuMar 23, 2021
  46. ZheNing HuMar 23, 2021
  47. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 23, 2021
  48. Eric SunshineMar 24, 2021
  49. ZheNing HuMar 24, 2021

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.