git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 03/03] Adding command for merging in git.el

From
Rémi Vanicat <vanicat@debian.org>
Date
Feb 18, 2008, 16:35 UTC
Message-ID
<87ir0mp6hg.dlv@maison.homelinux.org>
In-Reply-To
<87zltyp717.dlv@maison.homelinux.org>
M-x git-merge will ask for an commitish, and merge with it.
    key binding "C-cC-m"
A new submenu is also available for merging with local and remote
branch.
---
 contrib/emacs/git.el |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index d35f837..5c3fc01 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -1254,6 +1254,26 @@ use a prefix arg if git should merge while checking out"
      :after `(["checkout any commitish" git-checkout t]
 	      ["change to new" git-branch t]))))
 
+(defun git-merge (commitish)
+  "merge with commitish
+
+Note that in case of conflict, after resolving everty conflict,
+one have to select every concerned file before commiting"
+  (interactive (list (git-read-commitish "Merge with: ")))
+  (git-call-process-display-error "merge" commitish)
+  (git-refresh-status))
+
+(defun git-merge-menu-filter (rest)
+  "define the change branch menu"
+  (git-refs-build-menu
+   :branch (lambda (short-name ref-name)
+	     `[,short-name (git-merge ,short-name)])
+   :remote (lambda (short-name ref-name)
+	     `[,short-name (git-merge ,short-name)])
+   :tag (lambda (short-name ref-name)
+	  `[,short-name (git-merge ,short-name)])
+   :after `(["merge with any commitish" git-merge t])))
+
 (defun git-diff-file ()
   "Diff the marked file(s) against HEAD."
   (interactive)
@@ -1578,6 +1598,7 @@ amended version of it."
     (define-key commit-map "\C-a" 'git-amend-commit)
     (define-key commit-map "\C-o" 'git-checkout)
     (define-key commit-map "\C-b" 'git-branch)
+    (define-key commit-map "\C-m" 'git-merge)
     ; the diff submap
     (define-key diff-map "b" 'git-diff-file-base)
     (define-key diff-map "c" 'git-diff-file-combined)
@@ -1599,7 +1620,8 @@ amended version of it."
       ["Refresh" git-refresh-status t]
       ["Commit" git-commit-file t]
       ("Checkout Branch" :filter git-checkout-menu-filter)
-      ("Merge"
+      ("Merge" :filter git-merge-menu-filter)
+      ("Resolve Merge"
 	["Next Unmerged File" git-next-unmerged-file t]
 	["Prev Unmerged File" git-prev-unmerged-file t]
 	["Mark as Resolved" git-resolve-file t]
-- 
1.5.4.1.123.gcb68-dirty
Previous: Rémi Vanicat
Message 4 of 4 in “switching, branch creating branch and merging within Emacs”
  1. 00/03 switching, branch creating branch and merging within EmacsRémi Vanicat, Feb 18, 2008
  2. 01/03 Add helpers functions for refs and commitish to git.elRemi Vanicat, Feb 18, 2008
  3. 02/03 Adding checkout function for commitish in git.elRémi Vanicat, Feb 18, 2008
  4. 03/03 Adding command for merging in git.elRémi Vanicat, Feb 18, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.