Michael A. Covington    Michael A. Covington, Ph.D.
Books by Michael Covington
Previous months
About this notebook
Search site or Web

Daily Notebook

Popular topics on this page:
My YouTube début
Git, Visual Studio, and line endings

This web site is protected by copyright law. Reusing pictures or text requires permission from the author.
For more topics, scroll down, press Ctrl-F to search the page, or check previous months.
For the latest edition of this page at any time, create a link to "www.covingtoninnovations.com/michael/blog"

Ads by Google, based on your browsing history

Git, Visual Studio, and line-ending warnings

Periodically, Visual Studio has been telling me the end-of-line marks in a file I'm editing are inconsistent. On looking closer I have also found that Git, my source code management system, has been thinking large parts of a file have been changed when I couldn't see any difference.

Mystery solved.

As most computer geeks know, the lines of a text file end with LF (hex 0A) in Unix and with CRLF (hex 0D 0A) in Windows (and DOS before it). These correspond to carriage return and line feed on a teletype. The thinking back in the 1970s was that UNIX would use a single character for end-of-line, but Windows chose to use the pair of characters that are actually transmitted to a printer at the end of a line. One saves space, the other saves work.

Git caters for both UNIX and Windows and assumes the same file may be edited under both. What's more, some newer Windows editors have the option of ending lines just with LF. This option can be set accidentally, of course, and then you create files in a format you didn't intend.

And, worse, Visual Studio applies its currently set mode (LF or CRLF) to newly added material in a file, but not to material already there. Thus you can create a file with inconsistent line endings, which Visual Studio will later complain about. (This has supposedly been reported as a bug, and fixed, but I don't think it's gone.)

Although the problem isn't Git's fault, Git contributed to my woes and then helped me clean up the mess.

If you tell it to, Git will normalize line endings so that they are always stored as LF in the remote repository and always converted to what your OS uses (LF or CRLF) when you pull (download) the files.

And I had Git set up to do this on one computer and not two others. So I created CRLF files, pushed them to Github translating CRLF to LF, and then pulled them down on another computer that wasn't translating back. That gave me a lot of files with LF line endings, which Visual Studio edited without complaining, until eventually some CRLF material got inserted into them. That made Visual Studio complain. And the overall mixing up of CRLF with LF made various Git tools think files had undergone large-scale changes when they hadn't.

Here's how to solve it. I'll cast this as instructions to be followed, rather than a narrative of what I did.

To find out how Git is set up on your computer:

git config --global --list

If the output of that command does not include core.autocrlf=true, I strongly recommend making that global setting, which you can do with the command:

git config --global core.autocrlf true

That may be all you need to do, on every computer on which you use Git. There's a way to put the setting into the repository rather than the computer, and I'll git to, I mean get to that. But first...

After changing the setting, you'd probably like to renormalize all your files — that is, get all their line endings into the canonical form now. That will make almost all the files seem to undergo big changes just this once, and then the problem will no longer raise its ugly head. Here's how to do that:

(1) cd to the root folder of your local copy of the repository.

(2) git add --renormalize .   (don't forget the dot at the end)

(3) git status   (to see what happened)

(4) Commit your newly renormalized files, and push to the remote repository.

(5) Don't just pull from the repository. Delete or rename your local copy of the repository, and clone (download) a fresh copy. That's the only way you'll get the new versions of all the files!

Now then. Maybe you'd like to store these settings in the repository itself, to override the settings of any individual computers. And maybe you'd like to be more explicit about what kinds of files are to be handled how.

To do that, make a file called .gitattributes and store it in the root folder of the local repository (alongside .gitignore, which is probably already there). Commit and push it to the remote repository. The next time anybody pulls the same branch of the same repository, that file will be downloaded, and whenever they work on that repository, the settings in the file will be in effect.

Here is what is in my .gitattributes file:

# .gitattributes file

# Make GIT normalize all text files to have LF line endings internally
# and CRLF line endings when downloaded into Windows.
# This is often the default behavior, but sometimes git installs with something else selected.

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Since we are only using Windows, the distinction between the next
# two categories is largely moot...

# Explicitly declare text files you want to always be normalized and converted
# to native line endings (CRLF for Windows) on checkout.
*.cs text
*.txt text
*.csproj text
*.xaml text
*.xml text
*.json text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
*.csproj text eol=crlf
*.xaml text eol=crlf

# Declare some common file types that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.pdf binary

# In general, git is good at recognizing other binary files.

For more about this, see https://www.gloomycorner.com/line-ending-configuration-in-git/.


It sinks in

What I posted on Facebook yesterday morning:

Thought for the day: Please be angrier at enemy attackers than at your fellow citizens.

Don't forget the seriousness of what happened on January 6; admit that you're disappointed if you have supported Trump's platform; and don't follow people into fantasyland about the supposedly "stolen" election.

People want you to ignore the seriousness of what happened on January 6. As more information comes out, we're realizing we may have come within an inch of having the Vice President assassinated and the Capitol burned down. It was not a peaceful march infiltrated by provocateurs. The attackers considered themselves Trump supporters and intended to overturn the election by force. They left plenty of evidence. If Arab terrorists had done that, we'd be bombing somebody by now.

People don't want you to realize how disappointed you are with Trump. Six months ago, a lot of people supported him simply because he was the conservative candidate, and despite his quirks, he seemed better than the alternative. If that's you, it does not obligate you to follow him everywhere he goes. You can get off his bandwagon.

People want you to ignore what provoked the attack. Trump ordered Pence to overturn the electoral vote. When he refused, the Capitol was attacked. Prior to that, there was an unprecedented effort to overturn state elections due to minor irregularities that almost certainly didn't affect the outcome; Trump had lost the Electoral College; Trump had lost the popular vote; and Trump had never had an approval rating higher than 50%. He was not the choice of the American people. A special-interest group was determined to put him in power anyway.

Some people want you to ignore all that, and instead complain about the clumsy things Internet companies did to keep from being used to organize more violence. Of course they were clumsy. In the long run we want fairer policies from social media companies, and a larger number of competing companies. But don't forget why the issue came up, or the danger we have been in!

There is further violence threatened for the days just before the inauguration. This is not a game.


An attack on the United States


[Minor updates January 8, 9, and 10.]

I fly this flag to show my loyalty to the United States and its legitimate constitutional government, not any individual, movement, or group within it.

What can I write when there has just been a coup attempt in the United States? This is something that was never supposed to happen. Fortunately, it failed. Unfortunately, the cleanup is going to take a long time. I mean cleaning up misguided minds and delusional beliefs, not just broken glass.

Yesterday afternoon, a mob of attackers invaded the Capitol in order to disrupt the tallying of electoral votes and somehow "stop the steal" and give a second term to Trump even though he lost the election.

They share the delusional belief, promoted by Trump, that he really won the election even though, in dozens of courtrooms and the halls of Congress, he has presented no evidence that that is so. During his Saturday phone call to pressure Georgia to "find" 11,780 more votes, he further said he had "won in all 50 states," clearly false and not, so far, claimed by anyone. Yesterday, Vice President Pence had to tell Trump emphatically that he was not empowered to simply change the electoral votes, as Trump had been asking him to do.

This was the first violent attack on the Capitol since the War of 1812. Members of Congress were evacuated; people in the line of succession to the presidency were evacuated separately to an undisclosed location; attackers swarmed into the building and looted it; and Capitol Police, not numerous or heavily armed, did their best. There were four deaths, one apparently an attacker who was shot when she charged at a police officer, and three "medical emergencies" (no further details). [Update: Two bombs were reportedly found and defused. This could have been much uglier than it was.]

The whole nation is aghast. Most of us are upset at several things:

  • Trump and his personal lawyer Giuliani incited the attack. For some time Trump had been encouraging protesters to come to Washington on the day of tallying and somehow make their will known. He welcomed this group. Just before the violence, Giuliani told the protesters to pursue "trial by combat." After it started, Trump would not clearly condemn the attackers — he said things that continued to encourage and inflame them — and, in a long-overdue victory for civilization, he was finally banned from Twitter.
  • The attackers got in surprisingly easily and were treated with surprising leniency. Only a few were arrested. In the civil rights riots last summer, protesters who were doing much less damage were treated much more harshly. This time, it looked as if the defenses of the Capitol might have deliberately been lowered, as if the attackers were being protected for political reasons.
  • The whole episode was tinged with fantasy and delusion. The chief claim, that the election was "stolen," was never backed up with evidence. But it gets stranger. Quite a few of the attackers were dressed like cosplayers at a fantasy convention; one who occupied the Senate dais was dressed as a buffalo. [Update: Buffalo Man has been identified and arrested; he does not even conceal his identity.] Do these people draw any line between reality and imagination? Do they think that if they mix it with game play, their treasonous attack isn't real?
  • Although almost all Americans deplore the attack, a few still seem to be in this on the wrong side. Trumpism all along has been about loyalty to the man rather than a set of political positions; there are still people who can't make the mental distinction between supporting Trump's platform and supporting a violent attack on the Capitol.

To my delight, Congress re-convened and worked until 4 a.m. tallying the votes. (I listened to them until 2 a.m.; I had never watched this kind of history being made before.) Some members still wasted time making a show of challenging the legitimacy of electoral votes in Pennsylvania, but all they alleged was some inconsistency in the process — not forgery of the actual votes. Still, this, to me, still smacked of a common Trumpist attitude: if you can't prove it, just imagine it and say it, and that supposedly makes it true.

The sun rose this morning on a nation still at peace, with Biden certified as president-elect and a commitment from Trump to an orderly transition of power, even though he still maintains the election was "stolen."

But that's not enough. We can't have two more weeks of this. Discussions are in progress of ways of removing Trump from office. One option is to invoke the 25th Amendment and certify him disabled by mental illness. That requires the consent of the Vice President and a majority of the Cabinet. It depends mostly on Vice President Pence, and after yesterday's friction between Trump and Pence, he might to along with it. Another option is a very quick impeachment, but that's hard to do quickly enough, nor is there a provision for arresting the president before trial.

I think we have exposed a gap in our laws, and we need a more expeditious way of dealing with a president suddenly and dramatically violating his oath of office. We never expected to have one.

We also must deal with the attackers. Why should they get off any more lightly than if they had come from al-Qaeda or some other hostile power? Track them down, arrest them, and charge them with the most serious crimes that the evidence warrants. Tracking them down should be easy, as they were photographed in the act and are probably bragging about it on social media right now.




The holidays have helped me get around to modernizing my workshop, and one thing I've done — a bit sadly — was to sell most of the 1960s-era test equipment that I bought in the 1980s and 1990s. There are two reasons:

  • What used to be old-but-reliable instruments have turned into failure-prone antiques requiring careful care. In the past I've enjoyed fixing up old test equipment, but I don't expect to have time for much of that in the foreseeable future, and more importantly, what would I use for reliable test equipment while doing it?
  • The price-performance ratio for old and new equipment has inverted. In 1990, secondhand older equipment gave you most of the performance for a tiny fraction of full price. Nowadays, newer equipment is not only better, it's cheaper.

So some modernization is coming, and I'll blog about it. I'm not getting out of antique electronics altogether — I still keep up some old radios and a couple of test instruments — but I'm glad to be regaining the space. As you will soon see, the largest instrument in the picture, the Tek 575 curve tracer, will be replaced by a gadget that fits in the palm of my hand.

Above, you see the equipment I sold on January 2. For privacy, the purchaser's face is not shown. The old oscilloscope on the left was a parts donor, useful for maintaining the Tek 575 in the middle.

My YouTube channel

I've started a YouTube channel. [The name of the channel is "Michael A. Covington (Covington Innovations)," as there are several Michael Covingtons out there; I hope this doesn't confuse anyone.] It's going to have videos on a great variety of subjects, but right now, there's only one, about a light-sensitive transistor from the 1960s and a demonstration of testing it on the Tek 575.

A new golden age of television?

As Tom Scott recently pointed out, the days of high-budget television production are long gone. Fifty years ago, you could get millions of people to watch the same network TV special at the same time; this made its advertising income and thus its production budget enormous. Not any more. That's one reason for the proliferation of "reality TV," which is cheap to produce. Of course, other kinds of TV are are still made, and production costs have come down; we still have a steady supply, but no extravaganzas.

But I never liked TV that much anyhow. Until YouTube came along. Now video has an entirely new use — sharing any knowledge that involves demonstration by video in real time. Video is how you can show people what it looks like to do something with tools, crafts, or special equipment, and I've found amateur YouTube videos very useful for that purpose. I've been enjoying EEVBLOG (electronics), AstroStace and AmyAstro (amateur astronomy), and many other YouTube channels.

Because they don't have to fit a schedule, YouTube videos don't have to be any particular length; this favors conciseness. "Get to the point, get to the point, and get to the point" — my three rules for clear communication.

YouTube is very good at matching people with things they'd like to see. It has a wealth of content combined with a good search engine. If you want to know how to change the taillight on a 2012 Ford Escape, you can quickly find a YouTube video of just that thing. Production quality ranges from good to poor, but the important thing is, it doesn't have to be studio-quality to get distributed. It just has to be something people want to see.

The other thing YouTube is good at is linking related videos. If you liked this one, you might like these others... Apparently, a good many people have been led to my transistor video because it has something in common with other videos they said they liked.

There are occasional flaky channels. Of course, political cranks and fake newscasts are common (they look like newscasts on major media but are actually total strangers). There is also stranger stuff. While going through engineering videos, I came across a series made in China with a nearly-naked female presenter. I didn't watch more than about ten seconds of that, so I don't know exactly where they were going, and, fortunately, YouTube allowed me to click on "Don't recommend this channel." Naturally, something almost identical immediately popped up under a different name, and I had to click on "Don't recommend this channel" a second time; then they stayed away.

If what you are looking for is not here, please look at previous months .