summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_state.erl7
-rw-r--r--test/rebar_profiles_SUITE.erl12
2 files changed, 17 insertions, 2 deletions
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 09f1c43..2f8ab59 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -204,6 +204,13 @@ apply_profiles(State=#state_t{opts=Opts, current_profiles=CurrentProfiles}, Prof
merge_opts(Profile, NewOpts, OldOpts) ->
Opts = dict:merge(fun(_Key, NewValue, OldValue) when is_list(NewValue) ->
case io_lib:printable_list(NewValue) of
+ true when NewValue =:= [] ->
+ case io_lib:printable_list(OldValue) of
+ true ->
+ NewValue;
+ false ->
+ OldValue
+ end;
true ->
NewValue;
false ->
diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl
index 0b378cb..03a8090 100644
--- a/test/rebar_profiles_SUITE.erl
+++ b/test/rebar_profiles_SUITE.erl
@@ -85,10 +85,14 @@ profile_merge_keys(Config) ->
profile_merges(_Config) ->
RebarConfig = [{test1, [{key1, 1, 2}, key2]},
{test2, "hello"},
+ {test3, [key3]},
+ {test4, "oldvalue"},
{profiles,
[{profile1,
[{test1, [{key3, 5}, key1]}]},
- {profile2, [{test2, "goodbye"}]}]}],
+ {profile2, [{test2, "goodbye"},
+ {test3, []},
+ {test4, []}]}]}],
State = rebar_state:new(RebarConfig),
State1 = rebar_state:apply_profiles(State, [profile1, profile2]),
@@ -97,4 +101,8 @@ profile_merges(_Config) ->
lists:sort(rebar_state:get(State1, test1))),
%% Use new value for strings
- "goodbye" = rebar_state:get(State1, test2).
+ "goodbye" = rebar_state:get(State1, test2),
+
+ %% Check that a newvalue of []/"" doesn't override non-string oldvalues
+ [key3] = rebar_state:get(State1, test3),
+ [] = rebar_state:get(State1, test4).