omar-polo / vc-got

Emacs VC backend for Game of Tree
https://projects.omarpolo.com/vc-got.html
GNU General Public License v3.0
1 stars 2 forks source link

vc-root-diff fails in home directory #18

Open zmyrgel opened 3 weeks ago

zmyrgel commented 3 weeks ago

If I have got worktree in ~/dotfiles and use {C-x v D} to see vc-root-diff the command fails to list anything and shows:

got: ~/dotfiles: No such file or directory

Problem is the short hand path for home directory which I guess is passed to got binary as is. This can be solved by following small diff:

vc-got.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/vc-got.el b/vc-got.el
index 1d09771..513d137 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -756,6 +756,7 @@ Heavily inspired by `vc-git-log-view-mode'."
   "Insert into BUFFER (or *vc-diff*) the diff for FILES from REV1 to REV2."
   (let* ((buffer (get-buffer-create (or buffer "*vc-diff*")))
          (inhibit-read-only t))
+    (setq files (mapcar #'expand-file-name files))
     (with-current-buffer buffer
       (vc-got-with-worktree (or (car files)
                                 default-directory)

The diff just expands the files passed to diff command. But instead of doing it just for diff, would it be better to expand vc-got--call to take files parameter separately so it can expand the filenames for all commands?

omar-polo commented 2 weeks ago

TIL of C-x v D, i've always used vc-dir (C-x v d) which most of the times defaults to the root of the work tree.

I can reproduce the problem, and will look into it soon. I'm scared that calling expand-file-name like that could have unwanted side effects.

zmyrgel commented 2 weeks ago

I doubt it has any unwanted side effects but the patch is ugly.

I was thinking should the fix be even in the vc-level. Is there any reason the generic layer to pass these "short paths" to any vc-backends instead of always expanding them.

IIRC the path is coming from result of default-directory call in vc side. I think at least some of such pass go through expand-file-name but I didn't do full audit of them.

On Sun, Oct 6, 2024, at 17:59, Omar Polo wrote:

TIL of C-x v D, i've always used vc-dir (C-x v d) which most of the times defaults to the root of the work tree.

I can reproduce the problem, and will look into it soon. I'm scared that calling expand-file-name like that could have unwanted side effects.

— Reply to this email directly, view it on GitHub https://github.com/omar-polo/vc-got/issues/18#issuecomment-2395470093, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAI72SR53OKXDZ6RSC756LZ2FF6PAVCNFSM6AAAAABPIGPK2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJVGQ3TAMBZGM. You are receiving this because you authored the thread.Message ID: @.***>