monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] BUG: "mtn diff" vs. "diff" with respect to not existing


From: Ralf S. Engelschall
Subject: [Monotone-devel] BUG: "mtn diff" vs. "diff" with respect to not existing trailing newline on last line
Date: Wed, 27 Feb 2008 19:34:48 +0100
User-agent: Mutt/1.5.17 OpenPKG/CURRENT (2007-11-01)

I got catched the second time by this bug and now discovered the root of
the problem and hence finally can show a reproducer:

| $ mkdir test
| $ cd test
| $ mtn --db=/tmp/test.db db init
| $ mtn --db=/tmp/test.db setup -b test
| $ (echo "foo"; echo "bar"; echo "quux") >test1.txt
| $ (echo "foo"; echo "bar"; echo -n "quux") >test2.txt
| $ mtn add test1.txt test2.txt
| mtn: adding test1.txt to workspace manifest
| mtn: adding test2.txt to workspace manifest
| $ mtn ci -m "create two files: one with and one without trailing newline"
| mtn: beginning commit on branch 'test'
| mtn: committed revision 543d0ad9629f64fda112010bbdc1caae907d5beb
| $ (echo ""; echo "baz") >>test1.txt
| $ (echo ""; echo "baz") >>test2.txt
| $ mtn diff >/tmp/test.diff
| $ cat /tmp/test.diff
| #
| # old_revision [543d0ad9629f64fda112010bbdc1caae907d5beb]
| #
| # patch "test1.txt"
| #  from [a43dc27b1c92cccc533ceb3a27035128e26e5b07]
| #    to [ed677bdcf777e45b24bc12de48ea9b80b5c97ac2]
| #
| # patch "test2.txt"
| #  from [4f8091d2fa31b0598dd0ff6dc936f8d0b47b59d1]
| #    to [8aa9b19b304a24ebcd71cfc4a27efc95f8ad8e11]
| #
| ===================================================================
| Index: test1.txt
| --- test1.txt a43dc27b1c92cccc533ceb3a27035128e26e5b07
| +++ test1.txt ed677bdcf777e45b24bc12de48ea9b80b5c97ac2
| @@ -1,3 +1,5 @@
|  foo
|  bar
|  quux
| +
| +baz
| ===================================================================
| Index: test2.txt
| --- test2.txt 4f8091d2fa31b0598dd0ff6dc936f8d0b47b59d1
| +++ test2.txt 8aa9b19b304a24ebcd71cfc4a27efc95f8ad8e11
| @@ -1,3 +1,4 @@
|  foo
|  bar
|  quux
| +baz
| $ mtn revert .
| mtn: reverting test1.txt
| mtn: reverting test2.txt
| $ patch -p0 </tmp/test.diff
| patching file test1.txt
| patching file test2.txt
| Hunk #1 FAILED at 1.
| 1 out of 1 hunk FAILED -- saving rejects to file test2.txt.rej
| $

The problem is that the generated diff for test2.txt is not correct.
I've now just added the line with "baz", but actually also changed the
line with "quux": I added the terminating newline!

As a result patch(1) is not able to apply the generated patch, of
course! The correct patch as produced by diff(1) is:

| $ diff -u3 test1.txt.orig test1.txt; diff -u3 test2.txt.orig test2.txt
| --- test1.txt.orig      2008-02-27 19:26:07 +0100
| +++ test1.txt   2008-02-27 19:26:26 +0100
| @@ -1,3 +1,5 @@
|  foo
|  bar
|  quux
| +
| +baz
| --- test2.txt.orig      2008-02-27 19:26:07 +0100
| +++ test2.txt   2008-02-27 19:26:28 +0100
| @@ -1,3 +1,4 @@
|  foo
|  bar
| -quux
| \ No newline at end of file
| +quux
| +baz

Notice the difference on the "quux" line for test2.txt and the special
case of the "\ No newline at end of file" marker. I think Monotone has
to do the same in order to allow its output to be correctly processed by
the all-dancing-all-singing patch(1) command. I've still not looked at
the Monotone code, but I guess there currently might be still no special
processing for this special case...

                                       Ralf S. Engelschall
                                       address@hidden
                                       www.engelschall.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]