threads / discuss / 21249

How does format-patch determine the filename of the patch?

Subject: How does format-patch determine the filename of the patch?

## tl;dr

5 messages between Oct 15, 2009 and Oct 29, 2009.

replies: 4people: 4as markdown or json

Timur Tabi· Oct 15, 2009, 16:17 UTC · lore
Hi.  I'm not familiar with the git source code, so forgive me if this
is a dumb question.  I'm trying to determine the algorithm that
git-format-patch uses to determine the name of the patch file it
creates (e.g. "0001-this-is-my-patch-without-spaces-and-trunca.patch")
 I'm looking at the function cmd_format_patch(), and I just don't see
where it creates any files.  Can someone show me where this code is?

The reason I ask is that I'm writing a script which calls git-format-patch to create some patches for post-processing. So I need the name of the file that git-format-patch creates so that I can open it and examine it. I'd liked to see if there's a way to get the name of the patch without actually creating the file.

-- 
Timur Tabi
Linux kernel developer at Freescale
Thomas Rast· Oct 15, 2009, 17:48 UTC · re: Timur Tabi · lore

Re: How does format-patch determine the filename of the patch?

Timur Tabi wrote:
Show 6 quoted lines
> Hi.  I'm not familiar with the git source code, so forgive me if this
> is a dumb question.  I'm trying to determine the algorithm that
> git-format-patch uses to determine the name of the patch file it
> creates (e.g. "0001-this-is-my-patch-without-spaces-and-trunca.patch")
>  I'm looking at the function cmd_format_patch(), and I just don't see
> where it creates any files.  Can someone show me where this code is?

get_patch_filename() in log-tree.c, but the bulk of the work is done in the call out to format_commit_message() [pretty.c] with the "%f" format, which is in turn handled by format_sanitized_subject() [pretty.c].

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Robin Rosenberg· Oct 15, 2009, 17:59 UTC · re: Timur Tabi · lore

Re: How does format-patch determine the filename of the patch?

torsdag 15 oktober 2009 18:17:09 skrev  Timur Tabi:
Show 12 quoted lines
> Hi.  I'm not familiar with the git source code, so forgive me if this
> is a dumb question.  I'm trying to determine the algorithm that
> git-format-patch uses to determine the name of the patch file it
> creates (e.g. "0001-this-is-my-patch-without-spaces-and-trunca.patch")
>  I'm looking at the function cmd_format_patch(), and I just don't see
> where it creates any files.  Can someone show me where this code is?
>
> The reason I ask is that I'm writing a script which calls
> git-format-patch to create some patches for post-processing.  So I
> need the name of the file that git-format-patch creates so that I can
> open it and examine it.  I'd liked to see if there's a way to get the
> name of the patch without actually creating the file.
It tells you the names on stdout.
-- robin
Timur Tabi· Oct 29, 2009, 13:05 UTC · re: Robin Rosenberg · lore

Re: How does format-patch determine the filename of the patch?

On Thu, Oct 15, 2009 at 12:59 PM, Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:

Show 7 quoted lines
>> The reason I ask is that I'm writing a script which calls
>> git-format-patch to create some patches for post-processing.  So I
>> need the name of the file that git-format-patch creates so that I can
>> open it and examine it.  I'd liked to see if there's a way to get the
>> name of the patch without actually creating the file.
>
> It tells you the names on stdout.

Is there a way for it to tell me the name on stdout *without* actually creating the patch?

-- 
Timur Tabi
Linux kernel developer at Freescale
Joshua Roys· Oct 29, 2009, 13:14 UTC · re: Timur Tabi · lore

Re: How does format-patch determine the filename of the patch?

On 10/29/2009 09:05 AM, Timur Tabi wrote:
Show 14 quoted lines
> On Thu, Oct 15, 2009 at 12:59 PM, Robin Rosenberg
> <robin.rosenberg.lists@dewire.com>  wrote:
>
>>> The reason I ask is that I'm writing a script which calls
>>> git-format-patch to create some patches for post-processing.  So I
>>> need the name of the file that git-format-patch creates so that I can
>>> open it and examine it.  I'd liked to see if there's a way to get the
>>> name of the patch without actually creating the file.
>>
>> It tells you the names on stdout.
>
> Is there a way for it to tell me the name on stdout *without* actually
> creating the patch?
>
Hello,

Is there any way you can just save the names from when you do call format-patch?

e.g. ... my @filenames = qx(git format-patch $opts); ...

Josh

← back to recent threads