Subject: bug#79024: 31.0.50; Multiple working trees support for VC

From: Eli Zaretskii <[email-masked]>
Date: Sat, 26 Jul 2025 16:49:53 +0300

> From: Sean Whitton <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sat, 26 Jul 2025 13:19:29 +0100
> 
> Hello,
> 
> On Sat 26 Jul 2025 at 10:02am +03, Eli Zaretskii wrote:
> 
> > The new VC tests added under this discussion have 2 problems:
> >
> > . Compiling the test file produces a warning:
> >
> >   In vc-test--other-working-trees:
> >   lisp/vc/vc-tests/vc-tests.el:665:28: Warning: Unused lexical variable `tempdir'
> 
> Thanks.  Is it deliberate that these files aren't compiled during a
> regular build?  I didn't know that files in test/lisp/ need to be
> manually tested for problems like these.

I don't understand the question.  The test files are compiled when the
test is run, if the .elc file is outdated.

> >   Test vc-test-git07-other-working-trees condition:
> >       (error
> >        "Failed (status 128): git --no-pager commit -F c:/Users/EliZ/AppData/Local/Temp/git-msg5fr19l --only -- foo")
> >      FAILED  24/56  vc-test-git07-other-working-trees (0.337804 sec) at lisp/vc/vc-tests/vc-tests.el:1
> >
> > Is the new feature supposed to work on MS-Windows, where committing
> > specifies the message through a temporary file, rather than the
> > command line?
> 
> It should work fine, this isn't about the new features, but just about
> how I wrote the test setup.  This is the relevant code:
> 
> --8<---------------cut here---------------start------------->8---
>   ;; Set up the first working tree.
>   (make-directory first t)
>   (let ((default-directory first))
>     (vc-test--create-repo-function backend)
>     (write-region "foo" nil tmp-name nil 'nomessage)
>     (vc-register `(,backend (,(file-name-nondirectory tmp-name)))))
>   (with-current-buffer (find-file-noselect tmp-name)
>     (vc-checkin (list (file-name-nondirectory tmp-name)) backend)
>     (insert "Testing other working trees")
>     (let (vc-async-checkin)
>       (log-edit-done))
> --8<---------------cut here---------------end--------------->8---
> 
> I tried to just copy what vc-test--version-diff did to create and
> checkin a sample file.  Does vc-test-git06-version-diff work for you?

Yes.

This test fails on GNU/Linux as well for me, but for a different
reason:

  Test vc-test-git07-other-working-trees backtrace:
    write-region(nil nil "~/.emacs.d/projects.eld" nil silent)
    project--write-project-list()
    project--remember-dir("/tmp/vc-testxQfvm1/first/" nil)
    project-remember-project((vc Git "/tmp/vc-testxQfvm1/first/"))
    vc-add-working-tree(Git "/tmp/vc-testxQfvm1/second/")
    (progn (fset 'completing-read vnew) (vc-add-working-tree backend sec
    (unwind-protect (progn (fset 'completing-read vnew) (vc-add-working-
    (let* ((vnew #'(lambda (&rest _ignore) "")) (old (symbol-function 'c
    (cond ((eql backend 'Git) (let* ((vnew #'(lambda (&rest _ignore) "")
    (save-current-buffer (set-buffer (find-file-noselect tmp-name)) (vc-
    (let* ((first (file-name-as-directory (expand-file-name "first" defa
    (progn (add-hook 'vc-test--cleanup-hook (let ((dir default-directory
    (unwind-protect (progn (add-hook 'vc-test--cleanup-hook (let ((dir d
    (let ((vc-handled-backends (list backend)) (default-directory (file-
    (progn (let ((vc-handled-backends (list backend)) (default-directory
    (unwind-protect (progn (let ((vc-handled-backends (list backend)) (d
    (let* ((coding-system-for-write nil) (temp-file (file-name-as-direct
    vc-test--other-working-trees(Git)
    #f(lambda () :dynbind (let ((value-478 (gensym "ert-form-evaluation-
    #f(compiled-function () #<bytecode 0x67538246abce8e>)()
    handler-bind-1(#f(compiled-function () #<bytecode 0x67538246abce8e>)
    ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
    ert-run-test(#s(ert-test :name vc-test-git07-other-working-trees :do
    ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
    ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
    ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
    ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
    eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
    command-line-1(("-L" ":." "-l" "ert" "--eval" "(setq treesit-extra-l
    command-line()
    normal-top-level()
  Test vc-test-git07-other-working-trees condition:
      (file-missing "Opening output file" "No such file or directory"
		    "/nonexistent/.emacs.d/projects.eld")
     FAILED  24/56  vc-test-git07-other-working-trees (0.120713 sec) at lisp/vc/vc

Maybe this fails because my Git is very old?  (It does support
worktrees, though.)  If you could show a series of shell commands this
test invokes, I could perhaps run them from the shell and see what
happens.

> > (The vc-test-hg07-other-working-trees test is skipped, perhaps the
> > version of Mercurial I have here is 4.7.1 or maybe "share" is an
> > add-on one should install and I didn't.)
> 
> You don't have to install it but you do have to enable it in your
> personal ~/.hgrc runtime configuration file.  Add this to that file:
> 
>     [extensions]
>     share =

OK, did that (perhaps this should be in the comments to the test?).
But the test is still skipped.  I think I understand why: we run the
test suite with a bogus HOME directory, so the real ~/.hgrc is not
used, and "hg share" says "unknown command".  I see the same on
GNU/Linux, so this is not specific to Windows.  Does the test work for
you?