Please describe the problem.
Hi,
I'm trying to sync some files to my Android phone using the adb special remote.
Of course, I have a complicated 'wanted' expression: I want new files matching a query be exported automatically on 'sync' and files added on the phone be imported automatically. I also want the files I manually export to the phone to stay where they are.
I'm still debugging my 'wanted' expression, I run 'git annex sync --content', notice it isn't syncing the right files, ctrl+C.
My worktree is left in a weird state: All the files are moved or removed. It seems git-annex made the worktree into the desired shape for syncing. However, it did that with my main worktree, which is annoying.
To recover from that, 'git reset --hard' works but I also need to do 'git add' then 'git annex fix'.
Is here a reason to use the main worktree instead of a temporary directory to do that ?
Also, it makes a branch 'android/master' which seems weird. First, it doesn't look like 'master' at all, a cryptic name would be better. This branch isn't supposed to be pushed anywhere and generates tons of conflicts every time, I don't think it should do a branch at all. Why not rebuild the desired tree into a temporary directory without storing it in git in any way ?
What steps will reproduce the problem?
Have an 'adb' remote with 'annex-tracking-branch' set to a subdirectory, 'master:subdirectory'. Kill the process while it is syncing files.
What version of git-annex are you using? On what operating system?
git-annex version: 10.20220504 Android Debug Bridge version 1.0.41 (31.0.3p1-android-tools)
Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
I've been using git-annex for a year and it has been awesome for me ! I'm trusting it more and more and that's why I'm trying new things with it.
Thanks a lot for the awesome work !
I noticed that even when the syncing finishes. Worse than that, the 'android/master' branch is merged into 'master'. The removed files are brought back during the merge, but the moved files are committed.
I definitely don't want git annex to touch my master branch. I have 'autocommit = false', 'synconlyannex = true' and 'alwayscommit = false'. I take care of merging and pushing the 'git-annex' branch myself.
Perhaps I'm not using git-annex right ?
I'm quite sure that syncing with a extporttree=yes special remote does not alter the working tree or the usual index beyond the sync command's usual commit of any staged changes. It writes the tree using
git mktree
andgit commit-tree
.I have tried to reproduce this, without any luck. I used a directory special remote not adb, but that should not possibly change anything.
Also, I don't understand what you mean by this:
What do these conflicts look like? When do they happen?
Please show a transcript of the problem happening. Ideally starting with a fresh git repository and showing all steps you used to set it up.
Here's my suspicion: You started with annex-tracking-branch set to some value, and synced. Then you changed it to some other value and synced again.
For example, if you start with it set to master:subdirectory, then change it to master, this happens on the subsequent sync:
So, files not in subdirectory get removed, and everything in subdirectory is moved out of it and into the top of the tree.
Does this behavior make sense? I am not sure, but by changing annex-tracking-branch, you have certianlly ripped the rug out from under git-annex. And that seems to more or less match what you are describing.
(Nothing to do with being interrupted, and no merge conflicts though.)
The reason that happens is that the remote tracking branch has a tree with "subdirectory/bigfile" and "foo" in it. The new tree imported from the remote, after changing annex-tracking-branch, has "bigfile" in it. So the result is the same as if a regular git remote used to contain that old tree, and has been updated to the new tree.
git merge
with a remote where that has happened naturally updates master to move "subdirectory/bigfile" to "bigfile" and to delete "foo".I think this does beg the question of how to safely change annex-tracking-branch. One way is to sync, change it, sync again. Then revert the commit that imports from the remote. That gets the tree back into the state it was before, and then syncing again will update the remote.
Perhaps git-annex should detect when the annex-tracking-branch config has changed, and somehow handle this better, or just refuse to sync?
Yes, I did change the 'annex-tracking-branch' in the way you described. I was trying various values and I guess I expected git-annex not to keep any state after I interrupted the transfer (a few files were transfered).
I suspect the merge conflicts (on the android/master branch) were a combination of interrupting the process and changing the config back and forth. I think I could see them because my git config (name, email) is temporarily broken if the worktree is changed, which interrupted the committing.
I would expect git-annex to remember what happened only if it completed. In the case of adb, transfer is pretty slow and it's not likely to ever terminate (if I didn't meant to sync that many files, I won't wait days for it to complete). The impacted files were all the files to be synced, only a fraction of which was actually synced.