TheLocehiliosan / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
4.91k stars 176 forks source link

Checkout files to $HOME worktree not working #479

Closed perrefe closed 4 months ago

perrefe commented 4 months ago

Description

I have encountered that yadm clone (with default options) don't place the files where it should be and don't run bootstrap script either.

I am very aware that it is a very strange situation, since it is one of the most basic things in yadm and I did not find anyone who had the same problem as mine.

The thing is that when yadm clones the repository the files it brings to the worktree do not exist and git status shows them as deleted and staged

$yadm status
Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
deleted: ../../../.config/yadm/bootstrap

As I see in the clone() function, it executes the command git ls-files --deleted, however, with the files in the stage, this command does not deliver any results, so it doesn't iterate over them so the checkout is not done.

I saw that after the checkout the git reset --quiet -- . command is executed, but I see that it doesn't generate the expected result. I just simply changed the command to git reset and in that way the file get unstaged

$yadm status
Unstaged changes after reset:
D.config/yadm/bootstrap

Then, git ls-files --deleted finds it and checks it out, causing the files to now remain in the worktree and the bootstrap script to be executed correctly

Environment

macos version: Sonoma 14.0 bash version: 3.2.57(1)-release git version 2.39.3 (Apple Git-145) yadm version 3.2.2

PD: I tried with brew installed git (2.43.1) and the situation didn't change

TheLocehiliosan commented 4 months ago

Can you post the complete clone command you are running and the complete output of the command?

perrefe commented 4 months ago

The clone command is executed by yadm, so it is:

"$GIT_PROGRAM" -c core.sharedrepository=0600 clone --no-checkout \
                      --separate-git-dir="$YADM_REPO" "${args[@]}" repo.git

after executing yadm clone --bootstrap https://github.com/me/mydotfiles the worktree at $HOME doesn't have any file, so bootstrap script is not executed, and yadm status shows

Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
deleted: ../../../.config/yadm/bootstrap
perrefe commented 4 months ago

IMHO I think the "$GIT_PROGRAM" reset --quiet -- . command should just be "$GIT_PROGRAM" reset --quiet, the dot in the pathspec represents the same as not specifying anything and maybe this carries some compatibility issues.

(unless you are thinking in some whitelist feature that can rely in the reset pathspec)

TheLocehiliosan commented 4 months ago

From the description above it sounds like you do not have your bootstrap program committed to the repository. Is it possible to show me an example dotfiles repo that exhibits this problem?

TheLocehiliosan commented 4 months ago

Also, by clone command, I meant for you to share the "yadm clone" command and all of its output (not the "git clone" command that yadm runs).

perrefe commented 4 months ago

Here is an example dot files repo: https://github.com/perrefe/dotfiles.git

The clone command I'm using is: yadm clone --bootstrap https://github.com/perrefe/dotfiles.git

TheLocehiliosan commented 4 months ago

Can you show me the full output of the yadm clone command? I've cloned that repo, and did not encounter any issue (when running the bootstrap too).

perrefe commented 4 months ago
perrefe@mb ~ %ls -l .config/                      
total 0
perrefe@mb ~ %ls -l .local/share                  
total 0
perrefe@mb ~ %
perrefe@mb ~ %yadm clone --bootstrap https://github.com/perrefe/dotfiles.git
Cloning into 'repo.git'...
remote: Enumerating objects: 55, done.
remote: Counting objects: 100% (55/55), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 55 (delta 9), reused 55 (delta 9), pack-reused 0
Receiving objects: 100% (55/55), 17.85 KiB | 299.00 KiB/s, done.
Resolving deltas: 100% (9/9), done.
Executing /Users/perrefe/.config/yadm/bootstrap

                 _            
 _   _  __ _  __| |_ __ ___   
| | | |/ _` |/ _` | '_ ` _ \  
| |_| | (_| | (_| | | | | | | 
 \__, |\__,_|\__,_|_| |_| |_| 
 |___/                        
                  ...bootstrap

perrefe@mb ~ %ls -l .config/                                                
total 0
drwxr-xr-x  6 perrefe  staff  192 Mar  6 21:38 nvim
drwxr-xr-x  3 perrefe  staff   96 Mar  6 21:38 yadm
perrefe@mb ~ %rm -rf .config/nvim .config/yadm                             
perrefe@mb ~ %ls -l .local/share/yadm                                       
total 0
drwx------  12 perrefe  staff  384 Mar  6 21:38 repo.git
perrefe@mb ~ %rm -rf .local/share/yadm

It's working now :| and cannot reproduce anymore.

A very important thing was changed by a system update applied yesterday

perrefe@mb ~ %git --version
git version 2.39.3 (Apple Git-146)

I'm not sure if that was the real problem, but the thing is now operational. I really appreciate all your attention, thanks!