summaryrefslogtreecommitdiff
path: root/doc/bugs/sync_does_not_commit_with_alwasycommit___61___false.mdwn
blob: 9b7ec7cf511b4455bf1c208f83df825f27416b50 (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
### Please describe the problem.

The documentation of `git annex sync` states

> The sync process involves first committing all local changes, then fetching and merging […]
> You can use standard git commands to do each of those steps  by  hand,  or  if  you
> don't want to worry about the details, you can use sync.

The documentation of `alwasycommit` states

> By default, git-annex automatically commits data to the git-annex branch after each
> command is run. To disable these commits, set to false. Then data will only be
> committed when running `git annex merge` (or by automatic merges) or `git annex sync`.

In fact, however, `git annex sync` will not commit or will not commit some pieces of information when `alwasycommit` is false. This leads to various problems, the first of which is that cloned repositories do not have information about the other remotes.

It is hard to work around this problem because `git commit` cannot be used in direct mode.

This problem does not show up when using local, non over-the-network, remotes.

### What steps will reproduce the problem?

The following script (available at <https://gist.github.com/gioele/5ffeff8988a535164e5b>) will reproduce this problem. If you do not have SSH running on localhost, you can change the `h` variable to point to another host.

    #!/bin/sh -x

    set -e ; set -u
    export LC_ALL=C

    h=${h:-localhost}
    dr="/tmp/annex"

    chmod a+rwx -R pc1 pc2 || true
    rm -Rf pc1 pc2

    # create central git repo
    ssh $h "chmod a+rwx -R ${dr}/Docs.git" || true
    ssh $h "rm -Rf ${dr}/Docs.git"
    ssh $h "mkdir -p ${dr}/Docs.git"
    ssh $h "cd ${dr}/Docs.git ; git init --bare"

    d=$(pwd)

    # populate repo in PC1
    mkdir -p pc1/Docs
    cd pc1/Docs
    echo AAA > fileA
    echo BBB > fileB

    git init
    git config annex.alwayscommit false # change to true to solve this problem

    git remote add origin $h:$dr/Docs.git
    git fetch --all

    # simulate a host without git-annex
    git config remote.origin.annex-ignore true

    git annex init "pc1"
    git annex info

    git annex direct
    git annex sync origin

    git annex add .
    git annex sync

    # re-create repo on PC2
    cd $d
    mkdir -p pc2
    cd pc2
    git clone $h:$dr/Docs.git
    cd Docs

    git config remote.origin.annex-ignore true

    git annex init "pc2"
    git annex direct
    git annex info

    # git annex info shows only pc2, shouldn't pc1 be there as well?

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

git-annex version: 5.20140708-g8c9c55c on Ubuntu 12.04.4

> I have improved the documentation to not imply that sync/merge are a
> special case. They honor the autocommit settings more or less
> intentionally, and to get a commit to be made, just pass -c
> autocommit=true when running them. [[done]] --[[Joey]]