This is a followup to another question I asked before.
Before being edited, the initially created file something
gets renamed to somethingelse
which can be observed here:
git mv something somethingelse
The file somethingelse
then gets renamed back to something
before the second vim edit:
git mv somethingelse something
Basically in the following portion of the code:
# If you add something to the first line, the rename will not be detected by Git
# However, if you instead create 2 newlines and fill line 3 with new code,
# the rename gets detected for whatever reason
printf "
COMMAND: vim something
"
vim something
If at this point I add abc
to the code, we would end up with:
First line of code. abc
Which I think is an addition of 4 bytes on line 1, which in turn will end up in this:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: something
deleted: somethingelse
Then, if we add a newline and type in abc into the third line (which should also be 4 bytes, correct me if wrong):
First line of code.
abc
Suddenly, Git will detect the rename (edit inclusive):
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: somethingelse -> something
One good answer/comment by @torek given here explains this to a certain extent, taking the git diff
rename detection treshold of git status
into consideration.
Shouldn't Git behave identically since we added 4 bytes in both cases, but in a different manner or does the newline have something to do with this?
See Question&Answers more detail:os