help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GIT_DIR unset in vc-git.el


From: Emre Yolcu
Subject: Re: GIT_DIR unset in vc-git.el
Date: Tue, 30 Apr 2024 16:12:01 -0400
User-agent: Mozilla Thunderbird

`vc-region-history` says that the commit which introduced this GIT_DIR
override is:

     commit dc5e65b5deb2f5b67f6c3a06ae81c6b074bd4b56
     Author: Dmitry Gutov <dgutov@yandex.ru>
     Date:   Wed Jun 22 02:04:33 2016 +0300
Unset GIT_DIR when calling Git commands * lisp/vc/vc-git.el (vc-git--call, vc-git-command):
         Unset GIT_DIR (bug#23769).

So you can check bug#23769 for further info.

Thanks for the pointer; the discussion on bug#23769 has been helpful in solving my issue.

   (defun git-link-home ()
     (interactive)
     (let ((process-environment
            `(,(format "GIT_DIR=%s" (expand-file-name "~/.home.git/"))
              ,(format "GIT_WORK_TREE=%s" (expand-file-name "~/"))
              ,@process-environment)))
       (recursive-edit)))

Maybe you can save yourself the trouble.

     cd ~/.home.git; git worktree add ~ main

won't work because it will complain that ~ "already exists", but that's
just Git being too protective.  You can "do it by hand":

     cd ~/.home.git; git worktree add ~/dummy main
     mv ~/dummy/.git ~/.
     sed -i s/.dummy// ~/.home.git/worktrees/dummy/gitdir

and then your home's Git data will still be stored in that bare
`.home.git` but without having to mess with `GIT_DIR` and
`GIT_WORK_TREE`.  The only/main difference is that you'll now have
a `~/.git` file (which points at `~/.home.git/worktrees/dummy`).

If I understood the suggestion correctly, this would make every invocation of git under my home directory think that it is in a repository. This is not my goal, since I rarely work on maintaining my home directory but often on other Git repositories residing somewhere in home. With the "linking" approach above, I enter recursive edit, work on some configuration files, and exit when I am done so that git becomes unaware that home is kept under version control.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]