Hacker News new | ask | show | jobs
by ffjffsfr 1781 days ago
how is git log -S more efficient? You have to write whole line, what if line is long? What if you need to look at several lines within some range. git blame is much better than your git log -S
2 comments

git blame can't possibly work well in all cases, which is why the author is saying that.

Git doesn't store what actually was changed. Git stores how to reconstruct the new file from the old file in a space efficient way.

This is unrelated to storage of who changed what, only "what is the minimal way to reproduce the end state from the beginning state".

As a result, tools like blame take the two versions and try to figure out what someone actually changed, trying to turn applesauce back into apples.

Whether it gets it right or not has an element of luck to it (the diff algorithms are also often based on finding the minimal sequence of edits.). Whether it happens depends on the algorithm and it's heuristics, and often whether there is a single unique minimal sequences that could produce your end state from your beginning state (if not, it's not actually possible to say what you changed with 100% accuracy)

git log -S instead is saying "give me all the times this line seems to have changed", and then you do the work of figuring out which were real and which are artifacts of the diff algorithm.

It doesn't have to be that detailed or bullet-proof to be good enough for like 90% of cases.
I actually don't have a strong opinion, i'm just responding to the comment about why they suggest what they suggest.
you... copy and paste it?