1

I am reading a diff between two revisions, say A..B, possibly limited to a single file.

Once in a while, I stumble on a hunk that I’d like to investigate in detail. I want to press a key or two and see the commit(s) that introduce the change I’m currently looking at.

Since that is kind of vague, let’s say I want the equivalent of l =L file RET start,+lines RET l range RET, where file, start and lines are taken from the current hunk and range is the current diff’s range. The log should not be limited to the file, even if the diff was.

I can do this manually but I want to automate it.

0

That's currently not supported. There already exist requests for similar features and I plan to implement such things eventually. So it's not strictly necessary that you open a feature request for this, but if you want to really make sure I don't forget about this particular variant, then you might want to open one anyway.

0

As a stopgap, I’m going to try this:

(defun yk-magit-log-hunk ()
  (interactive)
  (let ((yk-diff-range (car magit-refresh-args)))
    (magit-section-case
      ('hunk (let* ((yk-file (magit-section-value (magit-section-parent it)))
                    (yk-hunk-lines (nth 2 (magit-section-value it)))
                    (yk-line-range (replace-regexp-in-string
                                    "^\\+\\([0-9]+\\),\\([0-9]+\\)$"
                                    "\\1,+\\2"
                                    yk-hunk-lines)))
               (magit-log (list yk-diff-range)
                          (list (concat "-L" yk-line-range ":" yk-file))
                          nil)))
      ('file (let ((yk-file (magit-section-value it)))
               (magit-log (list yk-diff-range) nil (list yk-file)))))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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