@cryptotaxi247 / kubo / commits / 8fe7d2f57

Fix refs -r -u for #1211

License: MIT Signed-off-by: Gaetan Voyer-Perrault <gatesvp@gmail.com>

gatesvp committed Jul 28, 2015 at 03:05 UTC 8fe7d2f571ea3f7c68e34f1b4d9867a2ba3d4e4c
2 files changed +24 -4
core/commands/refs.go
-4
@@ -232,10 +232,6 @@ func (rw *RefWriter) writeRefsRecursive(n *dag.Node) (int, error) {
232 return 0, err
233 }
234
235 - if rw.skip(nkey) {
236 - return 0, nil
237 - }
238 -
235 var count int
236 for i, ng := range rw.DAG.GetDAG(rw.Ctx, n) {
237 lk := key.Key(n.Links[i].Hash)
test/sharness/t0080-repo.sh
+24
@@ -163,6 +163,30 @@ test_expect_success "'ipfs pin ls --type=all --quiet' is correct" '
163 test_sort_cmp allpins_uniq_hashes actual_allpins
164 '
165
166 +test_expect_success "'ipfs refs --unique' is correct" '
167 + mkdir -p uniques &&
168 + cd uniques &&
169 + echo "content1" > file1 &&
170 + echo "content1" > file2 &&
171 + ROOT=$(ipfs add -r -q . | tail -n1) &&
172 + ipfs refs --unique $ROOT >expected &&
173 + ipfs add -q file1 >unique_hash &&
174 + test_cmp expected unique_hash
175 +'
176 +
177 +test_expect_success "'ipfs refs --unique --recursive' is correct" '
178 + mkdir -p a/b/c &&
179 + echo "c1" > a/f1 &&
180 + echo "c1" > a/b/f1 &&
181 + echo "c1" > a/b/c/f1 &&
182 + echo "c2" > a/b/c/f2 &&
183 + ROOT=$(ipfs add -r -q a | tail -n1) &&
184 + ipfs refs --unique --recursive $ROOT >refs_output &&
185 + wc -l refs_output | sed "s/^ *//g" >line_count &&
186 + echo "4 refs_output" >expected &&
187 + test_cmp expected line_count
188 +'
189 +
190 test_kill_ipfs_daemon
191
192 test_done