Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-gutter+-stage-hunks doesn't work across Tramp #17

Closed
domq opened this issue Feb 7, 2015 · 4 comments
Closed

git-gutter+-stage-hunks doesn't work across Tramp #17

domq opened this issue Feb 7, 2015 · 4 comments

Comments

@domq
Copy link
Contributor

domq commented Feb 7, 2015

Steps to reproduce:

  • Open remote file w/ Tramp
  • Select region
  • M-x git-gutter+-stage-hunks

Result:

Error staging hunks:
fatal: --cached outside a repository

Platform details:
Emacs for Mac OS X (from http://emacsformacosx.com/), emacs-version 24.4.50.1

@domq
Copy link
Contributor Author

domq commented Feb 7, 2015

AIUI, the trouble is that call-process-region doesn't work through tramp. The org-mode folks ran into the same problem before.

@domq
Copy link
Contributor Author

domq commented Feb 7, 2015

Running the following code (cobbled together from the Git history over at https://github.com/emacsmirror/tramp) gets the hunk feature working remotely. Note that tramp-sh-handle-call-process-region was deleted in December 2012 for some reason.

(defun tramp-sh-handle-call-process-region
    (start end program &optional delete buffer display &rest args)
  "Like `call-process-region' for Tramp files."
  (let ((tmpfile (tramp-compat-make-temp-file "")))
    (write-region start end tmpfile)
    (when delete (delete-region start end))
    (unwind-protect
        (apply 'process-file program tmpfile buffer display args)
      (delete-file tmpfile))))

(defadvice call-process-region
  (around tramp-advice-call-process-region activate)
  "Invoke `tramp-sh-handle-call-process-region' for Tramp files."
  (if (eq (tramp-find-foreign-file-name-handler default-directory)
          'tramp-sh-file-name-handler)
      (setq ad-return-value
            (apply 'tramp-sh-handle-call-process-region (ad-get-args 0)))
    ad-do-it))

@domq
Copy link
Contributor Author

domq commented Feb 7, 2015

Pull request #18 is a cleaned-up version of the above.

nonsequitur pushed a commit that referenced this issue Feb 16, 2015
Change git-gutter+-call-git-on-current-buffer to call either
#'call-process-region or #'tramp-sh-handle-call-process-region,
#depending on context, just like git-gutter+-call-git already does
@nonsequitur
Copy link
Owner

Commited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants