git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] Some left-over add-on for bw/config-h
@ 2018-11-13 15:05 Johannes Schindelin via GitGitGadget
  2018-11-13 15:05 ` [PATCH 1/1] do_git_config_sequence(): fall back to git_dir if commondir is NULL Johannes Schindelin via GitGitGadget
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-11-13 15:05 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Back when bw/config-h was developed (and backported to Git for Windows), I
came up with this patch. It seems to not be strictly necessary, but I like
the safety of falling back to the Git directory when no common directory is
configured (for whatever reason).

Johannes Schindelin (1):
  do_git_config_sequence(): fall back to git_dir if commondir is NULL

 config.c | 2 ++
 1 file changed, 2 insertions(+)


base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-78%2Fdscho%2Fbw%2Fconfig-h-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-78/dscho/bw/config-h-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/78
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] do_git_config_sequence(): fall back to git_dir if commondir is NULL
  2018-11-13 15:05 [PATCH 0/1] Some left-over add-on for bw/config-h Johannes Schindelin via GitGitGadget
@ 2018-11-13 15:05 ` Johannes Schindelin via GitGitGadget
  2018-11-14  5:52 ` [PATCH 0/1] Some left-over add-on for bw/config-h Junio C Hamano
  2018-11-14 13:59 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
  2 siblings, 0 replies; 7+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-11-13 15:05 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Just some defensive programming.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/config.c b/config.c
index 4051e38823..279d0d7077 100644
--- a/config.c
+++ b/config.c
@@ -1676,6 +1676,8 @@ static int do_git_config_sequence(const struct config_options *opts,
 
 	if (opts->commondir)
 		repo_config = mkpathdup("%s/config", opts->commondir);
+	else if (opts->git_dir)
+		repo_config = mkpathdup("%s/config", opts->git_dir);
 	else
 		repo_config = NULL;
 
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/1] Some left-over add-on for bw/config-h
  2018-11-13 15:05 [PATCH 0/1] Some left-over add-on for bw/config-h Johannes Schindelin via GitGitGadget
  2018-11-13 15:05 ` [PATCH 1/1] do_git_config_sequence(): fall back to git_dir if commondir is NULL Johannes Schindelin via GitGitGadget
@ 2018-11-14  5:52 ` Junio C Hamano
  2018-11-14  7:31   ` Jeff King
  2018-11-14 13:59 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
  2 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2018-11-14  5:52 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> Back when bw/config-h was developed (and backported to Git for Windows), I
> came up with this patch. It seems to not be strictly necessary, but I like
> the safety of falling back to the Git directory when no common directory is
> configured (for whatever reason).

Shouldn't that be diagnosed as an error with BUG()?  That is, if we
know there is the current repository, and if commondir is not set,
isn't it a bug that we want to look into in the start-up sequence?

The phrase "for whatever reason" makes me wonder if this is truly
"defensive programming", rather than just sweeping the bug under the
rug.

FWIW, with this toy patch applied on top of this patch, all tests
that I usually run seem to pass.

 config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config.c b/config.c
index c5726af14d..e667e2ebce 100644
--- a/config.c
+++ b/config.c
@@ -1669,7 +1669,7 @@ static int do_git_config_sequence(const struct config_options *opts,
 	if (opts->commondir)
 		repo_config = mkpathdup("%s/config", opts->commondir);
 	else if (opts->git_dir)
-		repo_config = mkpathdup("%s/config", opts->git_dir);
+		BUG("git-dir exists but no commondir?");
 	else
 		repo_config = NULL;
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/1] Some left-over add-on for bw/config-h
  2018-11-14  5:52 ` [PATCH 0/1] Some left-over add-on for bw/config-h Junio C Hamano
@ 2018-11-14  7:31   ` Jeff King
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2018-11-14  7:31 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Johannes Schindelin, Johannes Schindelin via GitGitGadget, git

On Wed, Nov 14, 2018 at 02:52:24PM +0900, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
> 
> > Back when bw/config-h was developed (and backported to Git for Windows), I
> > came up with this patch. It seems to not be strictly necessary, but I like
> > the safety of falling back to the Git directory when no common directory is
> > configured (for whatever reason).
> 
> Shouldn't that be diagnosed as an error with BUG()?  That is, if we
> know there is the current repository, and if commondir is not set,
> isn't it a bug that we want to look into in the start-up sequence?
> 
> The phrase "for whatever reason" makes me wonder if this is truly
> "defensive programming", rather than just sweeping the bug under the
> rug.
> 
> FWIW, with this toy patch applied on top of this patch, all tests
> that I usually run seem to pass.

Heh, I independently made the same change after reading the patch and
came here to report similar results.

I think the key thing here is that git_dir is never meant to be used as
a source for config. It is there to let the "includeIf gitdir" directive
work. So it would indeed be surprising and a bug if we had one but not
the other.

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 0/1] Some left-over add-on for bw/config-h
  2018-11-13 15:05 [PATCH 0/1] Some left-over add-on for bw/config-h Johannes Schindelin via GitGitGadget
  2018-11-13 15:05 ` [PATCH 1/1] do_git_config_sequence(): fall back to git_dir if commondir is NULL Johannes Schindelin via GitGitGadget
  2018-11-14  5:52 ` [PATCH 0/1] Some left-over add-on for bw/config-h Junio C Hamano
@ 2018-11-14 13:59 ` Johannes Schindelin via GitGitGadget
  2018-11-14 13:59   ` [PATCH v2 1/1] config: report a bug if git_dir exists without commondir Johannes Schindelin via GitGitGadget
  2 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-11-14 13:59 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Back when bw/config-h was developed (and backported to Git for Windows), I
came up with a patch to use git_dir if commondir is NULL, and contributed
that as v1 of this patch. However, it was deemed a bug if that happens, so
let's instead detect that condition and report it.

Change since v1:

 * Be loud about this bug instead of papering over it.

Johannes Schindelin (1):
  config: report a bug if git_dir exists without commondir

 config.c | 2 ++
 1 file changed, 2 insertions(+)


base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-78%2Fdscho%2Fbw%2Fconfig-h-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-78/dscho/bw/config-h-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/78

Range-diff vs v1:

 1:  a3854e4ed8 ! 1:  0767f98378 do_git_config_sequence(): fall back to git_dir if commondir is NULL
     @@ -1,8 +1,9 @@
      Author: Johannes Schindelin <johannes.schindelin@gmx.de>
      
     -    do_git_config_sequence(): fall back to git_dir if commondir is NULL
     +    config: report a bug if git_dir exists without commondir
      
     -    Just some defensive programming.
     +    This did happen at some stage, and was fixed relatively quickly. Make
     +    sure that we detect very quickly, too, should that happen again.
      
          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
      
     @@ -14,7 +15,7 @@
       	if (opts->commondir)
       		repo_config = mkpathdup("%s/config", opts->commondir);
      +	else if (opts->git_dir)
     -+		repo_config = mkpathdup("%s/config", opts->git_dir);
     ++		BUG("git_dir without commondir");
       	else
       		repo_config = NULL;
       

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/1] config: report a bug if git_dir exists without commondir
  2018-11-14 13:59 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
@ 2018-11-14 13:59   ` Johannes Schindelin via GitGitGadget
  2018-11-14 21:42     ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-11-14 13:59 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

This did happen at some stage, and was fixed relatively quickly. Make
sure that we detect very quickly, too, should that happen again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/config.c b/config.c
index 4051e38823..db6b0167c6 100644
--- a/config.c
+++ b/config.c
@@ -1676,6 +1676,8 @@ static int do_git_config_sequence(const struct config_options *opts,
 
 	if (opts->commondir)
 		repo_config = mkpathdup("%s/config", opts->commondir);
+	else if (opts->git_dir)
+		BUG("git_dir without commondir");
 	else
 		repo_config = NULL;
 
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/1] config: report a bug if git_dir exists without commondir
  2018-11-14 13:59   ` [PATCH v2 1/1] config: report a bug if git_dir exists without commondir Johannes Schindelin via GitGitGadget
@ 2018-11-14 21:42     ` Jeff King
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2018-11-14 21:42 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget
  Cc: git, Junio C Hamano, Johannes Schindelin

On Wed, Nov 14, 2018 at 05:59:02AM -0800, Johannes Schindelin via GitGitGadget wrote:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> This did happen at some stage, and was fixed relatively quickly. Make
> sure that we detect very quickly, too, should that happen again.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  config.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/config.c b/config.c
> index 4051e38823..db6b0167c6 100644
> --- a/config.c
> +++ b/config.c
> @@ -1676,6 +1676,8 @@ static int do_git_config_sequence(const struct config_options *opts,
>  
>  	if (opts->commondir)
>  		repo_config = mkpathdup("%s/config", opts->commondir);
> +	else if (opts->git_dir)
> +		BUG("git_dir without commondir");

Yeah, I think this is the right thing to do. Thanks!

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-11-14 21:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 15:05 [PATCH 0/1] Some left-over add-on for bw/config-h Johannes Schindelin via GitGitGadget
2018-11-13 15:05 ` [PATCH 1/1] do_git_config_sequence(): fall back to git_dir if commondir is NULL Johannes Schindelin via GitGitGadget
2018-11-14  5:52 ` [PATCH 0/1] Some left-over add-on for bw/config-h Junio C Hamano
2018-11-14  7:31   ` Jeff King
2018-11-14 13:59 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
2018-11-14 13:59   ` [PATCH v2 1/1] config: report a bug if git_dir exists without commondir Johannes Schindelin via GitGitGadget
2018-11-14 21:42     ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).