git-gutter icon indicating copy to clipboard operation
git-gutter copied to clipboard

not always refreshing when commiting outside of emacs?

Open emmanueltouzery opened this issue 9 years ago • 15 comments

I'm not using (yet?) magit for committing, but rather commiting in a terminal outside of emacs. As a result, git-gutter still reflects the status of before the commit, does not pick up the change.

I have added this to my emacs config and was sure it would help, but it does not: (require 'git-gutter) (add-to-list 'git-gutter:update-hooks 'focus-in-hook)

Also when git-gutter is displaying obsolete information, running "git-gutter:update-all-windows" still does not get rid of the obsolete information.

I'm pretty sure I misconfigured something... I'm using spacemacs otherwise, and I put the focus-in-hook thing in the:

(defun dotspacemacs/config () "Configuration function. This function is called at the very end of Spacemacs initialization after layers configuration."

emmanueltouzery avatar Apr 04 '15 21:04 emmanueltouzery

Would you tell me your Emacs version and OS ? focus-in-hook was introduced at Emacs 24.4. And it works only on GUI Emacs.

I know focus hooks works on Linux however I don't know whether it works on other platforms(MacOSX, Windows etc).

syohex avatar Apr 06 '15 13:04 syohex

I have GNU Emacs 24.4.1, linux (fedora). I only use emacs in the GUI. As I said I use it through the spacemacs bundle though.

On Mon, Apr 6, 2015 at 3:13 PM, Syohei YOSHIDA [email protected] wrote:

Would you tell me your Emacs version and OS ? focus-in-hook was introduced at Emacs 24.4. And it works only on GUI Emacs.

I know focus hooks works on Linux however I don't know whether it works on other platforms(MacOSX, Windows etc).

— Reply to this email directly or view it on GitHub https://github.com/syohex/emacs-git-gutter/issues/86#issuecomment-90059399 .

emmanueltouzery avatar Apr 06 '15 13:04 emmanueltouzery

I've added this to my init function:

(add-hook 'focus-in-hook (lambda () (message "hello")))

and hello is displayed on focus. So I think that's not the problem.

emmanueltouzery avatar Apr 06 '15 13:04 emmanueltouzery

Thanks for information. Would you tell me how to reproduce this issue ? Which git command did you use ?

syohex avatar Apr 06 '15 13:04 syohex

It's a simple of having a clean repo, modifying the file, comitting outside of emacs, and the status doesn't update in emacs. In fact I even tried to call manually git-gutter:update-all-windows (M-x git-gutter:update-all-windows ENTER) but also that did not help. The status in git-gutter remained obsolete.

I tried to reproduce it with a sample project but this time it works. All I can say is that in some cases it doesn't...

emmanueltouzery avatar Apr 06 '15 14:04 emmanueltouzery

Maybe you can tell me what to try doing the next time I hit the issue so that I try to narrow the source of the problem?

emmanueltouzery avatar Apr 06 '15 14:04 emmanueltouzery

Maybe you can tell me what to try doing the next time I hit the issue so that I try to narrow the source of the problem?

I have no idea now.

I cannot reproduce this issue.

git-gutter

Can I get such a repository which makes this issue ?

syohex avatar Apr 07 '15 14:04 syohex

It's not with the repository, restarting emacs solves the problem. It's also not everytime.

I'll probably add debug messages and look at them when i reproduce..

On 7 Apr 2015 16:53, "Syohei YOSHIDA" [email protected] wrote:

Maybe you can tell me what to try doing the next time I hit the issue so that I try to narrow the source of the problem?

I have no idea now.

I cannot reproduce this issue.

Can I get such a repository which makes this issue ?

— Reply to this email directly or view it on GitHub.

emmanueltouzery avatar Apr 07 '15 15:04 emmanueltouzery

I just reproduced the issue just putting videos in case it helps somehow. As i said, manually calling the function to update the status does not help. Killing emacs and restarting it does help. I wonder if there's maybe a connection with the fact that I use emacs-client.

Anyway, videos: https://dl.dropboxusercontent.com/u/22600720/gitgutter1.webm https://dl.dropboxusercontent.com/u/22600720/gitgutter2.webm

PS: I'm not trying to reproduce the problem, just using git-gutter while working on other projects for now. If still no solution arise I'll guess I'll start looking at the git-gutter source but I didn't come around to doing that yet.

emmanueltouzery avatar Apr 10 '15 18:04 emmanueltouzery

it's possible that i have this problem only when using emacs-client. not sure yet, just a theory.

emmanueltouzery avatar May 14 '15 19:05 emmanueltouzery

it's possible that i have this problem only when using emacs-client.

Thanks for information.

syohex avatar May 18 '15 05:05 syohex

Same here. Reproducible almost on every commit. Running M-x git-gutter refreshes the buffer correctly.

I am using linum-mode, actually linum-relative along with git-gutter-fringe. The update-interval seems to have no effect:

(global-git-gutter-mode t) (custom-set-variables '(git-gutter:update-interval 2))

Please, if you need further information, just ask.

ereslibre avatar Jul 13 '15 09:07 ereslibre

just FYI I was using emacs-git-gutter because it's the default one in spacemacs. Now spacemacs swtiched to diff-hl and there the feature works as expected for me.

emmanueltouzery avatar Jul 13 '15 11:07 emmanueltouzery

partial solution for current version of magit: http://stackoverflow.com/a/32296023/321365

4DA avatar Sep 01 '15 18:09 4DA

Edited: Fixed it with the code below in my init file: Notice: It may have side effects.

Solution1:

;; Update all window when Emacs focus in.
;; This fixes git gutter cannot update the file status after committing outside of Emacs.
(add-hook 'focus-in-hook 'git-gutter:update-all-windows)

Solution2:

;; Revert buffer without confirm when buffer focus in.
;; This fixes git gutter cannot update the file status after committing outside of Emacs.
(add-hook 'focus-in-hook 'revert-buffer-no-confirm)

(defun revert-buffer-no-confirm ()
  "Revert buffer without confirmation."
  (interactive) (revert-buffer t t))

Confirmed on MacOS 11.0 Beta (20A4300b)

Screen Shot 2020-07-22 at 08 56 02

The correct status is showed after running M-x revert-buffer

willbchang avatar Jul 22 '20 02:07 willbchang