add --dereference-args parameter
License: MIT Signed-off-by: Dominic Della Valle <ddvpublic@gmail.com>
Dominic Della Valle committed
Apr 23, 2018 at 20:22 UTC
5a02b98702a91f6dfa56f2c25ca17efbe3e91671
2 files changed
+16
core/commands/add.go
+1
@@ -100,6 +100,7 @@ You can now check what blocks have been created by:
100
},
101
Options: []cmdkit.Option{
102
cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
103
+ cmds.OptionDerefArgs, // a builtin option that resolves passed in filesystem links (--dereference-args)
104
cmdkit.BoolOption(quietOptionName, "q", "Write minimal output."),
105
cmdkit.BoolOption(quieterOptionName, "Q", "Write only final hash."),
106
cmdkit.BoolOption(silentOptionName, "Write no output."),
test/sharness/t0040-add-and-cat.sh
+15
@@ -347,6 +347,19 @@ test_add_cat_raw() {
347
'
348
}
349
350
+test_add_cat_derefargs() {
351
+ test_expect_success "create and hash zero length file" '
352
+ touch zero-length-file &&
353
+ ZEROHASH=$(ipfs add -q -n zero-length-file)
354
+ '
355
+
356
+ test_expect_success "create symlink and add with dereferenced arguments" '
357
+ ln -s zero-length-file symlink-to-zero &&
358
+ HASH=$(ipfs add -q -n --dereference-args symlink-to-zero) &&
359
+ test $HASH = $ZEROHASH
360
+ '
361
+}
362
+
363
test_add_cat_expensive() {
364
ADD_FLAGS="$1"
365
HASH="$2"
@@ -720,6 +733,8 @@ test_expect_success "ipfs add --only-hash succeeds" '
733
echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash
734
'
735
736
+test_add_cat_derefargs
737
+
738
#TODO: this doesn't work when online hence separated out from test_add_cat_file
739
test_expect_success "ipfs cat file fails" '
740
test_must_fail ipfs cat $(cat oh_hash)