all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Matt Armstrong <matt@rfc20.org>
To: Gregor Zattler <telegraph@gmx.net>, 59064@debbugs.gnu.org
Cc: philip kaludercic <philipk@posteo.net>
Subject: bug#59064: 29.0.50; build problem git worktree linked to main worktree (repo)
Date: Sun, 06 Nov 2022 10:17:06 -0800	[thread overview]
Message-ID: <87v8nsaqxp.fsf@rfc20.org> (raw)
In-Reply-To: <87iljsruwz.fsf@no.workgroup>

X-Debbugs-CC: Philip Kaludercic <philipk@posteo.net>

Hi Philip, this bug manifests for Gregor as Emacs build error in a
particular kind of git repository, but it is really a problem with
`vc-git-mode-line-string' caused by a recent commit of yours to
`vc-working-revision'.  Could you take a look?


Gregor Zattler <telegraph@gmx.net> writes:

> I will try to bisect.  But since I have no clue regarding the build
> system I only hope that this will not hit other build failures in
> between.  This will take days...

Gregor, no need to bisect.  Your most recent instructions helped.  This
is not a mysterious problem with the build system, but a simpler one
with a recent regression in Emacs' vc-mode.

The steps to reproduce are simple:

1) In the root directory of an existing Emacs git repository, run this:

      git switch master
      git worktree add -d ../b59064

   Note that the -d is important.  This creates a "detached" work tree
   attached to no branch at all, but just happens to be at the same rev
   as "master".

2) cd ../b59064

3) git status

   Confirm this prints "Not currently on any branch."

3) emacs -Q (using a recent Emacs built on master, not one built in
             this new repository)

3) M-: (setq debug-on-error t)

Edit any file in this repository, I did C-x C-f "INSTALL".  You may then
need to run M-x vc-mode.

You get the following problem in `vc-git-mode-line-string':

Debugger entered--Lisp error: (args-out-of-range "master" 0 7)
  vc-git-mode-line-string("/home/matt/git/e/b59064/admin/grammars/srecode-tem...")
  apply(vc-git-mode-line-string "/home/matt/git/e/b59064/admin/grammars/srecode-tem...")
  vc-call-backend(Git mode-line-string "/home/matt/git/e/b59064/admin/grammars/srecode-tem...")
  vc-mode-line("/home/matt/git/e/b59064/admin/grammars/srecode-tem..." Git)
  vc-refresh-state()
  run-hooks(find-file-hook)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer srecode-template.wy> "~/git/e/b59064/admin/grammars/srecode-template.wy" nil nil "~/git/e/b59064/admin/grammars/srecode-template.wy" (67952095 27))
  find-file-noselect("/home/matt/git/e/b59064/admin/grammars/srecode-tem..." nil nil nil)
  find-file("/home/matt/git/e/b59064/admin/grammars/srecode-tem...")
  dired--find-file(find-file "/home/matt/git/e/b59064/admin/grammars/srecode-tem...")
  dired--find-possibly-alternative-file("/home/matt/git/e/b59064/admin/grammars/srecode-tem...")
  dired-find-file()
  funcall-interactively(dired-find-file)
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)

The `vc-git-mode-line-string' code assumes that if
`vc-git--symbolic-ref` returns nil then `vc-working-revision' must
necessarily return a full hex git rev ID, so it unconditionally performs
the following on that value:

  (substring rev 0 7)

However, Philip Kaludercic's recent commit 307ad210040 changed
`vc-working-revision' to resolve a hex ID to a symbolic revision if
possible, so in this case the function returns "master", causing
`substring' to signal as above.

This is not currently a problem in "normal" git trees because the
following command works in them:

  git symbolic-ref HEAD

...and this is what vc-git-mode-line-string normally uses to construct
the displayed revision used in that line.

In detached worktrees that command fails:

    $ git symbolic-ref HEAD
    fatal: ref HEAD is not a symbolic ref

...yet the following works:

    $ git rev-parse HEAD
    6e5ec085510ccf52ac6cb07c3a1a2778324a1d89

...and from that we can get to a symbolic name (the new code Philip
added to `vc-working-revision'):

    $ git name-rev --no-undefined --name-only 6e5ec085510ccf52ac6cb07c3a1a2778324a1d89
    master

Arguably, `vc-git-mode-line-string' should no longer call
`vc-working-revision' but instead a lower level variation that must
return the hex rev id.  Perhaps?





  reply	other threads:[~2022-11-06 18:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05 23:11 bug#59064: 29.0.50; build problem git worktree linked to main worktree (repo) Gregor Zattler
2022-11-06  0:04 ` Matt Armstrong
2022-11-06 11:30 ` Gregor Zattler
2022-11-06 14:59   ` Gregor Zattler
2022-11-06 18:17     ` Matt Armstrong [this message]
2022-11-06 18:38       ` Philip Kaludercic
2022-11-06 19:05         ` Eli Zaretskii
2022-11-07  8:52           ` Philip Kaludercic
2022-11-07 17:24             ` Matt Armstrong
2022-11-06 21:35       ` Gregor Zattler
2022-11-07 17:19         ` Matt Armstrong

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

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

  git send-email \
    --in-reply-to=87v8nsaqxp.fsf@rfc20.org \
    --to=matt@rfc20.org \
    --cc=59064@debbugs.gnu.org \
    --cc=philipk@posteo.net \
    --cc=telegraph@gmx.net \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.