Skip to content

Commit a96250c

Browse files
peffgitster
authored andcommitted
test-lib: add test_config_global variant
The point of test_config is to simultaneously set a config variable and register its cleanup handler, like: test_config core.foo bar However, it stupidly assumes that $1 contained the name of the variable, which means it won't work for: test_config --global core.foo bar We could try to parse the command-line ourselves and figure out which parts need to be fed to test_unconfig. But since this is likely the most common variant, it's much simpler and less error-prone to simply add a new function. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 017d1e1 commit a96250c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

t/test-lib.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ test_config () {
379379
git config "$@"
380380
}
381381

382+
test_config_global () {
383+
test_when_finished "test_unconfig --global '$1'" &&
384+
git config --global "$@"
385+
}
386+
382387
# Use test_set_prereq to tell that a particular prerequisite is available.
383388
# The prerequisite can later be checked for in two ways:
384389
#

0 commit comments

Comments
 (0)