problem in git format diff

Dustin Sallings dustin at spy.net
Thu Nov 1 13:12:21 CDT 2007


	I found a problem in 0.9.5 in the diff output when using git diffs  
with renames.

	This matters to me because I'm trying to get a tool to apply a git  
diff outside of mercurial.  git-apply does what I want, but it does  
not work with hg's git diffs.

	The source of the problem is not obvious to me, so I'm not including  
a patch, but here's a demonstration of the issue:

dustintmb:/tmp/test/r1 509% hg init
dustintmb:/tmp/test/r1 510% cat > afile
testing afile
dustintmb:/tmp/test/r1 511% hg add afile
dustintmb:/tmp/test/r1 512% hg commit  -m 'first version'
dustintmb:/tmp/test/r1 513% hg mv afile bfile
dustintmb:/tmp/test/r1 514% cat >! bfile
testing bfile
dustintmb:/tmp/test/r1 515% hg status
A bfile
R afile
dustintmb:/tmp/test/r1 516% hg commit  -m 'bfile'
dustintmb:/tmp/test/r1 517% hg export
abort: export requires at least one changeset
dustintmb:/tmp/test/r1 518% hg export tip
# HG changeset patch
# User Dustin Sallings <dustin at spy.net>
# Date 1193940066 25200
# Node ID 22f31a286b3cde68e22849340014f0d127b24643
# Parent  439c6afcd343096cde6c191d07eb02f58743ff8e
bfile

diff --git a/afile b/bfile
rename from afile
rename to bfile
--- a/bfile
+++ b/bfile
@@ -1,1 +1,1 @@ testing afile
-testing afile
+testing bfile


	Note that in this patch, the diff is against a/bfile and b/bfile.   
That causes the following problem:


dustintmb:/tmp/test 520% hg clone -r 0 r1 r2
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
dustintmb:/tmp/test 521% cd r2/
dustintmb:/tmp/test/r2 522% hg export -R ../r1 2 | git-apply -p1
fatal: git-apply: bad git-diff - inconsistent old filename on line 11

	This is easily fixed if the prev name in the diff is the old name of  
the file:

dustintmb:/tmp/test/r2 523% hg export -R ../r1 2 | sed s,'--- a/ 
bfile,--- a/afile', | git-apply -p1
dustintmb:/tmp/test/r2 524%
[at this point, the tree is in the state I expect]

-- 
Dustin Sallings


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20071101/7d74efc5/attachment.htm 


More information about the Mercurial mailing list