Search code examples
gitgit-log

Why git do not take into account changes at working tree?


I run the command:

git log --topo-order -u -L 228,250:"lib/Mojolicious/Plugin/Wizard.pm"

To inspect changes at the start subroutine, but git do not take into account changes in working tree.

enter image description here

It seems I should supply lines as they are in last commit:

git stash save
git log --topo-order -u -L 212,234:"lib/Mojolicious/Plugin/Wizard.pm"

enter image description here

After that I can restore stash. And command still works (just lines in editor are different. See first picture):

git stash pop
git log --topo-order -u -L 212,234:"lib/Mojolicious/Plugin/Wizard.pm"

Is there an option that will show evolution for lines that are not committed yet?


Solution

  • Apparently the question is why git logs -L option doesn't show differences that are not committed.

    The simple answer is that git log shows information from the commit logs, and until you commit (or stash) your changes there is no information about those changes in the commit logs.

    In comments you say that an uncommitted change is still an evolution of the file. Well, ok, but git log traces the evolution of the specified lines through the commit logs. Maybe that's not as useful to you, or doesn't meet your definition of what git "should" do, but it is what git does.

    So is the point to debate git's design choices, or make a feature request of git? Not much use doing that in an SO question.

    If you want a work-around... Making a stash is probably as simple a solution as you'll get, assuming it's working for you. I guess you could write a script to make the stash, run the log command, and pop the stash (or otherwise create "temporary" commits representing your uncommitted changes) to save the couple commands' worth of typing