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

5 messages from 2009-10-15 to 2009-10-29. Participants: Timur Tabi, Thomas Rast, Robin Rosenberg, Joshua Roys.
Thread: https://gitlist.dev/t/21249

## Timur Tabi, 2009-10-15 16:17

Subject: How does format-patch determine the filename of the patch?
Message-ID: <ed82fe3e0910150917u72ef189epc74411e71a9cd2d4@mail.gmail.com>
URL: https://gitlist.dev/e/ed82fe3e0910150917u72ef189epc74411e71a9cd2d4%40mail.gmail.com

```
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, 2009-10-15 17:48

Subject: Re: How does format-patch determine the filename of the patch?
Message-ID: <200910151948.48539.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200910151948.48539.trast%40student.ethz.ch
In-Reply-To: <ed82fe3e0910150917u72ef189epc74411e71a9cd2d4@mail.gmail.com>

```
Timur Tabi wrote:
> 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, 2009-10-15 17:59

Subject: Re: How does format-patch determine the filename of the patch?
Message-ID: <200910151959.47778.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200910151959.47778.robin.rosenberg.lists%40dewire.com
In-Reply-To: <ed82fe3e0910150917u72ef189epc74411e71a9cd2d4@mail.gmail.com>

```
torsdag 15 oktober 2009 18:17:09 skrev  Timur Tabi:
> 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, 2009-10-29 13:05

Subject: Re: How does format-patch determine the filename of the patch?
Message-ID: <ed82fe3e0910290605j302747f9o6a86acb414427639@mail.gmail.com>
URL: https://gitlist.dev/e/ed82fe3e0910290605j302747f9o6a86acb414427639%40mail.gmail.com
In-Reply-To: <200910151959.47778.robin.rosenberg.lists@dewire.com>

```
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?

-- 
Timur Tabi
Linux kernel developer at Freescale

```

## Joshua Roys, 2009-10-29 13:14

Subject: Re: How does format-patch determine the filename of the patch?
Message-ID: <4AE99548.5060100@gmail.com>
URL: https://gitlist.dev/e/4AE99548.5060100%40gmail.com
In-Reply-To: <ed82fe3e0910290605j302747f9o6a86acb414427639@mail.gmail.com>

```
On 10/29/2009 09:05 AM, Timur Tabi wrote:
> 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

```
