You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a subdirectory that's a git submodule prefixed with external_, chezmoi apply will clone it into the correct place, but running chezmoi add on the parent (target) directory will attempt to (a) add the cloned submodule without the external_ attribute and (b) delete the submodule.
I was surprised by this because the directory corresponding to the submodule was created by Chezmoi, and no changes were made to it. I'd expect apply immediately followed by add to (generally) not have anything to do.
To reproduce
create a submodule within Chezmoi's source directory, prefixed with external_
run chezmoi apply
run chezmoi add <target directory housing the submodule>
Expected behavior
No change in source state.
Output of command with the --verbose flag
$ git status # In Chezmoi source dirHEAD detached at 7392844Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) deleted: normal-dir/external_repro-submoduleUntracked files: (use "git add <file>..." to include in what will be committed) normal-dir/repro-submodule/no changes added to commit (use "git add" and/or "git commit -a")
Output of chezmoi doctor
$ chezmoi doctorRESULT CHECK MESSAGEwarning version v2.42.2, built at 2023-12-06T22:39:17Z, built by Alpine Linuxwarning latest-version v2.46.0ok os-arch linux/amd64 (Alpine Linux)ok uname Linux runner-zxwgkjap-project-54387395-concurrent-0 5.4.109+ #1 SMP Wed Jun 16 20:00:10 PDT 2021 x86_64 Linuxok go-version go1.21.4 (gc)ok executable /usr/bin/chezmoiok upgrade-method upgrade-packageok config-file no config file foundwarning source-dir /builds/detly/chezmoi-externals-repro is a git working tree (dirty)ok suspicious-entries no suspicious entrieswarning working-tree /builds/detly/chezmoi-externals-repro is a git working tree (dirty)ok dest-dir ~ is a directoryok umask 022ok cd-command found /bin/ashok cd-args /bin/ashinfo diff-command not setok edit-command found /usr/bin/viok edit-args /usr/bin/viok git-command found /usr/bin/git, version 2.43.0warning merge-command vimdiff not found in $PATHok shell-command found /bin/ashok shell-args /bin/ashinfo age-command age not found in $PATHinfo gpg-command gpg not found in $PATHinfo pinentry-command not setinfo 1password-command op not found in $PATHinfo bitwarden-command bw not found in $PATHinfo bitwarden-secrets-command bws not found in $PATHinfo dashlane-command dcli not found in $PATHinfo doppler-command doppler not found in $PATHinfo gopass-command gopass not found in $PATHinfo keepassxc-command keepassxc-cli not found in $PATHinfo keepassxc-db not setinfo keeper-command keeper not found in $PATHinfo lastpass-command lpass not found in $PATHinfo pass-command pass not found in $PATHinfo passhole-command ph not found in $PATHinfo rbw-command rbw not found in $PATHinfo vault-command vault not found in $PATHinfo vlt-command vlt not found in $PATHinfo secret-command not set
Thank you very much for reporting this and particularly for your work in creating a test case that perfectly reproduces the problem. Very much appreciated!
The root cause of this is similar to #1574 and #3559, namely that chezmoi add is currently buggy when handling adding entries that come from externals.
Describe the bug
Given a subdirectory that's a git submodule prefixed with
external_
,chezmoi apply
will clone it into the correct place, but runningchezmoi add
on the parent (target) directory will attempt to (a) add the cloned submodule without theexternal_
attribute and (b) delete the submodule.I was surprised by this because the directory corresponding to the submodule was created by Chezmoi, and no changes were made to it. I'd expect
apply
immediately followed byadd
to (generally) not have anything to do.To reproduce
external_
chezmoi apply
chezmoi add <target directory housing the submodule>
Expected behavior
No change in source state.
Output of command with the
--verbose
flagOutput of
chezmoi doctor
Additional context
There is a git repo that reproduces this issue here, with a CI job to run the steps and show the output.
The text was updated successfully, but these errors were encountered: