I've been thinking a bit more about annex.dotfiles
in the context of
this forum post. It seems to me that annexed dotfiles can jump
to git in a way that's surprising and worth raising as a possible bug.
Say that I have repo with annex.dotfiles=true
in the .git/config,
and I add some dotfiles to the annex. Then, someone clones that repo
and goes into an adjusted state (either by running git annex adjust
--unlock
or by being on a crippled file system). In that clone,
calling annex get
on any of the annexed dotfiles will lead to those
files being added to the index as regular files. (Demo included
below.)
The above issue could be resolved by the user storing
annex.dotfiles=true
in git-annex:config.log
, but perhaps it'd be
feasible for git-annex to guard against already annexed dotfiles
migrating to git?
Thanks in advance.
git annex version | head -1
cd "$(mktemp -d --tmpdir gx-XXXXXXX)"
git init a
(
cd a
git annex init a
git config annex.dotfiles true
mkdir .reallybig
echo "a" >.reallybig/foo
git annex add .reallybig/foo
git commit -m"add foo"
)
git clone a b
(
cd b
git annex init b
git annex adjust --unlock
git annex get .reallybig
git status
git diff --cached
)
git-annex version: 8.20200226
[...]
On branch adjusted/master(unlocked)
Changes to be committed:
modified: .reallybig/foo
diff --git a/.reallybig/foo b/.reallybig/foo
index 3de500c..7898192 100644
--- a/.reallybig/foo
+++ b/.reallybig/foo
@@ -1 +1 @@
-/annex/objects/SHA256E-s2--87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7
+a
This looks like a serious regression in 8.x. It is not an intentional part of the annex.dotfiles change. I have confirmed the last 7.x release did not have the behavior.
(Notice that annex.dotfiles is not used in the repo where the problem occurs. The regression was probably introduced by the annex.dotfiles changes, but the dotfile could just as well have been added by git-annex v5 with git-annex add --include-dotfiles and the result committed to git would be the same.)
A simpler test case is to unlock the dotfile in the first repo, then all that needs to be run in its clone is
git annex get
.Analysis: Command.Smudge.shouldAnnex was changed in 3cd375723658398a4b15ff8ec19e562ec4622488 to check, for dotfiles, if annex.dotfiles is set. If not, it always returns False, so the file always gets added to git when it's smudged.
After getting a file, git-annex tells git to update its index, which smudges the file. Of course, there are also plenty of other things that can cause a file to be smudged.
Bad. Fix is very easy, luckily. It just needs to, rather than returning False, checking if the file was annexed, same as is done for non-dotfiles.