@matheusbsbs / matheus-bagliano / commits / a7da5c4259
Fork 0

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>

Alexandre Julliard committed Nov 23, 2008 at 16:12 UTC a7da5c425970372f75d7cc2c194d5646554f8a32
1 file changed +19 -19
contrib/emacs/git.el
+19 -19
@@ -220,7 +220,7 @@ the process output as a string, or nil if the git command failed."
220 (with-current-buffer buffer
221 (cd dir)
222 (apply #'call-process-region start end program
223 - nil (list output-buffer nil) nil args))))
223 + nil (list output-buffer t) nil args))))
224
225 (defun git-run-command-buffer (buffer-name &rest args)
226 "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."
237
238 (defun git-run-command-region (buffer start end env &rest args)
239 "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
242 (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)))
249
250 (defun git-run-hook (hook env &rest args)
251 "Run a git hook and display its output if any."
@@ -456,18 +458,16 @@ Each entry is a cons of (SHORT-NAME . FULL-NAME)."
458 (setq coding-system-for-write buffer-file-coding-system))
459 (let ((commit
460 (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)))
471
472 (defun git-empty-db-p ()
473 "Check if the git db is empty (no commit done yet)."