unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alexei Khlebnikov <alexei.khlebnikov@gmail.com>
To: 21559@debbugs.gnu.org
Subject: bug#21559: 25.0.50; auto-revert-mode breaks git rebase
Date: Thu, 15 Feb 2018 23:32:44 +0100	[thread overview]
Message-ID: <CAJz13riV9ZvDnC+B7tVCxT+_zt0N3RzcaDXor27e-bA4jmEv4g@mail.gmail.com> (raw)
In-Reply-To: <CAJz13rgS6QbnSFLH-SgiNiaT1Xuuwg5Ew0GCwEGFE0=tJGd_Tg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1148 bytes --]

I am sending patch that fixes the issue. It fixes the issue for me on
Emacs' current master branch. The patch also cleanly applies to emacs-26
branch.

I tested using Mitchel Humpherys' repro method, i.e.

    $ cd /path/to/emacs
    $ ./src/emacs -Q lisp/*.el
    [ M-x global-auto-revert-mode ]
    $ for i in $(seq 30); do for f in lisp/*.el; do echo "; $i" >> $f;
done; git commit -am "test $i"; done


Without the fix I could reproduce the issue, and with the fix I could not
reproduce even if running the loop 100 times instead of 30. Emacs was
reloading a lot of files very fast, but no locking errors happened in the
shell which ran the loop.


2018-02-15 20:08 GMT+01:00 Alexei Khlebnikov <alexei.khlebnikov@gmail.com>:

> Judging from the comment of the commit implementing the
> "--no-optional-locks" switch,
>
> https://github.com/git/git/commit/27344d6a6c8056664966e11acf674e5da6dd7ee3
> ​
> , the switch was implemented exactly for background refresh in "tools like
> IDEs or fancy editors".
> I.e. for mitigating this particular bug! Now we only have to use this
> switch in our "fancy editor".
>
>

[-- Attachment #1.2: Type: text/html, Size: 1728 bytes --]

[-- Attachment #2: 0001-Fix-for-25.0.50-auto-revert-mode-breaks-git-rebase-B.patch --]
[-- Type: text/x-patch, Size: 2310 bytes --]

From 4bba51ded42954a62c99696453c17e7fa3f2b730 Mon Sep 17 00:00:00 2001
From: Alexei Khlebnikov <alexei.khlebnikov@gmail.com>
Date: Thu, 15 Feb 2018 21:18:01 +0100
Subject: [PATCH] Fix for: "25.0.50; auto-revert-mode breaks git rebase"
 (Bug#21559)

* lisp/vc/vc-git.el (vc-git-state, vc-git-conflicted-files)
  Use "--no-optional-locks" switch when doing "git status".
---
 lisp/vc/vc-git.el | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 47172dd52f..06db43c311 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -292,13 +292,16 @@ vc-git-state
   ;; upstream.  We'd need to check against the upstream tracking
   ;; branch for that (an extra process call or two).
   (let* ((args
-          `("status" "--porcelain" "-z"
+          `(;; Avoid locking repository during "git status" (bug#21559).
+            ,@(when (version<= "2.15.0" (vc-git--program-version))
+                '("--no-optional-locks"))
+            "status" "--porcelain" "-z"
             ;; Just to be explicit, it's the default anyway.
             "--untracked-files"
             ,@(when (version<= "1.7.6.3" (vc-git--program-version))
                 '("--ignored"))
             "--"))
-        (status (apply #'vc-git--run-command-string file args)))
+         (status (apply #'vc-git--run-command-string file args)))
     ;; Alternatively, the `ignored' state could be detected with 'git
     ;; ls-files -i -o --exclude-standard', but that's an extra process
     ;; call, and the `ignored' state is rarely needed.
@@ -939,8 +942,12 @@ vc-git-merge-branch
 
 (defun vc-git-conflicted-files (directory)
   "Return the list of files with conflicts in DIRECTORY."
-  (let* ((status
-          (vc-git--run-command-string directory "status" "--porcelain" "--"))
+  (let* ((args
+          `(;; Avoid locking repository during "git status" (bug#21559).
+            ,@(when (version<= "2.15.0" (vc-git--program-version))
+                '("--no-optional-locks"))
+            "status" "--porcelain" "--"))
+         (status (apply #'vc-git--run-command-string directory args))
          (lines (when status (split-string status "\n" 'omit-nulls)))
          files)
     ;; TODO: Look into reimplementing `vc-git-state', as well as
-- 
2.15.1


  reply	other threads:[~2018-02-15 22:32 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 12:45 bug#21559: 25.0.50; auto-revert-mode breaks git rebase Ben Gamari
2015-09-26  7:41 ` Eli Zaretskii
2015-09-28 14:11   ` Ben Gamari
2015-09-28 14:35     ` Eli Zaretskii
2015-09-28 15:05       ` Ben Gamari
2015-09-29  8:47     ` Michael Albinus
2015-10-26 18:43 ` bug#21559: [PATCH] autorevert: Wait for repository to become idle before calling vc-find-file-hook Ben Gamari
2015-10-26 18:43   ` bug#21559: [PATCH] autorevert: Wait a while " Ben Gamari
2015-10-27  8:25     ` Michael Albinus
2015-10-28 11:59       ` Ben Gamari
2015-10-28 14:45         ` Michael Albinus
2015-10-28 17:05           ` Ben Gamari
2015-10-29  8:20             ` Michael Albinus
2016-02-06  0:01 ` bug#21559: 25.0.50; auto-revert-mode breaks git rebase Mitchel Humpherys
2016-02-06 12:34   ` Ben Gamari
2016-02-07  1:34     ` Mitchel Humpherys
2016-02-07  5:03       ` Mitchel Humpherys
2016-02-07  5:21         ` Mitchel Humpherys
2016-02-07 10:22           ` Ben Gamari
2016-02-07 10:55             ` Ben Gamari
2016-02-07 17:06               ` Mitchel Humpherys
2016-02-07 17:22                 ` Ben Gamari
2016-02-08 21:19               ` Daniel Colascione
2016-09-09 20:56 ` Jason Merrill
2018-02-14 10:08 ` Alexei Khlebnikov
2018-02-15 19:08   ` Alexei Khlebnikov
2018-02-15 22:32     ` Alexei Khlebnikov [this message]
2018-02-19 23:41     ` Dmitry Gutov
2018-02-20  0:06       ` Alexei Khlebnikov
2018-02-20  0:17         ` Dmitry Gutov
2018-02-20  4:07           ` Eli Zaretskii
2018-02-20  7:40       ` Michael Albinus
2018-02-20 11:37         ` Dmitry Gutov
2018-02-20 11:53           ` Michael Albinus
2018-02-20 22:28             ` Dmitry Gutov
2018-02-21 22:07               ` Alexei Khlebnikov
2018-02-22 11:24                 ` Michael Albinus
2018-02-22 11:45                   ` Dmitry Gutov
2018-02-19 10:24 ` bug#21559: PATCH review needed: lisp/vc/vc-git.el (vc-git-state, vc-git-conflicted-files) Alexei Khlebnikov
2018-02-19 12:39   ` Michael Albinus
2018-02-19 15:29   ` Eli Zaretskii
2018-02-19 18:39     ` Alexei Khlebnikov
2018-02-19 18:50       ` Michael Albinus
2018-02-19 19:05         ` Alexei Khlebnikov
2018-02-19 23:35         ` Dmitry Gutov
2018-09-25 12:23 ` bug#21559: additional patch needed to set GIT_OPTIONAL_LOCKS=0 in all cases Andrew Ruder
2018-09-26  3:16   ` Phil Sainty
2018-09-26  9:45     ` Michael Albinus
2018-09-29 11:16       ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJz13riV9ZvDnC+B7tVCxT+_zt0N3RzcaDXor27e-bA4jmEv4g@mail.gmail.com \
    --to=alexei.khlebnikov@gmail.com \
    --cc=21559@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).