Skip to content

Commit 1905a86

Browse files
committed
git.el: Allow to commit even if there are no marked files.
This can be useful to commit a merge that didn't result in any changes. Signed-off-by: Alexandre Julliard <julliard@winehq.org>
1 parent c4e8b72 commit 1905a86

1 file changed

Lines changed: 20 additions & 23 deletions

File tree

contrib/emacs/git.el

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -895,29 +895,26 @@ Return the list of files that haven't been handled."
895895
(unless (git-empty-db-p)
896896
(setq head (git-rev-parse "HEAD")
897897
head-tree (git-rev-parse "HEAD^{tree}")))
898-
(if files
899-
(progn
900-
(message "Running git commit...")
901-
(when
902-
(and
903-
(git-read-tree head-tree index-file)
904-
(git-update-index nil files) ;update both the default index
905-
(git-update-index index-file files) ;and the temporary one
906-
(setq tree (git-write-tree index-file)))
907-
(if (or (not (string-equal tree head-tree))
908-
(yes-or-no-p "The tree was not modified, do you really want to perform an empty commit? "))
909-
(let ((commit (git-commit-tree buffer tree head)))
910-
(when commit
911-
(condition-case nil (delete-file ".git/MERGE_HEAD") (error nil))
912-
(condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
913-
(with-current-buffer buffer (erase-buffer))
914-
(git-update-status-files (git-get-filenames files))
915-
(git-call-process nil "rerere")
916-
(git-call-process nil "gc" "--auto")
917-
(message "Committed %s." commit)
918-
(git-run-hook "post-commit" nil)))
919-
(message "Commit aborted."))))
920-
(message "No files to commit.")))
898+
(message "Running git commit...")
899+
(when
900+
(and
901+
(git-read-tree head-tree index-file)
902+
(git-update-index nil files) ;update both the default index
903+
(git-update-index index-file files) ;and the temporary one
904+
(setq tree (git-write-tree index-file)))
905+
(if (or (not (string-equal tree head-tree))
906+
(yes-or-no-p "The tree was not modified, do you really want to perform an empty commit? "))
907+
(let ((commit (git-commit-tree buffer tree head)))
908+
(when commit
909+
(condition-case nil (delete-file ".git/MERGE_HEAD") (error nil))
910+
(condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
911+
(with-current-buffer buffer (erase-buffer))
912+
(git-update-status-files (git-get-filenames files))
913+
(git-call-process nil "rerere")
914+
(git-call-process nil "gc" "--auto")
915+
(message "Committed %s." commit)
916+
(git-run-hook "post-commit" nil)))
917+
(message "Commit aborted."))))
921918
(delete-file index-file))))))
922919

923920

0 commit comments

Comments
 (0)