summaryrefslogtreecommitdiff
path: root/doc/bugs/git_annex_unused_considers_remote_branches_which_makes_it_inconsistent.mdwn
blob: 86151d116c8616ac0d07a2d2abfffa6670f1a088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
The "git annex unused" command considers remote branches as well as local branches.  This means that an
object may be considered unused or not depending on what remotes are present and when they were last synced.

I ran into this issue when experimenting with using repos on removable storage.  I'll post more about
what I was trying to do in the forum.  I'm posting this in bugs as I believe the inconsistent behavior
should probably be considered a bug.

#What steps will reproduce the problem?

Here is a sample session illustrating the problem.  At the end, you can see that the object is
not shown as unused, then the remote is removed and it is shown as unused, then the remote is added
back and the file is once again not shown as unused.

    /tmp/git $ mkdir 1 2
    /tmp/git $ cd 1
    /tmp/git/1 $ git init
    Initialized empty Git repository in /tmp/git/1/.git/
    /tmp/git/1 $ git annex init 1
    init 1 ok
    (Recording state in git...)
    /tmp/git/1 $ git remote add 2 ../2
    /tmp/git/1 $ dd if=/dev/urandom of=file.bin count=100
    100+0 records in
    100+0 records out
    51200 bytes (51 kB) copied, 0.0113172 s, 4.5 MB/s
    /tmp/git/1 $ git annex add file.bin 
    add file.bin (checksum...) ok
    (Recording state in git...)
    /tmp/git/1 $ git commit -m 'added file'
    [master (root-commit) 3c1ad30] added file
     1 files changed, 1 insertions(+), 0 deletions(-)
     create mode 120000 file.bin
    /tmp/git/1 $ cd ../2
    /tmp/git/2 $ git init
    Initialized empty Git repository in /tmp/git/2/.git/
    /tmp/git/2 $ git annex init 2
    init 2 ok
    (Recording state in git...)
    /tmp/git/2 $ git remote add 1 ../1
    /tmp/git/2 $ git fetch 1
    warning: no common commits
    remote: Counting objects: 13, done.
    remote: Compressing objects: 100% (9/9), done.
    remote: Total 13 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (13/13), done.
    From ../1
     * [new branch]      git-annex  -> 1/git-annex
     * [new branch]      master     -> 1/master
    /tmp/git/2 $ git checkout -b master 1/master
    Branch master set up to track remote branch master from 1.
    Already on 'master'
    /tmp/git/2 $ cd ../1
    /tmp/git/1 $ git fetch 2
    remote: Counting objects: 5, done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 5 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (5/5), done.
    From ../2
     * [new branch]      git-annex  -> 2/git-annex
     * [new branch]      master     -> 2/master
    /tmp/git/1 $ git rm file.bin 
    rm 'file.bin'
    /tmp/git/1 $ git commit -m 'rmed file'
    [master ab242b0] rmed file
     1 files changed, 0 insertions(+), 1 deletions(-)
     delete mode 120000 file.bin
    /tmp/git/1 $ git annex unused
    unused . (checking for unused data...) (checking master...) (checking 2/master...) ok
    /tmp/git/1 $ git remote rm 2
    /tmp/git/1 $ git annex unused
    unused . (checking for unused data...) (checking master...) 
      Some annexed data is no longer used by any files:
        NUMBER  KEY
        1       SHA256E-s51200--e400e5abea095ad4364d8f97c5fe1a3f8a6db670b2dfee951d7c9674afc9a21d.bin
      (To see where data was previously used, try: git log --stat -S'KEY')
      
      To remove unwanted data: git-annex dropunused NUMBER
      
    ok
    /tmp/git/1 $ git remote add 2 ../2
    /tmp/git/1 $ git fetch 2
    From ../2
     * [new branch]      git-annex  -> 2/git-annex
     * [new branch]      master     -> 2/master
    /tmp/git/1 $ git annex unused
    unused . (checking for unused data...) (checking master...) (checking 2/master...) ok
    /tmp/git/1 $ 


#What is the expected output? What do you see instead?

I expected that the object's unused status would not change based on which remotes this particular
repo knows about.  In other words, I expected the unused status to be based on the local branches
and possibly information in the git-annex branch.

#What version of git-annex are you using? On what operating system?

Gentoo Linux, git annex version 3.20121211

#Please provide any additional information below.

The forum post describing what I was trying to accomplish is [[forum/Best way to manage files on removable media?]]

> While it would be nice if git-annex unused could somehow know about
> branches that exist on remotes that git doesn't have locally, this is
> impossible. It does the best it can. [[done]] --[[Joey]]