Skip to content

Commit a7da5c4

Browse files
committed
git.el: Make git-run-command-region display the error if any.
This makes it easier to figure out why a commit has failed. Signed-off-by: Alexandre Julliard <julliard@winehq.org>
1 parent ab69e3e commit a7da5c4

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

contrib/emacs/git.el

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ the process output as a string, or nil if the git command failed."
220220
(with-current-buffer buffer
221221
(cd dir)
222222
(apply #'call-process-region start end program
223-
nil (list output-buffer nil) nil args))))
223+
nil (list output-buffer t) nil args))))
224224

225225
(defun git-run-command-buffer (buffer-name &rest args)
226226
"Run a git command, sending the output to a buffer named BUFFER-NAME."
@@ -237,13 +237,15 @@ the process output as a string, or nil if the git command failed."
237237

238238
(defun git-run-command-region (buffer start end env &rest args)
239239
"Run a git command with specified buffer region as input."
240-
(unless (eq 0 (if env
241-
(git-run-process-region
242-
buffer start end "env"
243-
(append (git-get-env-strings env) (list "git") args))
240+
(with-temp-buffer
241+
(if (eq 0 (if env
244242
(git-run-process-region
245-
buffer start end "git" args)))
246-
(error "Failed to run \"git %s\":\n%s" (mapconcat (lambda (x) x) args " ") (buffer-string))))
243+
buffer start end "env"
244+
(append (git-get-env-strings env) (list "git") args))
245+
(git-run-process-region buffer start end "git" args)))
246+
(buffer-string)
247+
(display-message-or-buffer (current-buffer))
248+
nil)))
247249

248250
(defun git-run-hook (hook env &rest args)
249251
"Run a git hook and display its output if any."
@@ -456,18 +458,16 @@ Each entry is a cons of (SHORT-NAME . FULL-NAME)."
456458
(setq coding-system-for-write buffer-file-coding-system))
457459
(let ((commit
458460
(git-get-string-sha1
459-
(with-output-to-string
460-
(with-current-buffer standard-output
461-
(let ((env `(("GIT_AUTHOR_NAME" . ,author-name)
462-
("GIT_AUTHOR_EMAIL" . ,author-email)
463-
("GIT_COMMITTER_NAME" . ,(git-get-committer-name))
464-
("GIT_COMMITTER_EMAIL" . ,(git-get-committer-email)))))
465-
(when author-date (push `("GIT_AUTHOR_DATE" . ,author-date) env))
466-
(apply #'git-run-command-region
467-
buffer log-start log-end env
468-
"commit-tree" tree (nreverse args))))))))
469-
(and (git-update-ref "HEAD" commit head subject)
470-
commit))))
461+
(let ((env `(("GIT_AUTHOR_NAME" . ,author-name)
462+
("GIT_AUTHOR_EMAIL" . ,author-email)
463+
("GIT_COMMITTER_NAME" . ,(git-get-committer-name))
464+
("GIT_COMMITTER_EMAIL" . ,(git-get-committer-email)))))
465+
(when author-date (push `("GIT_AUTHOR_DATE" . ,author-date) env))
466+
(apply #'git-run-command-region
467+
buffer log-start log-end env
468+
"commit-tree" tree (nreverse args))))))
469+
(when commit (git-update-ref "HEAD" commit head subject))
470+
commit)))
471471

472472
(defun git-empty-db-p ()
473473
"Check if the git db is empty (no commit done yet)."

0 commit comments

Comments
 (0)