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

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

From
Vít Ondruch <vondruch@redhat.com>
Date
Sep 1, 2023, 08:56 UTC
Message-ID
<24e10903-29a0-497a-c8d8-b26c02de7336@redhat.com>
In-Reply-To
<xmqqo7inw2na.fsf@gitster.g>
Dne 31. 08. 23 v 19:19 Junio C Hamano napsal(a):
Show 28 quoted lines
> Vít Ondruch <vondruch@redhat.com> writes:
>
>> My typical use case is to download patches from GH, e.g.:
>>
>> ~~~
>>
>> $ curl -OL https://github.com/rails/sprockets/pull/791.patch
> ...
>> 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?
> Do you mean: GitHub should let me run this command instead
>
>    $ curl -OL https://github.com/rails/sprockets/pull/0001-Fix-Minitest-constant-name-in-tests.patch
>
> It may be nice for them to give a more meaningful name to their pull
> request (not just the output file name) than just an integer.

This URL would be hard to compile and it could potentially lead me to the same question ;) But maybe in combination with `-J` option, GH (but also all other forges) could probably do something about it.

> But
> that is not a question/request we can answer here (this is not a
> help forum for GitHub users).
Right.
Show 13 quoted lines
>
> Something along the lines of
>
>      sed -ne '/^Subject: /{
>              s/^Subject: *\[PATCH[^]]*\] *//;
>              s/[^a-zA-Z0-9]/-/g;
>              s/--*/-/g;
>              s/$/\.patch/;
> 	    p;
> 	    q;
>      }' 791.patch
>
> should be doable, but I am not sure what the benefit is.

If this was provided as a some convenient script, then I would not need to know what the sanitation of the subject is done to get the file name. However, so far I was mostly fine with manually replacing spaces by dashes, so what is sanitized is not really that important to me. I just though that if Git has already some opinion about it and it is already implemented, it would be nice to reuse the functionality.

>    Once you
> get it in Git,
But I typically don't have a Git.
Show 7 quoted lines
>   you'd park it on a branch with a useful name and we
> can forget about "791", so the "The files we get from GitHub are
> named in a way that makes it hard to identify them" does not sound
> like a Git issue, at least to me.
>
>
>

It does not seems I have convinced you (and that is fine). I'll probably look around. patchutils project could be probably good candidate for such script. I'll try to ask there. Maybe I'll also try to explore if GH would be open to provide some better filename, leveraging the `-J` curl option.

Thx for you help! Appreciate that.
Vít
Previous: Junio C HamanoNext: Oswald Buddenhagen
Message 6 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.