Subject: bug#76187: vc-git-test-dir-branch-headers failure on Fedora

From: Kévin Le Gouguec <[email-masked]>
Date: Tue, 11 Feb 2025 21:43:50 +0100

Kévin Le Gouguec <[email-masked]> writes:

> Paul Eggert <[email-masked]> writes:
>
>> The second failure was with "make lisp/vc/vc-git-tests" in the test directory. I repeatedly ran that test, and it failed on the 20th execution as follows:
>
>> Test vc-git-test-dir-branch-headers condition:
>>     (error
>>      "Failed (status 128): git --no-pager checkout -b feature/bar --track master .")
>>    FAILED  2/8  vc-git-test-dir-branch-headers (0.316582 sec) at lisp/vc/vc-git-tests.el:146
>
> Interesting.  I reproduced the 'checkout -b feature/foo master' failure
> after 300 executions.
>
> "status 128" confounds me a bit; tho there is a surprising (to me)
> number of hits for "git exit 128" on the net.  Wondering if Git outputs
> anything useful…
>
> Anyhoo, no clue yet - just wanted to ACK (openSUSE Tumbleweed FWIW),
> what with having authored that test.

Ah-ha.

diff --git a/test/lisp/vc/vc-git-tests.el b/test/lisp/vc/vc-git-tests.el
index 4b5cb75df01..b9d815e9a5d 100644
--- a/test/lisp/vc/vc-git-tests.el
+++ b/test/lisp/vc/vc-git-tests.el
@@ -106,7 +106,11 @@ vc-git-test--with-repo
 (defun vc-git-test--run (&rest args)
   "Run git ARGS…, check for non-zero status, and return output."
   (with-temp-buffer
-    (apply 'vc-git-command t 0 nil args)
+    (condition-case err
+        (apply 'vc-git-command t 0 nil args)
+      (t (message "err: %s" err)
+         (message "buffer-string: %s" (buffer-string))
+         (signal (car err) (cdr err))))
     (buffer-string)))
 
 (defun vc-git-test--start-branch ()

Yields:

> err: (error Failed (status 128): git --no-pager checkout -b feature/foo master .)
> buffer-string: fatal: Unable to create '/tmp/emacs-test-uJtGe2-vc-git/.git/index.lock': File exists.
> 
> Another git process seems to be running in this repository, e.g.
> an editor opened by 'git commit'. Please make sure all processes
> are terminated then try again. If it still fails, a git process
> may have crashed in this repository earlier:
> remove the file manually to continue.

Pondering.