all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* vc-dir fails if Git upstream branch is local
@ 2023-04-30  8:58 Tobias Bading
  2023-04-30  9:09 ` Philip Kaludercic
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Bading @ 2023-04-30  8:58 UTC (permalink / raw)
  To: emacs-devel

Hi.

Is it just me, am I using Git wrong, or does vc-dir fail for everyone in a
working tree whose upstream branch is a local branch, not a remote-tracking
branch?

I have a local branch named “my-emacs-29” which was created from “emacs-29”,
which is my local branch that tracks “origin/emacs-29”.

After a “git branch --set-upstream-to=origin/emacs-29”, vc-dir works just
fine and its buffer contains

Remote     : git://git.sv.gnu.org/emacs.git

After “git branch --unset-upstream”, vc-dir still works and its buffer does
not contain a Remote line (as expected).

Things go sideways after a “git branch --set-upstream-to=emacs-29”. This
works fine with Git 2.40.0 on GNU/Linux in a shell. “git status” correctly
prints

Your branch is ahead of 'emacs-29' by 9 commits.

But vc-dir fails completely with

Failed (status 2): git --no-pager remote get-url . .

in *Messages*. This is caused by vc-git-dir-extra-headers running
“git config branch.my-emacs-29.remote”, which returns a period due to
.git/config containing

[branch "my-emacs-29"]
     remote = .

Then vc-git-repository-url runs “git --no-pager remote get-url .”, which
produces

error: No such remote '.'

in a shell.

It looks like this is fixable with a simple

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 7ae763d2ee..cdeebd9e0b 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -770,7 +770,7 @@ vc-git-dir-extra-headers
                                      (concat "branch." branch
".remote")))))
        (when (string-match "\\([^\n]+\\)" remote)
          (setq remote (match-string 1 remote)))
-          (when (> (length remote) 0)
+          (when (> (length remote) 1)
          (setq remote-url (vc-git-repository-url dir remote))))
        (setq branch "not (detached HEAD)"))
      (when stash-list

Am I the only one who uses upstream branches this way? If you have a local
feature branch created from another local branch, doesn’t it make sense to
have it track the local branch it was created from? Especially if both
branches are local and never have been pushed to any remote.

Tobias

PS: please keep me CC’d, thanks




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: vc-dir fails if Git upstream branch is local
  2023-04-30  8:58 vc-dir fails if Git upstream branch is local Tobias Bading
@ 2023-04-30  9:09 ` Philip Kaludercic
  0 siblings, 0 replies; 2+ messages in thread
From: Philip Kaludercic @ 2023-04-30  9:09 UTC (permalink / raw)
  To: Tobias Bading; +Cc: emacs-devel

Tobias Bading <tbading@web.de> writes:

> Hi.
>
> Is it just me, am I using Git wrong, or does vc-dir fail for everyone in a
> working tree whose upstream branch is a local branch, not a remote-tracking
> branch?

I think you should report this as a bug.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-30  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-30  8:58 vc-dir fails if Git upstream branch is local Tobias Bading
2023-04-30  9:09 ` Philip Kaludercic

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.