Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions list.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr)
} else {
struct uci_section *old = ptr->s;
ptr->s = uci_alloc_section(ptr->p, ptr->value, old->e.name, &old->e.list);
ptr->s->anonymous = old->anonymous;
uci_section_transfer_options(ptr->s, old);
if (ptr->section == old->e.name)
ptr->section = ptr->s->e.name;
Expand Down
16 changes: 16 additions & 0 deletions tests/shunit2/tests.d/030_set
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,19 @@ test_set_existing_option_multiline()
World\""
assertSameFile ${REF_DIR}/set_existing_option_multiline.result ${CHANGES_DIR}/set
}

test_set_anonymous_section_type_preserves_anonymous()
{
cat > ${CONFIG_DIR}/set << 'EOF_CONFIG'
config short
option value 'kept'
EOF_CONFIG

${UCI} set 'set.@short[0]=longer'
${UCI} commit set

output=$(${UCI} export set)
echo "$output" | grep -q '^config longer$'
assertTrue "changing an anonymous section type makes it named" $?
assertEquals "kept" "$(${UCI} get 'set.@longer[0].value')"
}
Loading