Skip to content

Commit 5d7dee5

Browse files
authored
Merge pull request #839 from HParker/each_key-returns-keys-without-arrays
each_key returns individual keys not wrapped in an internal array
2 parents 068075a + cbf0523 commit 5d7dee5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ext/rugged/rugged_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static int cb_config__each_key(const git_config_entry *entry, void *payload)
173173
{
174174
int *exception = (int *) payload;
175175

176-
rb_protect(rb_yield, rb_ary_new3(1, rb_str_new_utf8(entry->name)), exception);
176+
rb_protect(rb_yield, rb_str_new_utf8(entry->name), exception);
177177

178178
return (*exception != 0) ? GIT_EUSER : GIT_OK;
179179
}

test/config_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ def test_snapshot
4343
assert_nil snapshot['new.value']
4444
end
4545

46+
def test_each_key_is_a_string
47+
config = @repo.config
48+
config.each_key do |key|
49+
assert key.is_a?(String)
50+
end
51+
end
52+
53+
def test_each_pair_is_pairs
54+
config = @repo.config
55+
config.each_pair do |key, value|
56+
assert key.is_a?(String)
57+
assert value.is_a?(String)
58+
end
59+
end
60+
4661
def test_transaction
4762
config = Rugged::Config.new(File.join(@repo.path, 'config'))
4863
config['section.name'] = 'value'

0 commit comments

Comments
 (0)