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

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

From
Rémi Vanicat <vanicat@debian.org>
Date
Feb 16, 2008, 19:35 UTC
Message-ID
<8763wou23f.dlv_-_@maison.homelinux.org>
In-Reply-To
<87lk5ku2wn.dlv_-_@maison.homelinux.org>

M-x git-merge will ask for an commitish, and merge with it. A new submenu is also available for merging with local and remote branch. --- The problem here, which is similar to the one that exist now when one merge from outside Emacs, is that in case of conflict, Emacs doesn't look to the index, and so, when one commit the resolved conflict, one might forget to select all file that should be selected for the commit to be what is needed.

This problem could be even worse with rebasing, as rebasing is a more destructive action than merging.

 contrib/emacs/git.el |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index f180421..60553d3 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -1213,6 +1213,25 @@ use a prefix arg if git should merge while checking out"
    (list ["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 merge branch menu"
+  (append
+   (mapcar
+    (lambda (branch)
+      `[,(car branch)
+	 (git-merge ,(car branch)) :visible ,(not (cdr branch))])
+    (git-list-branches :all))
+   (list ["merge with any commitish" git-merge t])))
+
 (defun git-diff-file ()
   "Diff the marked file(s) against HEAD."
   (interactive)
@@ -1555,7 +1574,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: Alexandre JulliardNext: Sergei Organov
Message 13 of 14 in “Add function to checkout a branch in git.el”
  1. Add function to checkout a branch in git.el=?utf-8?q?R=C3=A9mi=20Vanicat?=, Feb 13, 2008
  2. Karl HasselströmFeb 13, 2008
  3. Karl HasselströmFeb 13, 2008
  4. Remi VanicatFeb 13, 2008
  5. Sergei OrganovFeb 13, 2008
  6. Karl HasselströmFeb 13, 2008
  7. Sergei OrganovFeb 14, 2008
  8. switching and creating branch, merging and rebasing with Emacs=?utf-8?q?R=C3=A9mi=20Vanicat?=, Feb 16, 2008
  9. 01/03 Add helper function for branch tag and commitish to git.elRémi Vanicat, Feb 16, 2008
  10. Alexandre JulliardFeb 17, 2008
  11. 02/03 Adding checkout function for commitish in git.elRémi Vanicat, Feb 16, 2008
  12. Alexandre JulliardFeb 17, 2008
  13. 03/03 Adding command for merging in git.elRémi Vanicat, Feb 16, 2008
  14. Sergei OrganovFeb 13, 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.