Programowanie

2 paź 2020

Znalazłem błąd w GIT - WAT? Loteria GIT

Znalazłem błąd w GIT - WAT? Loteria GIT

Znalazłem błąd w GIT - WAT? Loteria GIT

Sebastian Wilgosz

Ruby Developer

Liliowy Kwiat
Liliowy Kwiat
Liliowy Kwiat

Znalazłem błąd w GIT. Jakie jest prawdopodobieństwo, że to się stanie? Podaj mi dowolną loterię, a wciąż mogę argumentować, czy trudniej w niej wygrać. Oto jak to się stało...

Since I watched the Ruby/JS WAT? video, I always see it in front of my eyes, whenever I discover my personal WATs in all parts of my life. And I always want to write o nas them, so here is one such thing.

I've found a bug in GIT.

How likely is that to happen? Give me any lottery you can think of and still I can argue if it's harder to win in it or find a bug in GIT. Still - it happened to me and the funniest thing is, that it happened while working on a blog aplikacja. When I worked on it alone!

No big teams, merges, overriding history... nothing. Just basic features had been used there.

Here is how it happened...

For people who don't know the word WAT: It's a term describing a thing that shouldn't have a place. Something completely unexpected and non-intuitive.

React blog aplikacja

I wanted to rewrite my blog from Nuxt (Vue.js) to Next (React.js) to test a very weird behavior related to the Nuxt api proxy.

During the rozwój, I've realized, that I've named one of the component's files wrongly - Logo.js instead of logo.js. No big deal, one could say. Just rename it, commit changes and voila! You're ready to go.

However, not everything went so smoothly.

Module Not found

The continuous integration tool - in this case, it was a Now from Zeit firma - reported that the path to my logo component could not be found.

I was stunned. Ok, I expected that I have a typo somewhere in the import or the file name, but I haven't.

My components file list was very small and flat, there was no place for an error:

Components file list in Driggl's blog aplikacja

The same applied to the importing part, where I just needed to import the file from the same folders, when I had just this one-line responsible for importing the Logo component:

The weirdest thing was that actually everything worked locally, and it only crashed when deploying to production.

I was really confused until I've shown the code to my teammate. He had cloned the repository and we've realized, that the logo component file is named wrongly despite the fact I had no uncommited changes!

GIT has issues.

It was a really interesting discovery, that when I've checked the GIT mechanism, it'd shown me that GIT does not recognize renaming files when the only change you do in the file name is the letter's capitalization!

So basically, even though I had the logo file renamed, GIT'd never noticed it! I was looking like:

And here I am - WAT?

Try it yourself:

Then play with the file name a little bit:

Has anything changed for you?

Now try to reset the staged changes and check the status again:

Voila! The GIT magically recognized the file name!

Takeaways

This little doświadczenie taught me that everybody writes buggy code sometimes. We should never assume anything is perfect, as every little part of the oprogramowanie we use is written by a human. And humans can make mistakes.

And, if it comes to GIT, just always - ALWAYS do the review of your own changes.

I occasionally write o nas GIT hacks and tricks, but this one was the most interesting thing I've found in the last few lat.

✍️

O autorze

Sebastian Wilgosz

Ruby Developer

Entuzjasta Ruby, miłośnik kawy i maniak produktywności. Uwielbiam znajdować kreatywne sposoby na ulepszenie wszystkiego, co robię.

Masz pomysł na projekt? Porozmawiajmy i wspólnie go zrealizujmy.

Nasi wysoko wykwalifikowani specjaliści są do Twojej dyspozycji. Skontaktuj się z nami i przekonaj się, co możemy razem osiągnąć.

Dariusz Michalski

Dariusz Michalski, CEO

dariusz@useo.pl

Konrad Pochodaj

Konrad Pochodaj, CGO

konrad@useo.pl

Masz pomysł na projekt? Porozmawiajmy i wspólnie go zrealizujmy.

Nasi wysoko wykwalifikowani specjaliści są do Twojej dyspozycji. Skontaktuj się z nami i przekonaj się, co możemy razem osiągnąć.

Dariusz Michalski

Dariusz Michalski, CEO

dariusz@useo.pl

Konrad Pochodaj

Konrad Pochodaj, CGO

konrad@useo.pl

Masz pomysł na projekt? Porozmawiajmy i wspólnie go zrealizujmy.

Nasi wysoko wykwalifikowani specjaliści są do Twojej dyspozycji. Skontaktuj się z nami i przekonaj się, co możemy razem osiągnąć.

©2009 - 2025 Useo sp. z o.o.

Gdzie nas znaleźć

ul. Ofiar Oświęcimskich 17

50-069 Wrocław, Polska

ul. Ofiar Oświęcimskich 17

50-069 Wrocław, Polska

©2009 - 2025 Useo sp. z o.o.

Gdzie nas znaleźć

ul. Ofiar Oświęcimskich 17

50-069 Wrocław, Polska

ul. Ofiar Oświęcimskich 17

50-069 Wrocław, Polska

©2009 - 2025 Useo sp. z o.o.