Tortoise Git unified diff from working tree has lines that git cannot handle when the patch is applied

29 views
Skip to first unread message

jdan...@gmail.com

unread,
Mar 31, 2020, 4:17:40 PM3/31/20
to tortoisegit-users
When I "save unified diff" for my working changes from the Working Tree Dialog I receive the following diff:




 top.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/top.txt b/top.txt
index fd2a720..a63684e 100644
--- a/top.txt
+++ b/top.txt
@@ -5,7 +5,7 @@ reading
 writing
 'rithmatic
 
-
+I want to see this change in the patch file.
 
 And another one.
 
 


Note the first two lines (three if you include the blank line) that include the individual file changed and the stats for those changes.  When I save this as a patch file, then try to apply it git chokes because of those lines.  If I manually remove those lines so that the first line of the patch is "diff --git ......" everything works as expected.

This seems to be a bug.  Can anyone confirm this is not intended behavior?  Sourcetree and other git clients don't seem to include these lines in the patch for the working tree.

Tortoise git version: TortoiseGit-2.10.0.2-64bit  for windows
Git version: 2.25.0.windows.1

Thanks,
Jonathan

Yue Lin Ho

unread,
Apr 19, 2020, 10:00:19 PM4/19/20
to tortoisegit-users


jdan...@gmail.com於 2020年4月1日星期三 UTC+8上午4時17分40秒寫道:
When I "save unified diff" for my working changes from the Working Tree Dialog I receive the following diff:




 top.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/top.txt b/top.txt
index fd2a720..a63684e 100644
--- a/top.txt
+++ b/top.txt
@@ -5,7 +5,7 @@ reading
 writing
 'rithmatic
 
-
+I want to see this change in the patch file.
 
 And another one.
 
 


Note the first two lines (three if you include the blank line) that include the individual file changed and the stats for those changes.  When I save this as a patch file, then try to apply it git chokes because of those lines.  If I manually remove those lines so that the first line of the patch is "diff --git ......" everything works as expected.

This seems to be a bug.  Can anyone confirm this is not intended behavior?  Sourcetree and other git clients don't seem to include these lines in the patch for the working tree.


Not sure if it is intended behavior. 
But, here is my way to apply such patch file by using "TortoiseGit -> Review/apply single patch...":  

the patch file:

TortoiseGitUDiff_2020-04-20_09-55-52.png



Apply:

explorer_2020-04-20_09-46-27.png


Do these:

explorer_2020-04-20_09-51-31.png


Done 

TortoiseGitMerge_2020-04-20_09-52-57.png


and exit



Yue Lin

 
Reply all
Reply to author
Forward
0 new messages