Hi all,

a couple of days ago I needed to dig into the history of a region of one
source file. I started with "magit-blame", then tried "mo-git-blame",
because I found its "back and forth navigation" thru the changeset
slightly more intuitive (but that may be just ignorance on my part: for
example, I learned about "repeated M-x magit-blame" right then :-). At
last I found what I was looking for.

Anyway, yesterday I did remember about a related little function
appeared on comp.emacs.help by Tassilo Horn, and quickly tried it after
a few tweaks to adapt it to magit:

  (defun git-commits-on-region (beg end)
    (interactive "r")
    (let ((start-line (line-number-at-pos beg))
          (end-line (line-number-at-pos end))
          (default-directory (magit-toplevel)))
      (if default-directory
          (let ((file (buffer-file-name))
                (buffer (get-buffer-create (format "*git commits touching %s, 
lines %d to %d*"
                                                   (buffer-file-name) 
start-line end-line))))
            (with-current-buffer buffer
              (erase-buffer)
              (call-process "git" nil t
                            t "log" "-L" (format "%d,%d:%s"
                                                 start-line end-line
                                                 (file-relative-name file)))
              (diff-mode)
              (goto-char (point-min)))
            (display-buffer buffer))
        (user-error "Probably not in a Git repo!"))))

It shows a single buffer, with all the changesets that touched the given
region of code.

I wonder if this could be a nice little feature to integrate into magit,
if it's not already there :-)

Thank you,
ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
[email protected]  |                 -- Fortunato Depero, 1929.

-- 
You received this message because you are subscribed to the Google Groups 
"magit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to