git am & apply 的trailing whitespace 错误

现象:
git am someone.patch
Applying: ...
/workingfolder/.git/rebase-apply/patch:50: trailing whitespace.
-- 
...
 
warning: squelched 3 whitespace errors
warning: 6 lines applied after fixing whitespace errors.

===============================
原因:
告警的含义是提示有空格在行尾出现。

检查后的确有空格在行尾。
===============================
具体方法:

1. git reset --hard <前一个commit id>

2. git am --reject --whitespace=fix /someone.patch

3. git format-patch -01 重新制作补丁,然后利用

vimdiff检查一下,是否已修正。

==========================
【其它】
为何报告的行号与实际patch中少了5行?
比如,报在50行,实际在55行。

因为patch开头的邮件相关的几行需要忽略。

这是因为git am利用的还是git apply命令。所以最后的输出是git apply输入。 它的输入,已被git am 删除了前面的几行关于邮件的信息:

From 7af2dbac9f32d7567b7a01199a539c3756a60897 Mon Sep 17 00:00:00 2001
From: Yujie Hao
Date: Fri, 9 Aug 2019 16:18:35 +0800
Subject: [PATCH] someone fox something

你可能感兴趣的:(linux)