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>
Alexandre Julliard committed
Nov 7, 2008 at 14:28 UTC
1905a8666a676f7070ba15c6f56f98bb1da20f7b
1 file changed
+20
-23
contrib/emacs/git.el
+20
-23
@@ -895,29 +895,26 @@ Return the list of files that haven't been handled."
895
(unless (git-empty-db-p)
896
(setq head (git-rev-parse "HEAD")
897
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."))))
918
(delete-file index-file))))))
919
920