reddit / emacs

is there a Vim Fugitive style git blame?

masukomi · 2022-04-02 17:14
[Fugutive](https://github.com/tpope/vim-fugitive) is the Vim equivalent of Magit. The *one* thing that it has, that I'm really missing in emacs is its git blame Is there anything like this in emacs? Notable things about this screenshot (beyond the the obvious): the two viewports are synced, so if you scroll one the other scrolls. The one on the left actually has the \_full\_ git blame (showing the source code it's blaming) hidden off to the right. Not sure that last bit is useful. This visualization of git blame works WAY better for me than anything I've found yet. I'd \_love\_ it if one of you would say "oh, just use \_\_\_\_\_\_ package to get this." ;) https://preview.redd.it/hs2dmz91f5r81.png?width=2572&format=png&auto=webp&s=30f15e4f59dbe2a3edf690712becb92565a30064
snafuchs · 2022-04-02 18:36
Your screenshot is pretty much how magit-blame buffers look: https://magit.vc/manual/magit/Blaming.html
phmx · 2022-04-02 18:38
Try to cycle styles using "c" key binding while blaming.
masukomi · 2022-04-02 18:44
i dunno about you but I find the magit version *way* more difficult to parse. There isn't a 1:1 line comparison, having the _entire_ hash there is way more than i need, the hashes are all the same color, and the name of the person who made it is also the same color, and the date it was created is the same color. The comments really make things harder to read as well. [example screenshot will expire after 30 days](https://cln.sh/VE3xgF)
snafuchs · 2022-04-02 18:46
Huh, i don’t recall mine looking like that - maybe I customized the format. When I’m at the editor again, I’ll check if there’s something in my config.
mickeyp · 2022-04-02 19:32
Use `C-x v g`?
zajasu · 2022-04-02 19:58
This looks nice, but for some reason it creates additional window in which blaming is done. In addition, color highlighting in this window is broken. Is it possible to have blaming in the same window?
Nhaco · 2022-04-02 20:22
Don't know if it fills your need, but there is the blamer package: https://github.com/Artawower/blamer.el
redguardtoo · 2022-04-03 06:34
https://github.com/redguardtoo/vc-msg It does not have fancy UI but it provides some killer feature "If Git is used and partial of the line is selected, the correct commit for the selected text is displayed." Also check `magit-log-buffer-file` from Magit, "When the region is active, restrict the log to the lines that the region touches."
emax-gomax · 2022-04-03 10:03
``` c (magit-blame-cycle-style) This command changes how blame information is visualized in the current buffer by cycling through the styles specified using the option magit-blame-styles. ```
masukomi · 2022-04-03 15:54
appreciated, but to me, that's not even remotely the same thing. Even if we ignore the weird coloring in mine, there's no visual connection between the line in the blame because it's a horizontal split not a vertical split so the blame lines aren't visually connected to the lines they're blaming in your main editing panel. You have to mentally reconcile them. [example screenshot (will expire)](https://cleanshot-cloud-fra.s3.eu-central-1.amazonaws.com/media/5806/g5OKjCddtfNiZ0qx5Qdn9UrE4Bc4DyXjxezmyF3a.jpeg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEMj%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDGV1LWNlbnRyYWwtMSJIMEYCIQCc2s4geoZ21rd3LN1sNbZ%2FgrtgFJZUjkZATXm7YT85IwIhAIGPd2aVrG07iwi77aC6MavPzHQowkOi%2BUcu2r5JXJ99KqECCGEQABoMOTE5NTE0NDkxNjc0Igx7NM%2B7BsntyrQ1eOAq%2FgGiQCQ3S6Gemkpe%2FQuSFS9UAPG%2BJpobx4unZ6SS98AGJ2mIdya1EnR98NCFk%2F%2B%2FGjudqRli%2FUxALmPvBd36jG%2FEY5qyNLTLLmupUcyX5CxiPdR0zPYjC7j5ADt33gwz9ULvWVnc59ygGwDAd4EUbhcLFfn4YEGVYVBMMmfTjI675KUjyXZRYWPwn9MscHAmafoAH63Avlrvwb96V3dQjBtbGIdwrePdqKZ9PCznpTumE4KOLu5PKxpe53vR3YDerfA4GUPVJxGnw%2FzpbAMtUPT3dsid8QHS2Bq2noBWGLckPYw%2Ftmah7lOBkAHM7Tg8ajbT4SGuoCLPHr300uuB7TCjg6eSBjqZAQbbxZGvzYCwYFIEQdY3r0SgXm33cs61Xlm%2FfMA75GlrusTBNCb30%2FSUuencheT3D6CNyqcYcFI0SWyy0b5M5%2Bd%2BH%2Bo9ZoYEkjkeklNhxrST7%2FbV%2BsINVjokvU4lFoFpV2vtoePFX%2F4zRpcoslimMNjl3i4B%2FaMTXCWhqpo5ZkQZaVs6Yyq6r%2B2Tw8X149MJq37Ud%2Bts2%2Bt%2B%2BQ%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA5MF2VVMNEVVA55GM%2F20220403%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20220403T155248Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Signature=368139be1184f39a55971096f347a76c0f244d94170e9a59582531d10456d174)
masukomi · 2022-04-03 15:56
🤔 blamer is definitely cool, and i totally understand why someone would want that. What it doesn't do is let me see at a glance "oh, these 3 lines were from that commit, but those 2 were added later by Bob". I'm not sure if I'd want to run that normally, but I'm thinking there may be a good use for it.
masukomi · 2022-04-03 15:59
hmm. yeah, that is interesting. and ... being able to say the _specific_ subsection of a line is _very cool_. However, i can't think of a time where that's been particularly meaningful to me. The person who last touched the line, and when, is usually all i care about. Do you find that useful in a practical way, or is it just appreciation of geeky coolness? That being said, as i noted in another response, what it doesn't do is let me see at a glance "oh, these 3 lines were from that commit, but those 2 were added later by Bob".
masukomi · 2022-04-03 16:00
thanks, but as i noted above, the result is very different and not nearly as usable: [example screenshot (will expire)](https://cln.sh/VE3xgF)
masukomi · 2022-04-03 16:00
thanks, but as i noted above, the result is very different and not nearly as usable: [example screenshot (will expire)](https://cln.sh/VE3xgF)
by_wicker · 2022-04-03 17:16
With `vc-annotate` (`C-x v g`) your cursor will be on the same line you summoned it from which helps a lot with the cognitive reconciliation. It's definitely to be viewed in its own right, not alongside the editing buffer, but that workflow works well in my experience. It's something I dip into for forensic purposes, and not really something I want visible the rest of the time. `q` pops you back out. The coloring of it is a very useful visual indication of the age of the commits by lines redder for 'hotter' new changes through to blue for old ones. The mode has a bunch of other features like jumping to the commit before/at the line under the cursor etc., so is quite a rich and useful mode for actually navigating and understanding the history. But it's an old VC-agnostic feature that isn't the most polished or as git-aware as it could be. It would be nice to combine all these features into something richer. Much as I love magit in general, I find `magit-blame` very hard to parse and use compared to `vc-annotate`. There is certainly room for improvement. I can see that the shadow buffer option as you're showing could work well, but AFAIK it doesn't currently exist, and digging into `vc-annotate` is well worth your time, even if it has a different flavor. locking the scrolling of a vc-annotate buffer with the editing buffer, and moving the coloring to the commit info, seems like it would be reasonably doable for someone with a little Elisp skill, time and inclination. Sadly I don't have sufficient of any of those personally.
redguardtoo · 2022-04-04 03:17
In corp environment, the last committer of the line could be, - QA who approved the merge request. - A junior developer who accidently added extra trailing spaces They are usually not the person I want to "blame". For your specific requirement, check `magit-log-buffer-file`.
bravosierrasierra · 2022-04-04 16:04
You can select interesting lines and blamer annotated each selected line
Ghosty141 · 2022-06-06 15:44
You can't replicate fugitive blame with magit (sadly). https://github.com/magit/magit/issues/4057 -> short hashes are not available. Without that it's really hard to do. You can try the following which kinda comes close. (setq magit-blame-styles '((margin (margin-width . 32) (margin-format . ("%C %c %f")) (margin-face . magit-blame-margin) (margin-body-face . magit-blame-dimmed) (show-message . t))))
masukomi · 2022-06-06 19:13
That got me _very_ close, and more importantly, the info i needed. Thank you _very_ much. However, for some reason "committer" is GitHub in my case (for all lines regardless of author). ?!?!? had to switch `%c` to `%a` Note: That's not a magit bug. `git blame --incremental` also said `committer GitHub` Now i have to go explore WTF "committer" is supposed to represent, but that's a separate rabbit hole.