git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vít Ondruch" <vondruch@redhat.com>
To: git@vger.kernel.org
Subject: Is there a way to get the "format-patch" formatted file name?
Date: Thu, 31 Aug 2023 11:49:10 +0200	[thread overview]
Message-ID: <aa35fbdb-cca4-ae04-4124-9498d682ec06@redhat.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1831 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

             reply	other threads:[~2023-08-31  9:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31  9:49 Vít Ondruch [this message]
2023-08-31 11:04 ` Is there a way to get the "format-patch" formatted file name? Oswald Buddenhagen
2023-08-31 12:13   ` Vít Ondruch
2023-08-31 12:46     ` Oswald Buddenhagen
2023-08-31 17:19 ` Junio C Hamano
2023-09-01  8:56   ` Vít Ondruch
2023-09-01 11:00     ` Oswald Buddenhagen
2023-09-01 15:53       ` Junio C Hamano
2023-09-01 16:04         ` Junio C Hamano
2023-09-01 16:37         ` Vít Ondruch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa35fbdb-cca4-ae04-4124-9498d682ec06@redhat.com \
    --to=vondruch@redhat.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).