現象:
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 <[email protected]>
Date: Fri, 9 Aug 2019 16:18:35 +0800
Subject: [PATCH] someone fox something