git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH RFC] init-db: introduce new -c/--config option

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 25, 2015, 20:30 UTC
Message-ID
<CAPig+cREbg0VZyzL7na6QfOpBK3_Ydw3u-rdNOpcs4DG3=RbOw@mail.gmail.com>
In-Reply-To
<1427307759-18679-1-git-send-email-kuleshovmail@gmail.com>

On Wed, Mar 25, 2015 at 2:22 PM, Alexander Kuleshov <kuleshovmail@gmail.com> wrote:

> For now we can clone repository with the `git clone` command and pass
> -c/--config with configuration option to it and these configuration
> options will be set in the clonned repository config.
s/clonned/cloned/
> This patch provides the same functional, but for the `git init` command.
s/functional/functionality/
Show 5 quoted lines
> It allows to pass -c/--config option to the `git init` command and
> given configuration option will be added to the newly created repository,
> after it will be created.
>
> This option can be used multiply times. If given configuration option
s/multiply/multiple/
Show 19 quoted lines
> is the same that in the default config, given option will overwrite.
>
> Main purpose of this option is to get rid of the manual editing of
> the config.
>
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
> ---
> diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt
> index 8174d27..3ecbf2a 100644
> --- a/Documentation/git-init.txt
> +++ b/Documentation/git-init.txt
> @@ -111,6 +111,15 @@ into it.
>  If you provide a 'directory', the command is run inside it. If this directory
>  does not exist, it will be created.
>
> +--config <key>=<value>::
> +-c <key>=<value>::
> +Set a new configuration option in the new repository. The <key> expected in
> +the same format as linkgit:git-config[1] (e.g., `core.eol=true`). If
"If" what?
> +This option can be used multiply times. If multiply options are given with
s/multiply/multiple/g
Show 16 quoted lines
> +the same keys, each value will be written to the config. If given key is
> +the same that used in the default configuration file, previous value
> +will be overwritten.
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index 7de8d85..8ce3537 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -339,4 +339,20 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
>         test_path_is_dir realgitdir/refs
>  '
>
> +test_expect_success 'git init -c key=value' '
> +       rm -rf newdir realgitdir &&
> +       git init -c core.foo=bar newdir &&
> +       echo bar >expect &&
> +       git --git-dir=newdir/.git config core.foo >actual &&
Maybe "git -C newdir ..." instead?
Show 9 quoted lines
> +       test_cmp expect actual
> +'
> +
> +test_expect_success 'git init -c key=value override default value' '
> +       rm -rf newdir &&
> +       git init -c core.filemode=false newdir &&
> +       echo false >expect &&
> +       git --git-dir=newdir/.git config core.filemode >actual &&
> +       test_cmp expect actual

git-init automatically detects an appropriate value for core.filemode, so this test may not be telling us anything useful on some platforms.

Show 5 quoted lines
> +'
> +
>  test_done
> --
> 2.3.3.611.g09038fc.dirty
Previous: Jeff King
Message 4 of 4 in “init-db: introduce new -c/--config option”
  1. init-db: introduce new -c/--config optionAlexander Kuleshov, Mar 25, 2015
  2. Alexander KuleshovMar 25, 2015
  3. Jeff KingMar 25, 2015
  4. Eric SunshineMar 25, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.