2

I'm curious if there's an easy way in Magit to see how a piece of code changes over time, i.e., with each commit.

I'd like to have one window open in Emacs, focusing on the code/function I want to see changes to, and another window (e.g., Magit log buffer or something) where, when I move up/down in the history of the file in the other window, I can see it evolve over time.

I've thought about this for a long time, but I've never been able to find it in the manual or even know what kind of keywords to look for. I hope I managed to explain it this time and someone out there understands what I'm talking about.

2 Answers 2

5

You can do this with vc or with magit:

  • C-xvh runs the command vc-region-history.

  • Using Magit, the equivalent command magit-log-buffer-file (l in the magit-file-dispatch menu; hence commonly it would be C-cM-gl).

With either of these commands you firstly mark a region you are interested in, and they then give you (in a single buffer) a history of that region: the sequence of commits which affected the region, and the diff for each of those changes.

As such, a useful prefix is often C-M-h which runs the command mark-defun.

1
  • Amazing, thank you SO MUCH! <3
    – troglobit
    Commented Feb 5, 2023 at 1:07
0

It’s not exactly what you describe, but there is magit-blame-addition.

1
  • Thanks, that's a nice function, but like you say. Not what I was looking for.
    – troglobit
    Commented Feb 5, 2023 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.