# [git issue] git am failed for patches of converting the format of source codes from dos to unix

2 messages from 2019-09-27 to 2019-09-27. Participants: Beyondhorizon Zheng, Thomas Gummerer.
Thread: https://gitlist.dev/t/51933

## Beyondhorizon Zheng, 2019-09-27 07:31

Subject: [git issue] git am failed for patches of converting the format of source codes from dos to unix
Message-ID: <CAP2YDYhfA__VYe-Kt3FwjPMzJ1jVo8X9eQ-pHR4MhQWypkrkKQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAP2YDYhfA__VYe-Kt3FwjPMzJ1jVo8X9eQ-pHR4MhQWypkrkKQ%40mail.gmail.com

```
[git issue] git am failed for patches of converting the file format of
source codes from dos to unix

Git version: git version 2.23.0
Host PC: ubuntu 16.04.10
Reporter: Shuang Zheng

I have submitted a patch which convert the file format of source file
from dos to unix with command:
dos2unix misc/acrn-config/config_app/controller.py
then submit a patch with this change:
        git add controller.py
        git commit -m “change file format”
        git format-patch HEAD~1
        git am 0001-change-file-format.patch
errors as below:
Applying: change file format
error: patch failed: misc/acrn-config/config_app/controller.py:1
error: misc/acrn-config/config_app/controller.py: patch does not apply
Patch failed at 0001 fix format
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

```

## Thomas Gummerer, 2019-09-27 09:25

Subject: Re: [git issue] git am failed for patches of converting the format of source codes from dos to unix
Message-ID: <20190927092543.GE11444@cat>
URL: https://gitlist.dev/e/20190927092543.GE11444%40cat
In-Reply-To: <CAP2YDYhfA__VYe-Kt3FwjPMzJ1jVo8X9eQ-pHR4MhQWypkrkKQ@mail.gmail.com>

```
On 09/27, Beyondhorizon Zheng wrote:
> [git issue] git am failed for patches of converting the file format of
> source codes from dos to unix
> 
> Git version: git version 2.23.0
> Host PC: ubuntu 16.04.10
> Reporter: Shuang Zheng
> 
> I have submitted a patch which convert the file format of source file
> from dos to unix with command:
> dos2unix misc/acrn-config/config_app/controller.py
> then submit a patch with this change:
>         git add controller.py
>         git commit -m “change file format”
>         git format-patch HEAD~1

Here you are preparing a patch of your last commit.  Good.

>         git am 0001-change-file-format.patch

Running this right after 'git format-patch' will try to apply the
patch, but your latest commit already includes those changes.  So
there is nothing to apply, and 'git am' fails.  Normally you would not
use 'format-patch' and then try to apply the patch again, but rather
send it to someone else, who could then apply your changes.

You could use 'git am -3 0001-change-file-format.patch', which falls
back to a three-way merge, which should tell you something like:

    No changes -- Patch already applied.

If you want to check that the patch applies correctly, you can use
'git reset --hard HEAD~1' (make sure you don't have any untracked
changes you don't want to loose first), and then use the 'git am'
command from above.

Hope that helps.

> errors as below:
> Applying: change file format
> error: patch failed: misc/acrn-config/config_app/controller.py:1
> error: misc/acrn-config/config_app/controller.py: patch does not apply
> Patch failed at 0001 fix format
> hint: Use 'git am --show-current-patch' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".

```
