Two SVG files in core/misc/icons have CRLF line endings. These cause problems when you commit Drupal to a Git repo, because Git generally wants to convert CRLF to LF, leading to a lot of warnings like:

warning: CRLF will be replaced by LF

This is also inconsistent with the other SVG files in Drupal core, and with Drupal's policy as a whole of using LF vs CRLF.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dane Powell created an issue. See original summary.

Dane Powell’s picture

Status: Active » Needs review
FileSize
3.26 KB
Dane Powell’s picture

If anyone can suggest a way to automatically test for CRLF line endings in future commits, I think that would be smart. Not sure how myself.

Chi’s picture

I wonder if SVG should be configured in the .gitattrbutes file the same way as XML.

If anyone can suggest a way to automatically test for CRLF line endings in future commits

You may find this useful https://www.drupal.org/node/1542048.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

LoMo’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Needs review » Reviewed & tested by the community

Your fix looks good. The patch applies and fixes the only two instances in the project of CRLF line endings.

I don't think this needs to wait for 8.4 release, since this fix is totally non-disruptive.

To verify that these were the only two instances of a CRLF, I used the following terminal command:
find . -not -type d -exec file "{}" ";" | grep CRLF

What was displayed:

./core/misc/icons/787878/plus.svg: ASCII text, with very long lines, with CRLF line terminators
./core/misc/icons/bebebe/plus.svg: ASCII text, with very long lines, with CRLF line terminators
./drupal-2831598-2.patch: ASCII text, with very long lines, with CRLF, LF line terminators

(The third item found was your patch, of course. And after applying your patch, that was the only output from re-running the find/grep command.)

Full disclosure: I'm not a total terminal geek. ;-) I tried the most up-rated answer found here: http://stackoverflow.com/questions/73833/how-do-you-search-for-files-con...

Seems like the main repo needs to be set up to follow the published Git configuration instructions for CRLF? (Or maybe there is something wrong with that configuration and it needs a tweak?)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The suggestion in #4 seems very sensible - it will prevent this from every happening again.

LoMo’s picture

Status: Needs work » Reviewed & tested by the community

@alexpott Given that the scope of this issue was to fix the files in Drupal core which had slipped through whatever system might have been in place to prevent this sort of thing, shouldn't this issue still be considered RTBC? I think we can open another issue (referencing this one) to fix the d.o. Git system to reject any submitted patch which has CLRF line endings. But that would be an issue that only very few (drumm, maybe you, and other core committers, perhaps) would be able to take care of, if I'm not mistaken. Setting this one to "Needs work" sends a message to people who worked on it that there is something to be done (potentially by them). And I don't think that there is, right?

Since this is an issue related to existing files in Drupal core and the "bigger picture" is an issue for drupal.org's repo system, I've gone ahead and created that issue here: #2875025: Add code sniffs for line endings / SVG (on Project: Drupal.org webmasters / Component: Project/Git problem), and I've set this issue's status back to RTBC. (Please let me know if that approach doesn't make sense to you... ;-) )

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

@LoMo part of fixing a bug it also to work out if we can prevent causing it again. That can mean adding automated tests or reconfiguring something. In this instance it is configuring something that is missing.

LoMo’s picture

@alexpott I understand your point. And shouldn't the other issue tackle the "prevention issue" (and take further diagnosis from those with the power to do anything about it). I think this issue could just be resolved as something now patched in core, without any need for others to run into issues with those files. As we see from the issue description, this issue was created because those files were causing problems.

The "root issue" is, afaik, something that can only be managed by a few d.o. infrastructure admins (I'm thinking maybe I should have created it in https://www.drupal.org/project/issues/infrastructure, but not sure, since I found the "Project/Git problem" component in the d.o. Webmasters project). But creating that as a separate task ensures that it gets handled. Since it seems commits like that are not happening very often (or there would be a lot more than two files that have this issue—both of these files were in one patch committed quite some time back (25e7311c (webchick 2016-08-31 12:16:46), btw, so I really think this is an "edge case" which may only affect .svg and/or related files), I think it's safe to get this one closed and leave #2875025: Add code sniffs for line endings / SVG open for whenever d.o. admins have time to deal with sussing out a solution for future prevention.

In short: Since this issue is causing current headaches for people deploying D8-based systems, on a regular basis and has been open for 5 months (of the 8 months those files have been in core), and the "root issue" is something that seems to only have happened once in thousands of commits to D8 core, I think THIS issue is somewhat more critical and time-sensitive and the "root cause" issue can wait (probably with no ill ramifications). IMHO, setting this issue to "Needs work" doesn't do anything useful, produces distraction for people attempting to contribute (who can do nothing about the needed work) and fails to address the more immediate needs of the community (that core has some problematic files). I'm not going to set this back to RTBC since my intention is not to annoy you (and I think that might ;-) ), but I'm wondering if you might have missed the part about "These cause problems when you commit Drupal to a Git repo..." in the issue description?

idebr’s picture

Title: Bad SVG line endings » Two SVG icons have crlf line endings
Status: Needs work » Needs review
FileSize
881 bytes
3.77 KB

Attached patch implements the following changes compared to #2, see interdiff-2-11.txt:

  1. Apply git configuration through .gitattributes for *.svg based on the *.xml available in the same file, so future svg files will be added with the correct line endings per the suggestion in #2

@LoMo I understand your wish to further the Drupal project, but let's leave the executive calls to the core committers. If they agree a bug has not been fully resolved, let's work together to finish up the patch.

LoMo’s picture

Status: Needs review » Reviewed & tested by the community

Yeah... That should do it. :-) Thank you, @idebr.

@idebr And you're right. In this case, I really thought that the d.o. central repo needed tweaks that couldn't be made from "our end" and that that might mean this issue just stayed open till it got attention for those fixes. My mistake. (The page linked by @chi was related to the .gitconfig file, so I was confused by his reference to the .gitattributes file, which I didn't actually realize was part of the repo we can fix—in this case, I really thought we would be waiting for a d.o sysadmin to make some changes outside of the project.) In my defense, I haven't been doing much with Drupal 8 in some time, so I'm back on the "learning curve" when it comes to understanding the project architecture.

When I've had time, over the years, I've tried to help review patches that had been stuck open for a long time (like this one) and sometimes it's frustrating to me when I spend time on such issues, verify that a patch works and achieves the stated goal, mark them RTBC, and then see them kept open, often for additional years, due to "scope creep" and endless discussion that carries on till no patch still even applies and everyone who originally put so much effort into it has completely lost interest (or no longer had time, as has usually been my case) in dealing with the task. There are so many such issues and it's a source of frustration for me, perhaps especially since reviewing patches is a somewhat "selfless" task in that reviewers often need to do a fair bit to understand and replicate the issue, verify the fix, etc (and only very rarely get any credit for that work). I don't do it for the "credit" but I like to see issues get resolved and see related tickets get created rather than seeing patches bloat to cover the whole project, start getting in conflict with other patches, and require endless re-rolls. I guess my experiences with that kind of thing made me think that this was just another case of "scope creep" blocking an issue. But you are right. In this case, I just misunderstood the remaining task and didn't realize how simple it could be. ;-) Again, my mistake, and thanks for sorting out that last bit that, I hope, can allow this to be closed.

Gábor Hojtsy’s picture

Are all the added code rules apply to svg? (I genuinely cannot tell).

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs review
alexpott’s picture

Status: Needs review » Reviewed & tested by the community

@Gábor Hojtsy yep that's what the *.svg at the start of the line is indicating.

Gábor Hojtsy’s picture

Well, what I meant is do we want 2 space indents in svg, etc? I guess we do then.

alexpott’s picture

@Gábor Hojtsy ah good point. I think it is valid to have the same format as xml for example. They are very similar. It uses the same DOM where possible as HTML... and

Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium (W3C) since 1999. SVG images and their behaviors are defined in XML text files.

https://en.wikipedia.org/wiki/Scalable_Vector_Graphics

LoMo’s picture

Status: Reviewed & tested by the community » Needs review

Re #16 Probably not. That would certainly be inconsistent with any other .svg file committed and, while I don't think it would cause any issues... I think you are right. .svg should probably have a slightly different setting than other .xml files.

Gábor Hojtsy’s picture

Also whatever code style configuration we have, we need to ensure that the existing SVGs match that, not just in terms of line ending then, which would be important to check before / in case we commit rules that contradict existing files :)

alexpott’s picture

A single line svg does not contradict the rule as far as I can see. As far as I know all core .svg should be on a single line. But they are not... Here's a line count per file...

> find ./ -name *.svg | xargs wc -l
       8 .//misc/feed.svg
       1 .//misc/icons/000000/barchart.svg
       1 .//misc/icons/000000/chevron-left.svg
       2 .//misc/icons/000000/chevron-right.svg
       1 .//misc/icons/000000/ex.svg
       1 .//misc/icons/000000/file.svg
       1 .//misc/icons/000000/move.svg
       1 .//misc/icons/000000/orgchart.svg
       1 .//misc/icons/000000/paintbrush.svg
       1 .//misc/icons/000000/people.svg
       1 .//misc/icons/000000/puzzlepiece.svg
       1 .//misc/icons/000000/questionmark-disc.svg
       1 .//misc/icons/000000/wrench.svg
       1 .//misc/icons/004875/twistie-down.svg
       1 .//misc/icons/004875/twistie-up.svg
       1 .//misc/icons/0074bd/chevron-left.svg
       1 .//misc/icons/0074bd/chevron-right.svg
       1 .//misc/icons/008ee6/twistie-down.svg
       1 .//misc/icons/008ee6/twistie-up.svg
       1 .//misc/icons/333333/caret-down.svg
       1 .//misc/icons/424242/loupe.svg
       1 .//misc/icons/505050/loupe.svg
       1 .//misc/icons/5181c6/chevron-disc-down.svg
       1 .//misc/icons/5181c6/chevron-disc-up.svg
       1 .//misc/icons/5181c6/pencil.svg
       1 .//misc/icons/5181c6/twistie-down.svg
       1 .//misc/icons/5181c6/twistie-up.svg
       0 .//misc/icons/73b355/check.svg
       1 .//misc/icons/787878/barchart.svg
       1 .//misc/icons/787878/chevron-disc-down.svg
       1 .//misc/icons/787878/chevron-disc-up.svg
       1 .//misc/icons/787878/cog.svg
       1 .//misc/icons/787878/ex.svg
       1 .//misc/icons/787878/file.svg
       1 .//misc/icons/787878/key.svg
       1 .//misc/icons/787878/move.svg
       1 .//misc/icons/787878/orgchart.svg
       1 .//misc/icons/787878/paintbrush.svg
       1 .//misc/icons/787878/pencil.svg
       1 .//misc/icons/787878/people.svg
       1 .//misc/icons/787878/plus.svg
       1 .//misc/icons/787878/push-left.svg
       1 .//misc/icons/787878/push-right.svg
       1 .//misc/icons/787878/push-up.svg
       1 .//misc/icons/787878/puzzlepiece.svg
       1 .//misc/icons/787878/questionmark-disc.svg
       1 .//misc/icons/787878/twistie-down.svg
       1 .//misc/icons/787878/twistie-up.svg
       1 .//misc/icons/787878/wrench.svg
       1 .//misc/icons/bebebe/chevron-disc-left.svg
       1 .//misc/icons/bebebe/chevron-disc-right.svg
       1 .//misc/icons/bebebe/cog.svg
       1 .//misc/icons/bebebe/ex.svg
       1 .//misc/icons/bebebe/hamburger.svg
       1 .//misc/icons/bebebe/house.svg
       1 .//misc/icons/bebebe/key.svg
       1 .//misc/icons/bebebe/move.svg
       1 .//misc/icons/bebebe/pencil.svg
       1 .//misc/icons/bebebe/person.svg
       1 .//misc/icons/bebebe/plus.svg
       1 .//misc/icons/bebebe/push-left.svg
       1 .//misc/icons/bebebe/push-right.svg
       1 .//misc/icons/bebebe/push-up.svg
       1 .//misc/icons/bebebe/questionmark-disc.svg
       1 .//misc/icons/bebebe/star-empty.svg
       1 .//misc/icons/bebebe/star.svg
       0 .//misc/icons/e29700/warning.svg
       1 .//misc/icons/e32700/error.svg
       1 .//misc/icons/ee0000/required.svg
       1 .//misc/icons/ffffff/ex.svg
       1 .//misc/icons/ffffff/hamburger.svg
       1 .//misc/icons/ffffff/house.svg
       1 .//misc/icons/ffffff/pencil.svg
       1 .//misc/icons/ffffff/person.svg
       1 .//misc/icons/ffffff/questionmark-disc.svg
       1 .//misc/icons/ffffff/star-empty.svg
       1 .//misc/icons/ffffff/star.svg
       1 .//misc/icons/ffffff/twistie-down.svg
       1 .//misc/icons/ffffff/twistie-up.svg
       1 .//modules/block_place/icons/bebebe/place-block.svg
       1 .//modules/block_place/icons/ffffff/place-block.svg
       4 .//modules/image/images/error.svg
       4 .//modules/image/images/upload.svg
      19 .//modules/shortcut/images/favstar-rtl.svg
       0 .//modules/shortcut/images/favstar.svg
       1 .//themes/bartik/images/required.svg
       1 .//themes/bartik/logo.svg
       1 .//themes/classy/logo.svg
       3 .//themes/seven/images/icons/cccccc/clock.svg
       6 .//themes/seven/images/icons/cccccc/d8-logo.svg
       6 .//themes/seven/images/icons/cccccc/database.svg
       7 .//themes/seven/images/icons/cccccc/php-logo.svg
       3 .//themes/seven/images/icons/cccccc/server.svg
       1 .//themes/seven/logo.svg
       8 .//themes/stable/images/core/feed.svg
       1 .//themes/stable/images/core/icons/000000/barchart.svg
       1 .//themes/stable/images/core/icons/000000/chevron-left.svg
       2 .//themes/stable/images/core/icons/000000/chevron-right.svg
       1 .//themes/stable/images/core/icons/000000/ex.svg
       1 .//themes/stable/images/core/icons/000000/file.svg
       1 .//themes/stable/images/core/icons/000000/move.svg
       1 .//themes/stable/images/core/icons/000000/orgchart.svg
       1 .//themes/stable/images/core/icons/000000/paintbrush.svg
       1 .//themes/stable/images/core/icons/000000/people.svg
       1 .//themes/stable/images/core/icons/000000/puzzlepiece.svg
       1 .//themes/stable/images/core/icons/000000/questionmark-disc.svg
       1 .//themes/stable/images/core/icons/000000/wrench.svg
       1 .//themes/stable/images/core/icons/004875/twistie-down.svg
       1 .//themes/stable/images/core/icons/004875/twistie-up.svg
       1 .//themes/stable/images/core/icons/0074bd/chevron-left.svg
       1 .//themes/stable/images/core/icons/0074bd/chevron-right.svg
       1 .//themes/stable/images/core/icons/008ee6/twistie-down.svg
       1 .//themes/stable/images/core/icons/008ee6/twistie-up.svg
       1 .//themes/stable/images/core/icons/333333/caret-down.svg
       1 .//themes/stable/images/core/icons/424242/loupe.svg
       1 .//themes/stable/images/core/icons/505050/loupe.svg
       1 .//themes/stable/images/core/icons/5181c6/chevron-disc-down.svg
       1 .//themes/stable/images/core/icons/5181c6/chevron-disc-up.svg
       1 .//themes/stable/images/core/icons/5181c6/pencil.svg
       1 .//themes/stable/images/core/icons/5181c6/twistie-down.svg
       1 .//themes/stable/images/core/icons/5181c6/twistie-up.svg
       0 .//themes/stable/images/core/icons/73b355/check.svg
       1 .//themes/stable/images/core/icons/787878/barchart.svg
       1 .//themes/stable/images/core/icons/787878/chevron-disc-down.svg
       1 .//themes/stable/images/core/icons/787878/chevron-disc-up.svg
       1 .//themes/stable/images/core/icons/787878/cog.svg
       1 .//themes/stable/images/core/icons/787878/ex.svg
       1 .//themes/stable/images/core/icons/787878/file.svg
       1 .//themes/stable/images/core/icons/787878/key.svg
       1 .//themes/stable/images/core/icons/787878/move.svg
       1 .//themes/stable/images/core/icons/787878/orgchart.svg
       1 .//themes/stable/images/core/icons/787878/paintbrush.svg
       1 .//themes/stable/images/core/icons/787878/pencil.svg
       1 .//themes/stable/images/core/icons/787878/people.svg
       1 .//themes/stable/images/core/icons/787878/push-left.svg
       1 .//themes/stable/images/core/icons/787878/push-right.svg
       1 .//themes/stable/images/core/icons/787878/push-up.svg
       1 .//themes/stable/images/core/icons/787878/puzzlepiece.svg
       1 .//themes/stable/images/core/icons/787878/questionmark-disc.svg
       1 .//themes/stable/images/core/icons/787878/twistie-down.svg
       1 .//themes/stable/images/core/icons/787878/twistie-up.svg
       1 .//themes/stable/images/core/icons/787878/wrench.svg
       1 .//themes/stable/images/core/icons/bebebe/chevron-disc-left.svg
       1 .//themes/stable/images/core/icons/bebebe/chevron-disc-right.svg
       1 .//themes/stable/images/core/icons/bebebe/cog.svg
       1 .//themes/stable/images/core/icons/bebebe/ex.svg
       1 .//themes/stable/images/core/icons/bebebe/hamburger.svg
       1 .//themes/stable/images/core/icons/bebebe/house.svg
       1 .//themes/stable/images/core/icons/bebebe/key.svg
       1 .//themes/stable/images/core/icons/bebebe/move.svg
       1 .//themes/stable/images/core/icons/bebebe/pencil.svg
       1 .//themes/stable/images/core/icons/bebebe/person.svg
       1 .//themes/stable/images/core/icons/bebebe/push-left.svg
       1 .//themes/stable/images/core/icons/bebebe/push-right.svg
       1 .//themes/stable/images/core/icons/bebebe/push-up.svg
       1 .//themes/stable/images/core/icons/bebebe/questionmark-disc.svg
       1 .//themes/stable/images/core/icons/bebebe/star-empty.svg
       1 .//themes/stable/images/core/icons/bebebe/star.svg
       0 .//themes/stable/images/core/icons/e29700/warning.svg
       1 .//themes/stable/images/core/icons/e32700/error.svg
       1 .//themes/stable/images/core/icons/ee0000/required.svg
       1 .//themes/stable/images/core/icons/ffffff/ex.svg
       1 .//themes/stable/images/core/icons/ffffff/hamburger.svg
       1 .//themes/stable/images/core/icons/ffffff/house.svg
       1 .//themes/stable/images/core/icons/ffffff/pencil.svg
       1 .//themes/stable/images/core/icons/ffffff/person.svg
       1 .//themes/stable/images/core/icons/ffffff/questionmark-disc.svg
       1 .//themes/stable/images/core/icons/ffffff/star-empty.svg
       1 .//themes/stable/images/core/icons/ffffff/star.svg
       1 .//themes/stable/images/core/icons/ffffff/twistie-down.svg
       1 .//themes/stable/images/core/icons/ffffff/twistie-up.svg
       4 .//themes/stable/images/image/error.svg
       4 .//themes/stable/images/image/upload.svg
      19 .//themes/stable/images/shortcut/favstar-rtl.svg
       0 .//themes/stable/images/shortcut/favstar.svg
       1 .//themes/stark/logo.svg
alexpott’s picture

Also note that .gitattributes does not define coding standards. The tabwidth=2 is an instruction for diffing not for what is in the file. That's a separate issue. So in my mind this issue is still rtbc because the eol=lf ensures that the end of lines will just be line feeds.

alexpott’s picture

So here's a way to fix and ensure we are compliant.

  1. create a new branch
  2. run find ./core -name *.svg | xargs rm
  3. commit
  4. Create a patch of diff from new branch to 8.4.x -> this will be a patch that adds all the svg back in.
  5. add the .gitattributes rule
  6. Apply the patch.
git apply ../all.svg.patch --whitespace=error-all
../all.svg.patch:295: trailing whitespace.
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px"><path fill="#787878" d="M0.656,9.023c0,0.274,0.224,0.5,0.499,0.5l4.853,0.001c0.274-0.001,0.501,0.226,0.5,0.5l0.001,4.853 c-0.001,0.273,0.227,0.5,0.501,0.5l1.995-0.009c0.273-0.003,0.497-0.229,0.5-0.503l0.002-4.806c0-0.272,0.228-0.5,0.499-0.502 l4.831-0.021c0.271-0.005,0.497-0.23,0.501-0.502l0.008-1.998c0-0.276-0.225-0.5-0.499-0.5l-4.852,0c-0.275,0-0.502-0.228-0.501-0.5 L9.493,1.184c0-0.275-0.225-0.499-0.5-0.499L6.997,0.693C6.722,0.694,6.496,0.92,6.495,1.195L6.476,6.026 c-0.001,0.274-0.227,0.5-0.501,0.5L1.167,6.525C0.892,6.526,0.665,6.752,0.665,7.026L0.656,9.023z"/></svg>
../all.svg.patch:428: trailing whitespace.
<svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px"><path fill="#bebebe" d="M0.656,9.023c0,0.274,0.224,0.5,0.499,0.5l4.853,0.001c0.274-0.001,0.501,0.226,0.5,0.5l0.001,4.853 c-0.001,0.273,0.227,0.5,0.501,0.5l1.995-0.009c0.273-0.003,0.497-0.229,0.5-0.503l0.002-4.806c0-0.272,0.228-0.5,0.499-0.502 l4.831-0.021c0.271-0.005,0.497-0.23,0.501-0.502l0.008-1.998c0-0.276-0.225-0.5-0.499-0.5l-4.852,0c-0.275,0-0.502-0.228-0.501-0.5 L9.493,1.184c0-0.275-0.225-0.499-0.5-0.499L6.997,0.693C6.722,0.694,6.496,0.92,6.495,1.195L6.476,6.026 c-0.001,0.274-0.227,0.5-0.501,0.5L1.167,6.525C0.892,6.526,0.665,6.752,0.665,7.026L0.656,9.023z"/></svg>
fatal: 2 lines add whitespace errors.
alexpott’s picture

A patch created by then doing git apply ../all.svg.patch --whitespace=fix ... results in exactly the same patch as #11.

idebr’s picture

Re #16

Well, what I meant is do we want 2 space indents in svg, etc? I guess we do then.

and #20

As far as I know all core .svg should be on a single line.

There is an effort the decide on svg guidelines / formatting in #2433761: [meta] svg guidelines / requirements. I would like to suggest to create a child issue for #2433761: [meta] svg guidelines / requirements once we decide on coding standards for svg to reformat historical files.

LoMo’s picture

Status: Needs review » Reviewed & tested by the community

Anyway, #23 is the same as before, so I guess we are safe with these settings as far as fixing the CLRF issue. And it looks like the SVG guidelines should help ensure that such files are consistently formatted in future. Getting this patch in will make sure that CLRF line endings aren't committed for any of them, either, so let's just get this committed. ;-)

  • catch committed eb67b8d on 8.4.x
    Issue #2831598 by idebr, alexpott, Dane Powell, LoMo: Two SVG icons have...

  • catch committed c4d9289 on 8.3.x
    Issue #2831598 by idebr, alexpott, Dane Powell, LoMo: Two SVG icons have...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.4.x and cherry-picked to 8.3.x. Thanks! Added reviewer credit for LoMo.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.