git.el: Added a function to diff against the other heads in a merge.
git-diff-file-merge-head generates a diff against the first merge head, or with a prefix argument against the nth head. Bound to `d h' by default. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Alexandre Julliard committed
Mar 19, 2006 at 10:06 UTC
2b1c0ef2e5d103efacb535f32fb142114490dc33
1 file changed
+11
contrib/emacs/git.el
+11
@@ -767,6 +767,16 @@ The default is to fall back to the git repository config, then to `add-log-maili
767
(git-setup-diff-buffer
768
(apply #'git-run-command-buffer "*git-diff*" "diff-index" "-p" "-M" "HEAD" "--" (git-get-filenames files)))))
769
770
+(defun git-diff-file-merge-head (arg)
771
+ "Diff the marked file(s) against the first merge head (or the nth one with a numeric prefix)."
772
+ (interactive "p")
773
+ (let ((files (git-marked-files))
774
+ (merge-heads (git-get-merge-heads)))
775
+ (unless merge-heads (error "No merge in progress"))
776
+ (git-setup-diff-buffer
777
+ (apply #'git-run-command-buffer "*git-diff*" "diff-index" "-p" "-M"
778
+ (or (nth (1- arg) merge-heads) "HEAD") "--" (git-get-filenames files)))))
779
+
780
(defun git-diff-unmerged-file (stage)
781
"Diff the marked unmerged file(s) against the specified stage."
782
(let ((files (git-marked-files)))
@@ -959,6 +969,7 @@ The default is to fall back to the git repository config, then to `add-log-maili
969
(define-key diff-map "=" 'git-diff-file)
970
(define-key diff-map "e" 'git-diff-file-idiff)
971
(define-key diff-map "E" 'git-find-file-imerge)
972
+ (define-key diff-map "h" 'git-diff-file-merge-head)
973
(define-key diff-map "m" 'git-diff-file-mine)
974
(define-key diff-map "o" 'git-diff-file-other)
975
(setq git-status-mode-map map)))