-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clone: accept config options on the command line
Clone does all of init, "remote add", fetch, and checkout without giving the user a chance to intervene and set any configuration. This patch allows you to set config options in the newly created repository after the clone, but before we do any other operations. In many cases, this is a minor convenience over something like: git clone git://... git config core.whatever true But in some cases, it can bring extra efficiency by changing how the fetch or checkout work. For example, setting line-ending config before the checkout avoids having to re-checkout all of the contents with the correct line endings. It also provides a mechanism for passing information to remote helpers during a clone; the helpers may read the git config to influence how they operate. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Jeff King
authored and
Junio C Hamano
committed
Jun 22, 2011
1 parent
2496844
commit 84054f7
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
|
||
test_description='tests for git clone -c key=value' | ||
. ./test-lib.sh | ||
|
||
test_expect_success 'clone -c sets config in cloned repo' ' | ||
rm -rf child && | ||
git clone -c core.foo=bar . child && | ||
echo bar >expect && | ||
git --git-dir=child/.git config core.foo >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_expect_success 'clone -c can set multi-keys' ' | ||
rm -rf child && | ||
git clone -c core.foo=bar -c core.foo=baz . child && | ||
{ echo bar; echo baz; } >expect && | ||
git --git-dir=child/.git config --get-all core.foo >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_expect_success 'clone -c without a value is boolean true' ' | ||
rm -rf child && | ||
git clone -c core.foo . child && | ||
echo true >expect && | ||
git --git-dir=child/.git config --bool core.foo >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_expect_success 'clone -c config is available during clone' ' | ||
echo content >file && | ||
git add file && | ||
git commit -m one && | ||
rm -rf child && | ||
git clone -c core.autocrlf . child && | ||
printf "content\\r\\n" >expect && | ||
test_cmp expect child/file | ||
' | ||
|
||
test_done |