Darcs appears to assume that "empty" files in fact contain a single ^J
character. I discovered this when an application created text files
without a tailing newline -- darcs whatnew and record both considered
the file to have had automatic newline REMOVED.
This behaviour is VERY VERY confusing, and it was only by chance that
I managed to diagnose the symptoms.
Below is a demonstration script
#!/bin/bash -x
darcs --version
/usr/bin/darcs --version
darcs init
touch f
darcs rec -lam 'Add f (empty).' f
cat >f <<EOF
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras posuere
mattis enim, nec elementum lorem vehicula non. Donec eget eros orci,
sed feugiat tellus.
Morbi nisi lectus, malesuada a aliquam sed, tempus id orci. Quisque
sit amet accumsan risus. Pellentesque ultrices diam ut ligula
scelerisque in porta libero euismod.
EOF
perl -pi -0 -e 's/\n$//' f # delete the final newline
darcs whatsnew f
darcs record f <<<nnnq
## Note that the record behaviour is slightly different for 2.3.0.
/usr/bin/darcs record f <<<nnnq
darcs rec -am 'Add f (contents).' f
darcs diff -p .
and its output
with-temp-dir: entering directory `/tmp/with-temp-dir.tro2Eo'
+ darcs --version
2.3.1 (+ 381 patches)
+ /usr/bin/darcs --version
2.3.0 (release)
+ darcs init
+ touch f
+ darcs rec -lam 'Add f (empty).' f
Recording changes in "f":
Finished recording patch 'Add f (empty).'
+ cat
+ perl -pi -0 -e 's/\n$//' f
+ darcs whatsnew f
What's new in "f":
hunk ./f 1
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras posuere
+mattis enim, nec elementum lorem vehicula non. Donec eget eros orci,
+sed feugiat tellus.
hunk ./f 5
+Morbi nisi lectus, malesuada a aliquam sed, tempus id orci. Quisque
+sit amet accumsan risus. Pellentesque ultrices diam ut ligula
+scelerisque in porta libero euismod.
+ darcs record f
Recording changes in "f":
hunk ./f 1
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras posuere
+mattis enim, nec elementum lorem vehicula non. Donec eget eros orci,
+sed feugiat tellus.
Shall I record this change? (1/2) [ynWesfvplxdaqjk], or ? for help:
hunk ./f 5
+Morbi nisi lectus, malesuada a aliquam sed, tempus id orci. Quisque
+sit amet accumsan risus. Pellentesque ultrices diam ut ligula
+scelerisque in porta libero euismod.
Shall I record this change? (2/2) [ynWesfvplxdaqjk], or ? for help:
Ok, if you don't want to record anything, that's fine!
+ /usr/bin/darcs record f
Recording changes in "f":
hunk ./f 1
-
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras posuere
+mattis enim, nec elementum lorem vehicula non. Donec eget eros orci,
+sed feugiat tellus.
+
+Morbi nisi lectus, malesuada a aliquam sed, tempus id orci. Quisque
+sit amet accumsan risus. Pellentesque ultrices diam ut ligula
+scelerisque in porta libero euismod.
Shall I record this change? (1/1) [ynWsfvplxdaqjk], or ? for help:
Ok, if you don't want to record anything, that's fine!
+ darcs rec -am 'Add f (contents).' f
Recording changes in "f":
Finished recording patch 'Add f (contents).'
+ darcs diff -p .
Mon Dec 14 18:11:45 EST 2009 Trent W. Buck <trentbuck@gmail.com>
* Add f (contents).
diff -rN -u -purd old-with-temp-dir.tro2Eo/f new-with-temp-dir.tro2Eo/f
--- old-with-temp-dir.tro2Eo/f 2009-12-14 18:11:46.024236048 +1100
+++ new-with-temp-dir.tro2Eo/f 2009-12-14 18:11:46.024236048 +1100
@@ -0,0 +1,7 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras posuere
+mattis enim, nec elementum lorem vehicula non. Donec eget eros orci,
+sed feugiat tellus.
+
+Morbi nisi lectus, malesuada a aliquam sed, tempus id orci. Quisque
+sit amet accumsan risus. Pellentesque ultrices diam ut ligula
+scelerisque in porta libero euismod.
\ No newline at end of file
with-temp-dir: leaving directory `/tmp/with-temp-dir.tro2Eo'
|