diff --git a/core/commands/add.go b/core/commands/add.go index ca29f99de..6e1b63dc1 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -100,6 +100,7 @@ You can now check what blocks have been created by: }, Options: []cmdkit.Option{ cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive) + cmds.OptionDerefArgs, // a builtin option that resolves passed in filesystem links (--dereference-args) cmdkit.BoolOption(quietOptionName, "q", "Write minimal output."), cmdkit.BoolOption(quieterOptionName, "Q", "Write only final hash."), cmdkit.BoolOption(silentOptionName, "Write no output."), diff --git a/test/sharness/t0040-add-and-cat.sh b/test/sharness/t0040-add-and-cat.sh index 50b7e1ea2..134eb6354 100755 --- a/test/sharness/t0040-add-and-cat.sh +++ b/test/sharness/t0040-add-and-cat.sh @@ -347,6 +347,19 @@ test_add_cat_raw() { ' } +test_add_cat_derefargs() { + test_expect_success "create and hash zero length file" ' + touch zero-length-file && + ZEROHASH=$(ipfs add -q -n zero-length-file) + ' + + test_expect_success "create symlink and add with dereferenced arguments" ' + ln -s zero-length-file symlink-to-zero && + HASH=$(ipfs add -q -n --dereference-args symlink-to-zero) && + test $HASH = $ZEROHASH + ' +} + test_add_cat_expensive() { ADD_FLAGS="$1" HASH="$2" @@ -720,6 +733,8 @@ test_expect_success "ipfs add --only-hash succeeds" ' echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash ' +test_add_cat_derefargs + #TODO: this doesn't work when online hence separated out from test_add_cat_file test_expect_success "ipfs cat file fails" ' test_must_fail ipfs cat $(cat oh_hash)