From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-5.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 1DB142034E for ; Wed, 20 Jul 2016 17:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754639AbcGTRZF (ORCPT ); Wed, 20 Jul 2016 13:25:05 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34229 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbcGTRY4 (ORCPT ); Wed, 20 Jul 2016 13:24:56 -0400 Received: by mail-lf0-f66.google.com with SMTP id l69so3989750lfg.1 for ; Wed, 20 Jul 2016 10:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=39s+EF5OdPmRWcFeSU6E5B+Syyd87RZ5+1a7YZCPAf4=; b=k0Ojxu66GRy6c9x98ky8j5lTOkxYA1LLiIQYMiFIbGpxCVFsyKX3dyn4fffLkMUaWO F/ymFXS0bFLx+hRf/OmevjkGSUz5t3iMOQ525dNjcteM89c4QtWyfsz+srruH2CkW4aF FIgBHbijdbQVI2tjiHh/n0C/Bg6PPNSmxtRLk37l6900UtzYE5RbtJz+J06qoUutvQmz vdpJJYY+isubp2J6Q09tc6TX0jsKmKrXr7M5H3yDI9OMYr/OM+jJYeTzQ8QziNbAqDT8 mnFBbFF9n41JYB7BuxSq65UkikbLYZwNUGhVQ2/FUPsKfEKi8uOh6LgMuI607kxxNJiC Wo+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=39s+EF5OdPmRWcFeSU6E5B+Syyd87RZ5+1a7YZCPAf4=; b=Ok27Sx8k2j3fWyP4O8bUn7Q5wWCog61aX+AsyS/Go1nH5NzmmZBpIW5I4QrTPOc/4j qlOObf6EDfjOJLdKTi+Y1MZzMeYh00X4QS1LF6TvN+Mf4daE29V7C2ay0THLeETJflYy Wd7tp8I2wKug5JdGioTdLbc5gs1VlHXTCRxkWj5AhuMGZU8hhDl/eWe0BFUj/LL1ZCrf GMQgZ0kPKdc0WELYj+5ZcbTunxT3jwicbtPRJMWqYFrBkL1Bhs/o9/hXlw77PNJioGQy +XtRYtyG6lnpQNnJTbean4scpNOvCKgfZxHaZLwqn0Zxx35UHVDjYH/NG3CvHMBkZWD/ 67Ow== X-Gm-Message-State: ALyK8tIcH6t5CPjU8bXb2MgyxDKzromYNTMsFlJEsBMfebQg4yydfDuPEcYADx/CjrbFTA== X-Received: by 10.25.22.97 with SMTP id m94mr6305406lfi.70.1469035494317; Wed, 20 Jul 2016 10:24:54 -0700 (PDT) Received: from duynguyen.does.not.exist (10.219.241.83.in-addr.dgcsystems.net. [83.241.219.10]) by smtp.gmail.com with ESMTPSA id g74sm777884ljg.24.2016.07.20.10.24.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jul 2016 10:24:53 -0700 (PDT) From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= To: git@vger.kernel.org Cc: max@max630.net, Junio C Hamano , git@drmicha.warpmail.net, Jens.Lehmann@web.de, larsxschneider@gmail.com, sbeller@google.com, mhagger@alum.mit.edu, =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Subject: [PATCH v4 1/4] worktree: add per-worktree config files Date: Wed, 20 Jul 2016 19:24:16 +0200 Message-Id: <20160720172419.25473-2-pclouds@gmail.com> X-Mailer: git-send-email 2.9.1.566.gbd532d4 In-Reply-To: <20160720172419.25473-1-pclouds@gmail.com> References: <20160720172419.25473-1-pclouds@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A new repo extension is added, worktreeConfig. When it is present: - Repository config reading by default includes $GIT_DIR/config _and_ $GIT_DIR/config.worktree. "config" file remains shared in multiple worktree setup. - The special treatment for core.bare and core.worktree, to stay effective only in main worktree, is gone. These config files are supposed to be in config.worktree. This extension is most useful in multiple worktree setup because you now have an option to store per-worktree config (which is either .git/config.worktree for main worktree, or .git/worktrees/xx/config.worktree for linked ones). This extension can be used in single worktree mode, even though it's pretty much useless (but this can happen after you remove all linked worktrees and move back to single worktree). "git config" reads from both "config" and "config.worktree" by default (i.e. without either --user, --file...) when this extension is present. Default writes still go to "config", not "config.worktree". A new option --worktree is added for that (*). Since a new repo extension is introduced, existing git binaries should refuse to access to the repo (both from main and linked worktrees). So they will not misread the config file (i.e. skip the config.worktree part). They may still accidentally write to the config file anyway if they use with "git config --file ". This design places a bet on the assumption that the majority of config variables are shared so it is the default mode. A safer move would be default writes go to per-worktree file, so that accidental changes are isolated. (*) "git config --worktree" points back to "config" file when this extension is not present so that it works in any setup. Signed-off-by: Nguyễn Thái Ngọc Duy --- Documentation/config.txt | 11 ++++- Documentation/git-config.txt | 26 ++++++++---- Documentation/git-worktree.txt | 31 ++++++++++++++ Documentation/gitrepository-layout.txt | 8 ++++ builtin/config.c | 18 +++++++- cache.h | 2 + config.c | 7 ++++ environment.c | 1 + setup.c | 5 ++- t/t2028-worktree-config.sh (new +x) | 77 ++++++++++++++++++++++++++++++++++ 10 files changed, 175 insertions(+), 11 deletions(-) create mode 100755 t/t2028-worktree-config.sh diff --git a/Documentation/config.txt b/Documentation/config.txt index 16dc22d..7d64da0 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -2,8 +2,9 @@ CONFIGURATION FILE ------------------ The Git configuration file contains a number of variables that affect -the Git commands' behavior. The `.git/config` file in each repository -is used to store the configuration for that repository, and +the Git commands' behavior. The files `.git/config` and optionally +`config.worktree` (see `extensions.worktreeConfig` below) are each +repository is used to store the configuration for that repository, and `$HOME/.gitconfig` is used to store a per-user configuration as fallback values for the `.git/config` file. The file `/etc/gitconfig` can be used to store a system-wide default configuration. @@ -264,6 +265,12 @@ advice.*:: show directions on how to proceed from the current state. -- +extensions.worktreeConfig:: + If set, by default "git config" reads from both "config" and + "config.worktree" file in that order. In multiple working + directory mode, "config" file is shared while + "config.worktree" is per-working directory. + core.fileMode:: Tells Git if the executable bit of files in the working tree is to be honored. diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt index f163113..9dfdb6a 100644 --- a/Documentation/git-config.txt +++ b/Documentation/git-config.txt @@ -47,13 +47,15 @@ checks or transformations are performed on the value. When reading, the values are read from the system, global and repository local configuration files by default, and options -`--system`, `--global`, `--local` and `--file ` can be -used to tell the command to read from only that location (see <>). +`--system`, `--global`, `--local`, `--worktree` and +`--file ` can be used to tell the command to read from only +that location (see <>). When writing, the new value is written to the repository local configuration file by default, and options `--system`, `--global`, -`--file ` can be used to tell the command to write to -that location (you can say `--local` but that is the default). +`--worktree`, `--file ` can be used to tell the command to +write to that location (you can say `--local` but that is the +default). This command will fail with non-zero status upon error. Some exit codes are: @@ -133,6 +135,11 @@ from all available files. + See also <>. +--worktree:: + Similar to `--local` except that `.git/config.worktree` is + read from or written to if `extensions.worktreeConfig` is + present. If not it's the same as `--local`. + -f config-file:: --file config-file:: Use the given config file instead of the one specified by GIT_CONFIG. @@ -253,6 +260,10 @@ $XDG_CONFIG_HOME/git/config:: $GIT_DIR/config:: Repository specific configuration file. +$GIT_DIR/config.worktree:: + This is optional and is only searched when + `extensions.worktreeConfig` is present in $GIT_DIR/config. + If no further options are given, all reading options will read all of these files that are available. If the global or the system-wide configuration file are not available they will be ignored. If the repository configuration @@ -268,9 +279,10 @@ configuration file. Note that this also affects options like `--replace-all` and `--unset`. *'git config' will only ever change one file at a time*. You can override these rules either by command-line options or by environment -variables. The `--global` and the `--system` options will limit the file used -to the global or system-wide file respectively. The `GIT_CONFIG` environment -variable has a similar effect, but you can specify any filename you want. +variables. The `--global`, `--system` and `--worktree` options will limit +the file used to the global, system-wide or per-worktree file respectively. +The `GIT_CONFIG` environment variable has a similar effect, but you +can specify any filename you want. ENVIRONMENT diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 7c4cfb0..41350db 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -111,6 +111,37 @@ OPTIONS --expire