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

not always refreshing when commiting outside of emacs? #86

Open
emmanueltouzery opened this issue Apr 4, 2015 · 15 comments
Open

not always refreshing when commiting outside of emacs? #86

emmanueltouzery opened this issue Apr 4, 2015 · 15 comments

Comments

@emmanueltouzery
Copy link

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."

@syohex
Copy link
Contributor

syohex commented Apr 6, 2015

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).

@emmanueltouzery
Copy link
Author

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
#86 (comment)
.

@emmanueltouzery
Copy link
Author

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.

@syohex
Copy link
Contributor

syohex commented Apr 6, 2015

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

@emmanueltouzery
Copy link
Author

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
Copy link
Author

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?

@syohex
Copy link
Contributor

syohex commented Apr 7, 2015

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 ?

@emmanueltouzery
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

@syohex
Copy link
Contributor

syohex commented May 18, 2015

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

Thanks for information.

@ereslibre
Copy link

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.

@emmanueltouzery
Copy link
Author

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.

@4DA
Copy link

4DA commented Sep 1, 2015

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

@willbchang
Copy link

willbchang commented Jul 22, 2020

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

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

No branches or pull requests

5 participants