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

Is there a way to get the "format-patch" formatted file name?

From
Vít Ondruch <vondruch@redhat.com>
Date
Aug 31, 2023, 09:49 UTC
Message-ID
<aa35fbdb-cca4-ae04-4124-9498d682ec06@redhat.com>
Hi,
My typical use case is to download patches from GH, e.g.:
~~~
$ curl -OL https://github.com/rails/sprockets/pull/791.patch
   % Total    % Received % Xferd  Average Speed   Time    Time Time  Current
                                  Dload  Upload   Total   Spent Left  Speed
   0     0    0     0    0     0      0      0 --:--:-- --:--:-- 
--:--:--     0
100 12717    0 12717    0     0  21765      0 --:--:-- --:--:-- --:--:-- 
58603
~~~

The problem with this is that I end up with the "791.patch" file, while I'd like have a file with similar name as if I have used the git command:

~~~

$ git format-patch -1 6554b6d 0001-Fix-Minitest-constant-name-in-tests.patch

~~~
So I wonder, is there a way to get such file name?

The basic use case which would be enough for me would be to obtain the string:

~~~
$ head -4 791.patch | tail -1
Subject: [PATCH] Fix Minitest constant name in tests
~~~
and then use something like:
~~~

$ echo "Fix Minitest constant name in tests" | git sanitize-string-into-filename

Fix-Minitest-constant-name-in-tests
~~~
Of course I can imagine something more fancy such as:
~~~
$ git extract-filenames-from-patch 791.patch
0001-Fix-Minitest-constant-name-in-tests.patch
~~~
IOW, I'd like if the `fmt_output_subject` method (if that is the right one):
https://github.com/git/git/blob/6e8611e90a629e38da1e7c0e1f986bc6ec23a330/log-tree.c#L388
was more user exposed.

Of course I could put some script like this together myself, but I think that Git already has all the pluming.

Thank you in advance
Vít
P.S.: Please keep me in the CC, because I am not subscribed to this ML
Next: Oswald Buddenhagen
Message 1 of 10 in “Is there a way to get the "format-patch" formatted file name?”
  1. Vít OndruchAug 31, 2023
  2. Oswald BuddenhagenAug 31, 2023
  3. Vít OndruchAug 31, 2023
  4. Oswald BuddenhagenAug 31, 2023
  5. Junio C HamanoAug 31, 2023
  6. Vít OndruchSep 1, 2023
  7. Oswald BuddenhagenSep 1, 2023
  8. Junio C HamanoSep 1, 2023
  9. Junio C HamanoSep 1, 2023
  10. Vít OndruchSep 1, 2023

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.