[PATCH 3/4] diff: Do not warn about missing EOL at EOF for symlinks

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

 



Symbolic links are represented by blobs without a trailing newline
(EOL). This cannot be changed because it would encumber the
representation with platform EOL issues.

But seeing a warning about "No newline at end of file" in the diff for
a symbolic link is highly distracting - in particular, it distracts from
the actual mode (120000) and gives the false impression that Git treated
the symlink as a file.

Therefore, change the default behaviour of the diff code so that there
is no warning about missing EOL at EOF if a symlink is involved AND
textconv is allowed. So, --no-textconv restores the old behaviour, and
diff users such as format-patch are not affected by this change so that
apply/am are still able to create files with no EOL at EOF - such as
symlink representations.

Note that a mode change (file<->symlink) is always rewritten as
deletion+addition by the diff engine so that replacing a file without
EOL at EOF by a symlink or vice versa displays the warning for the file.

Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx>
---
 diff.c                   |    2 ++
 t/t4030-diff-textconv.sh |    1 -
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/diff.c b/diff.c
index 7950df6..cad7339 100644
--- a/diff.c
+++ b/diff.c
@@ -1788,6 +1788,8 @@ static void builtin_diff(const char *name_a,
 		ecbdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);
 		ecbdata.found_changesp = &o->found_changes;
 		ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a);
+		if (DIFF_OPT_TST(o, ALLOW_TEXTCONV) && (S_ISLNK(one->mode) || S_ISLNK(two->mode)))
+			ecbdata.ws_rule &= ~WS_NO_EOL_AT_EOF;
 		if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
 			check_blank_at_eof(&mf1, &mf2, &ecbdata);
 		ecbdata.file = o->file;
diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh
index 88c5619..b6e537f 100755
--- a/t/t4030-diff-textconv.sh
+++ b/t/t4030-diff-textconv.sh
@@ -109,7 +109,6 @@ index 0000000..67be421
 +++ b/file
 @@ -0,0 +1 @@
 +frotz
-\ No newline at end of file
 EOF
 # make a symlink the hard way that works on symlink-challenged file systems
 test_expect_success 'textconv does not act on symlinks' '
-- 
1.7.1.351.ge2633e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]