# format-patch and submodules

5 messages from 2015-06-04 to 2015-06-10. Participants: Christopher Dunn, Jens Lehmann, Luke Diamand.
Thread: https://gitlist.dev/t/39528

## Christopher Dunn, 2015-06-04 23:20

Subject: format-patch and submodules
Message-ID: <CAD2z=MAu1qrr9=wwBnOJZZ3JCJOsmFWi=gDgKMQKU3_P-01e3g@mail.gmail.com>
URL: https://gitlist.dev/e/CAD2z%3DMAu1qrr9%3DwwBnOJZZ3JCJOsmFWi%3DgDgKMQKU3_P-01e3g%40mail.gmail.com

```
(Seen in git versions: 2.1.0 and 1.9.3 et al.)

$ git format-patch --stdout X^..X | git apply check -
fatal: unrecognized input

This fails when the commit consists of nothing but a submodule change
(as in 'git add submodule foo'), but it passes when a file change is
added to the same commit.

There used to be a similar problem for empty commits, but that was
fixed around git-1.8:

    http://stackoverflow.com/questions/20775132/cannot-apply-git-patch-replacing-a-file-with-a-link

Now, 'git format-patch' outputs nothing for an empty commit. I suppose
that needs to be the behavior also when only submodules are changed,
since in that case there is no 'diff' section from 'format-patch'.

Use-case: git-p4

Of course, we do not plan to add the submodule into Perforce, but we
would like this particular command to behave the same whether there
are other diffs or not.

~Christopher Dunn (cdunn2001)

```

## Jens Lehmann, 2015-06-09 18:52

Subject: Re: format-patch and submodules
Message-ID: <557735E6.8040906@web.de>
URL: https://gitlist.dev/e/557735E6.8040906%40web.de
In-Reply-To: <CAD2z=MAu1qrr9=wwBnOJZZ3JCJOsmFWi=gDgKMQKU3_P-01e3g@mail.gmail.com>

```
Am 05.06.2015 um 01:20 schrieb Christopher Dunn:
> (Seen in git versions: 2.1.0 and 1.9.3 et al.)
>
> $ git format-patch --stdout X^..X | git apply check -
> fatal: unrecognized input
>
> This fails when the commit consists of nothing but a submodule change
> (as in 'git add submodule foo'), but it passes when a file change is
> added to the same commit.
>
> There used to be a similar problem for empty commits, but that was
> fixed around git-1.8:
>
>      http://stackoverflow.com/questions/20775132/cannot-apply-git-patch-replacing-a-file-with-a-link
>
> Now, 'git format-patch' outputs nothing for an empty commit. I suppose
> that needs to be the behavior also when only submodules are changed,
> since in that case there is no 'diff' section from 'format-patch'.
>
> Use-case: git-p4
>
> Of course, we do not plan to add the submodule into Perforce, but we
> would like this particular command to behave the same whether there
> are other diffs or not.

Hmm, I'm not sure that this is a bug. It looks to me like doing a

$ git format-patch --stdout X^..X | git apply check -

when nothing is changed except submodules and expecting it to work
is the cause of the problem.

I get the same error when I do:

$git format-patch --stdout master..master | git apply --check -
fatal: unrecognized input

No submodules involved, just an empty patch.

I assume you want to ignore all submodule changes, so you should
check if e.g. "git diff --ignore-submodules X^..X" returns anything
before applying that? (From the command you ran I assume you might
be able to drop the --ignore-submodules because you already did set
"diff.ignoreSubmodules" to "all"?)

```

## Christopher Dunn, 2015-06-10 17:04

Subject: Re: format-patch and submodules
Message-ID: <CAD2z=MBSAzENvj1-WUMzrXznvudjCc3vyvYQQ+wMnPC3G3Go2Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAD2z%3DMBSAzENvj1-WUMzrXznvudjCc3vyvYQQ%2BwMnPC3G3Go2Q%40mail.gmail.com
In-Reply-To: <557735E6.8040906@web.de>

```
Sorry. I thought empty patches were made to work in other cases.

'git-p4' needs to skip these. Wrong mailing list then.

On Tue, Jun 9, 2015 at 1:52 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
> Am 05.06.2015 um 01:20 schrieb Christopher Dunn:
>>
>> (Seen in git versions: 2.1.0 and 1.9.3 et al.)
>>
>> $ git format-patch --stdout X^..X | git apply check -
>> fatal: unrecognized input
>>
>> This fails when the commit consists of nothing but a submodule change
>> (as in 'git add submodule foo'), but it passes when a file change is
>> added to the same commit.
>>
>> There used to be a similar problem for empty commits, but that was
>> fixed around git-1.8:
>>
>>
>> http://stackoverflow.com/questions/20775132/cannot-apply-git-patch-replacing-a-file-with-a-link
>>
>> Now, 'git format-patch' outputs nothing for an empty commit. I suppose
>> that needs to be the behavior also when only submodules are changed,
>> since in that case there is no 'diff' section from 'format-patch'.
>>
>> Use-case: git-p4
>>
>> Of course, we do not plan to add the submodule into Perforce, but we
>> would like this particular command to behave the same whether there
>> are other diffs or not.
>
>
> Hmm, I'm not sure that this is a bug. It looks to me like doing a
>
> $ git format-patch --stdout X^..X | git apply check -
>
> when nothing is changed except submodules and expecting it to work
> is the cause of the problem.
>
> I get the same error when I do:
>
> $git format-patch --stdout master..master | git apply --check -
> fatal: unrecognized input
>
> No submodules involved, just an empty patch.
>
> I assume you want to ignore all submodule changes, so you should
> check if e.g. "git diff --ignore-submodules X^..X" returns anything
> before applying that? (From the command you ran I assume you might
> be able to drop the --ignore-submodules because you already did set
> "diff.ignoreSubmodules" to "all"?)

```

## Luke Diamand, 2015-06-10 21:14

Subject: Re: format-patch and submodules
Message-ID: <5578A8AC.2090704@diamand.org>
URL: https://gitlist.dev/e/5578A8AC.2090704%40diamand.org
In-Reply-To: <CAD2z=MBSAzENvj1-WUMzrXznvudjCc3vyvYQQ+wMnPC3G3Go2Q@mail.gmail.com>

```
On 10/06/15 18:04, Christopher Dunn wrote:
> Sorry. I thought empty patches were made to work in other cases.
>
> 'git-p4' needs to skip these. Wrong mailing list then.

Possibly the right mailing list - can you explain what you mean here 
w.r.t git-p4 please?

Thanks!
Luke




>
> On Tue, Jun 9, 2015 at 1:52 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>> Am 05.06.2015 um 01:20 schrieb Christopher Dunn:
>>>
>>> (Seen in git versions: 2.1.0 and 1.9.3 et al.)
>>>
>>> $ git format-patch --stdout X^..X | git apply check -
>>> fatal: unrecognized input
>>>
>>> This fails when the commit consists of nothing but a submodule change
>>> (as in 'git add submodule foo'), but it passes when a file change is
>>> added to the same commit.
>>>
>>> There used to be a similar problem for empty commits, but that was
>>> fixed around git-1.8:
>>>
>>>
>>> http://stackoverflow.com/questions/20775132/cannot-apply-git-patch-replacing-a-file-with-a-link
>>>
>>> Now, 'git format-patch' outputs nothing for an empty commit. I suppose
>>> that needs to be the behavior also when only submodules are changed,
>>> since in that case there is no 'diff' section from 'format-patch'.
>>>
>>> Use-case: git-p4
>>>
>>> Of course, we do not plan to add the submodule into Perforce, but we
>>> would like this particular command to behave the same whether there
>>> are other diffs or not.
>>
>>
>> Hmm, I'm not sure that this is a bug. It looks to me like doing a
>>
>> $ git format-patch --stdout X^..X | git apply check -
>>
>> when nothing is changed except submodules and expecting it to work
>> is the cause of the problem.
>>
>> I get the same error when I do:
>>
>> $git format-patch --stdout master..master | git apply --check -
>> fatal: unrecognized input
>>
>> No submodules involved, just an empty patch.
>>
>> I assume you want to ignore all submodule changes, so you should
>> check if e.g. "git diff --ignore-submodules X^..X" returns anything
>> before applying that? (From the command you ran I assume you might
>> be able to drop the --ignore-submodules because you already did set
>> "diff.ignoreSubmodules" to "all"?)
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```

## Christopher Dunn, 2015-06-10 22:41

Subject: Re: format-patch and submodules
Message-ID: <CAD2z=MD3+63jL3Qqm-sj-7VnSB8ayhK_NjZV-qf+nyfuPdUk3Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAD2z%3DMD3%2B63jL3Qqm-sj-7VnSB8ayhK_NjZV-qf%2BnyfuPdUk3Q%40mail.gmail.com
In-Reply-To: <5578A8AC.2090704@diamand.org>

```
Well, now it gets more complicated. I want git-p4 to ignore submodules
completely. But it fails only *only* the submodules changed. (At
least, my version fails. I'll try to diff against latest.)

But to debug this, I had to add a dry-run mode to git-p4. And I am
using a version of git-p4 which uses 'git-notes' rather than
re-writing history. If you want, you can try my version:

  https://github.com/pb-cdunn/git-p4

On Wed, Jun 10, 2015 at 4:14 PM, Luke Diamand <luke@diamand.org> wrote:
> On 10/06/15 18:04, Christopher Dunn wrote:
>>
>> Sorry. I thought empty patches were made to work in other cases.
>>
>> 'git-p4' needs to skip these. Wrong mailing list then.
>
>
> Possibly the right mailing list - can you explain what you mean here w.r.t
> git-p4 please?
>
> Thanks!
> Luke
>
>
>
>
>>
>> On Tue, Jun 9, 2015 at 1:52 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>>>
>>> Am 05.06.2015 um 01:20 schrieb Christopher Dunn:
>>>>
>>>>
>>>> (Seen in git versions: 2.1.0 and 1.9.3 et al.)
>>>>
>>>> $ git format-patch --stdout X^..X | git apply check -
>>>> fatal: unrecognized input
>>>>
>>>> This fails when the commit consists of nothing but a submodule change
>>>> (as in 'git add submodule foo'), but it passes when a file change is
>>>> added to the same commit.
>>>>
>>>> There used to be a similar problem for empty commits, but that was
>>>> fixed around git-1.8:
>>>>
>>>>
>>>>
>>>> http://stackoverflow.com/questions/20775132/cannot-apply-git-patch-replacing-a-file-with-a-link
>>>>
>>>> Now, 'git format-patch' outputs nothing for an empty commit. I suppose
>>>> that needs to be the behavior also when only submodules are changed,
>>>> since in that case there is no 'diff' section from 'format-patch'.
>>>>
>>>> Use-case: git-p4
>>>>
>>>> Of course, we do not plan to add the submodule into Perforce, but we
>>>> would like this particular command to behave the same whether there
>>>> are other diffs or not.
>>>
>>>
>>>
>>> Hmm, I'm not sure that this is a bug. It looks to me like doing a
>>>
>>> $ git format-patch --stdout X^..X | git apply check -
>>>
>>> when nothing is changed except submodules and expecting it to work
>>> is the cause of the problem.
>>>
>>> I get the same error when I do:
>>>
>>> $git format-patch --stdout master..master | git apply --check -
>>> fatal: unrecognized input
>>>
>>> No submodules involved, just an empty patch.
>>>
>>> I assume you want to ignore all submodule changes, so you should
>>> check if e.g. "git diff --ignore-submodules X^..X" returns anything
>>> before applying that? (From the command you ran I assume you might
>>> be able to drop the --ignore-submodules because you already did set
>>> "diff.ignoreSubmodules" to "all"?)
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

```
