darcs

Issue 2386 A file with no trailing newline characters gives strange diff output

Title A file with no trailing newline characters gives strange diff output
Priority Status needs-diagnosis/design
Milestone Resolved in
Superseder Nosy List owst
Assigned To
Topics

Created on 2014-05-11.10:44:35 by owst, last changed 2020-06-21.09:13:55 by bfrk.

Messages
msg17439 (view) Author: owst Date: 2014-05-11.10:44:33
1. Summarise the issue (what were doing, what went wrong?)

I created a file foo with no trailing \n, and recorded its addition.
Upon removing foo, the output was strange (there is a spurious line
addition symbol):

hunk ./foo 1
-foo
+
rmfile ./foo

Indeed, when first adding foo, if I had diffed the file addition, I
would have seem the same problem, but inverted:

addfile ./foo
hunk ./foo 1
-
+foo

The same problem occurs for files with any number of (\n-terminated)
lines, but with no \n on the final line.

2. What behaviour were you expecting instead?

The spurious '+' should not be present for the removal case and the '-'
not present for the addition case.

There is a question about what darcs should do in the presence of such
"text files" (Text files should be a list of newline-terminated strings)
Git for example warns when handling such files.

Might be related to http://bugs.darcs.net/issue1717
msg18308 (view) Author: ankitku Date: 2015-03-13.21:09:06
verified behaviour on darcs 2.11.0 :
$ darcs record foo
Recording changes in "foo":

hunk ./foo 1
+foo

$vim foo #removed foo line
$ darcs record foo
Recording changes in "foo":

hunk ./foo 1
-foo

#working now as expected, without any spurious line.
#checked issue1717 too, and couldn't reproduce that, should I mark that 
resolved too?
msg18309 (view) Author: bfrk Date: 2015-03-16.00:32:27
I can reproduce this with 2.11:

> darcs --version
2.11.0 (unknown)
> darcs init
Repository initialized.
> echo -n foo >foo
> darcs record -lm'added foo'
addfile ./foo
Shall I record this change? (1/2)  [ynW...], or ? for more options: y
hunk ./foo 1
-
+foo
Shall I record this change? (2/2)  [ynW...], or ? for more options: y
Do you want to record these changes? [Yglqk...], or ? for more options: y
Do you want to add a long comment? [yn]n
Finished recording patch 'added foo'
> rm foo                     
> darcs record -lm'removed foo'
hunk ./foo 1
-foo
+
Shall I record this change? (1/2)  [ynW...], or ? for more options: y
rmfile ./foo
Shall I record this change? (2/2)  [ynW...], or ? for more options: y
Do you want to record these changes? [Yglqk...], or ? for more options: y
Do you want to add a long comment? [yn]n
Finished recording patch 'removed foo'

Should we mark this (and issue1717 which is a duplicate) as wont-fix?
Ganesh explained the reasons for this in a comment to issue1717, but I
don't understand the explanation. Perhaps some elaboration would help?
msg22090 (view) Author: bfrk Date: 2020-06-21.09:13:54
The model of how darcs handles this case is described in long comments 
in Darcs.Repository.Diff and in Darcs.Patch.Prim.V1.Apply.

A warning (a la diff or git) may be appropriate.
History
Date User Action Args
2014-05-11 10:44:35owstcreate
2015-03-13 21:09:08ankitkusetstatus: unknown -> needs-reproduction
messages: + msg18308
2015-03-16 00:32:29bfrksetmessages: + msg18309
2020-06-21 09:13:55bfrksetstatus: needs-reproduction -> needs-diagnosis/design
messages: + msg22090