ptr->last = &ptr->o->e;
}
} else if (ptr->s && ptr->section) { /* update section */
- struct uci_section *old = ptr->s;
- ptr->s = uci_alloc_section(ptr->p, ptr->value, old->e.name, &old->e.list);
- uci_section_transfer_options(ptr->s, old);
- if (ptr->section == old->e.name)
- ptr->section = ptr->s->e.name;
- uci_free_section(old);
- ptr->s->package->n_section--;
- ptr->last = &ptr->s->e;
+ if (!strcmp(ptr->s->type, ptr->value))
+ return 0;
+
+ if (strlen(ptr->s->type) == strlen(ptr->value)) {
+ strcpy(ptr->s->type, ptr->value);
+ } else {
+ struct uci_section *old = ptr->s;
+ ptr->s = uci_alloc_section(ptr->p, ptr->value, old->e.name, &old->e.list);
+ uci_section_transfer_options(ptr->s, old);
+ if (ptr->section == old->e.name)
+ ptr->section = ptr->s->e.name;
+ uci_free_section(old);
+ ptr->s->package->n_section--;
+ ptr->last = &ptr->s->e;
+ }
} else {
UCI_THROW(ctx, UCI_ERR_INVAL);
}
# save new changes in "$new_savedir"
mkdir -p "$new_savedir"
touch "$new_savedir/delta"
- $UCI -P "$new_savedir" set delta.sec0=sectype
+ $UCI -P "$new_savedir" set delta.sec0=tmptype
$UCI -P "$new_savedir" add_list delta.sec0.li0=1
+ $UCI -P "$new_savedir" set delta.sec0=sectype
assertEquals "delta.sec0='sectype'
delta.sec0.li0+='0'" "$($UCI changes)"
assertTrue "$?"
assertEquals "delta.sec0='sectype'
delta.sec0.li0+='0'
-delta.sec0='sectype'
-delta.sec0.li0+='1'" "$cmdoutput"
+delta.sec0='tmptype'
+delta.sec0.li0+='1'
+delta.sec0='sectype'" "$cmdoutput"
# check combined export. Order matters here.
cmdoutput="$($UCI -P "$new_savedir" export)"