git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] Fix git init with core.hidedotfiles
@ 2019-03-07  9:35 Johannes Schindelin via GitGitGadget
  2019-03-07  9:35 ` [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again Johannes Schindelin via GitGitGadget
  2019-03-11 20:10 ` [PATCH v2 0/1] Fix git init with core.hidedotfiles Johannes Schindelin via GitGitGadget
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2019-03-07  9:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

This fixes an regression that was not present in Git for Windows's original 
core.hideDotFiles patch, but in the shape of the core.hideDotFiles patch
that made it into git.git.

We fixed it in one big hurry in Git for Windows, and I simply forgot to
upstream this right away.

Johannes Schindelin (1):
  mingw: respect core.hidedotfiles = false in git-init again

 builtin/init-db.c |  6 ++++++
 t/t0001-init.sh   | 12 ++++++++++++
 2 files changed, 18 insertions(+)


base-commit: 39ffebd23b1ef6830bf86043ef0b5c069d9299a9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-131%2Fdscho%2Funhidden-git-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-131/dscho/unhidden-git-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/131
-- 
gitgitgadget

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

* [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again
  2019-03-07  9:35 [PATCH 0/1] Fix git init with core.hidedotfiles Johannes Schindelin via GitGitGadget
@ 2019-03-07  9:35 ` Johannes Schindelin via GitGitGadget
  2019-03-08  3:18   ` Junio C Hamano
  2019-03-11 20:10 ` [PATCH v2 0/1] Fix git init with core.hidedotfiles Johannes Schindelin via GitGitGadget
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2019-03-07  9:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

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

This is a brown paper bag. When adding the tests, we actually failed
to verify that the config variable is heeded in git-init at all. And
when changing the original patch that marked the .git/ directory as
hidden after reading the config, it was lost on this developer that
the new code would use the hide_dotfiles variable before the config
was read.

The fix is obvious: read the (limited, pre-init) config *before*
creating the .git/ directory.

This fixes https://github.com/git-for-windows/git/issues/789

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/init-db.c |  6 ++++++
 t/t0001-init.sh   | 12 ++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 93eff7618c..94df241ad5 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)
 	if (!strcmp(k, "init.templatedir"))
 		return git_config_pathname(&init_db_template_dir, k, v);
 
+	if (starts_with(k, "core."))
+		return platform_core_config(k, v, cb);
+
 	return 0;
 }
 
@@ -361,6 +364,9 @@ int init_db(const char *git_dir, const char *real_git_dir,
 	}
 	startup_info->have_repository = 1;
 
+	/* Just look for `init.templatedir` and `core.hidedotfiles` */
+	git_config(git_init_db_config, NULL);
+
 	safe_create_dir(git_dir, 0);
 
 	init_is_bare_repository = is_bare_repository();
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 42a263cada..35ede1b0b0 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -453,6 +453,18 @@ test_expect_success 're-init from a linked worktree' '
 	)
 '
 
+test_expect_success MINGW 'core.hidedotfiles = false' '
+	git config --global core.hidedotfiles false &&
+	rm -rf newdir &&
+	(
+		sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
+		mkdir newdir &&
+		cd newdir &&
+		git init
+	) &&
+	! is_hidden newdir/.git
+'
+
 test_expect_success MINGW 'redirect std handles' '
 	GIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir &&
 	test .git = "$(cat output.txt)" &&
-- 
gitgitgadget

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

* Re: [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again
  2019-03-07  9:35 ` [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again Johannes Schindelin via GitGitGadget
@ 2019-03-08  3:18   ` Junio C Hamano
  2019-03-11 19:56     ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2019-03-08  3:18 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin

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

> diff --git a/builtin/init-db.c b/builtin/init-db.c
> index 93eff7618c..94df241ad5 100644
> --- a/builtin/init-db.c
> +++ b/builtin/init-db.c
> @@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)
>  	if (!strcmp(k, "init.templatedir"))
>  		return git_config_pathname(&init_db_template_dir, k, v);
>  
> +	if (starts_with(k, "core."))
> +		return platform_core_config(k, v, cb);
> +
>  	return 0;
>  }

OK.  I think this is very much futureproof and a sensible thing to
have a "platform_core_config()" call here.  That way, we do not have
to say the details of what platform specific thing each platform
wants when init_db_config works.

> @@ -361,6 +364,9 @@ int init_db(const char *git_dir, const char *real_git_dir,
>  	}
>  	startup_info->have_repository = 1;
>  
> +	/* Just look for `init.templatedir` and `core.hidedotfiles` */

And from that point of view, replacing `core.hidedotfiles` with
something like "platform specific core config" would be more
appropriate.

> +	git_config(git_init_db_config, NULL);
> +

We use git_init_db_config from create_default_files(), which is a
function called several lines after this point; shouldn't that now
be removed from create_default_files()?

>  	safe_create_dir(git_dir, 0);
>  
>  	init_is_bare_repository = is_bare_repository();
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index 42a263cada..35ede1b0b0 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -453,6 +453,18 @@ test_expect_success 're-init from a linked worktree' '
>  	)
>  '
>  
> +test_expect_success MINGW 'core.hidedotfiles = false' '
> +	git config --global core.hidedotfiles false &&
> +	rm -rf newdir &&
> +	(
> +		sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
> +		mkdir newdir &&
> +		cd newdir &&
> +		git init
> +	) &&

This is not incorrect per-se, but I think most tests do the mkdir
outside subshell, i.e.

	rm -rf newdir &&
	mkdir newdir &&
	(
		cd newdir &&
		sane_unset ... &&
		...
	) &&

Other than these, I find nothing questionable in the patch.  Nicely
done.



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

* Re: [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again
  2019-03-08  3:18   ` Junio C Hamano
@ 2019-03-11 19:56     ` Johannes Schindelin
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2019-03-11 19:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin via GitGitGadget, git

Hi Junio,

On Fri, 8 Mar 2019, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
> 
> > diff --git a/builtin/init-db.c b/builtin/init-db.c
> > index 93eff7618c..94df241ad5 100644
> > --- a/builtin/init-db.c
> > +++ b/builtin/init-db.c
> > @@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)
> >  	if (!strcmp(k, "init.templatedir"))
> >  		return git_config_pathname(&init_db_template_dir, k, v);
> >  
> > +	if (starts_with(k, "core."))
> > +		return platform_core_config(k, v, cb);
> > +
> >  	return 0;
> >  }
> 
> OK.  I think this is very much futureproof and a sensible thing to
> have a "platform_core_config()" call here.  That way, we do not have
> to say the details of what platform specific thing each platform
> wants when init_db_config works.

I am glad you agree.

> > @@ -361,6 +364,9 @@ int init_db(const char *git_dir, const char *real_git_dir,
> >  	}
> >  	startup_info->have_repository = 1;
> >  
> > +	/* Just look for `init.templatedir` and `core.hidedotfiles` */
> 
> And from that point of view, replacing `core.hidedotfiles` with
> something like "platform specific core config" would be more
> appropriate.

Probably. But it could potentially make some developer (such as myself,
six months from now) wonder why we don't just remove this call because
clearly nothing uses this on Linux.

So even if it is not quite future-proof from the point of view where we
*technically* would have to extend this comment if we ever introduced
another platform-specific config setting that is relevant to the early
phase of `git init`, I would like to keep the comment in the current form.

Well, actually *almost* in the current form.

I did realize, based on your comment below, that the mention of
`init.templatedir` here is bogus, wrong even: if `git init` is started in
a Git worktree, we do not *want* to use the `init.templatedir` setting
from said worktree.

And that is the reason why...

> > +	git_config(git_init_db_config, NULL);
> > +
> 
> We use git_init_db_config from create_default_files(), which is a
> function called several lines after this point; shouldn't that now
> be removed from create_default_files()?

... we have to call `git_config()` *again* in `create_default_files()`.

> >  	safe_create_dir(git_dir, 0);
> >  
> >  	init_is_bare_repository = is_bare_repository();
> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> > index 42a263cada..35ede1b0b0 100755
> > --- a/t/t0001-init.sh
> > +++ b/t/t0001-init.sh
> > @@ -453,6 +453,18 @@ test_expect_success 're-init from a linked worktree' '
> >  	)
> >  '
> >  
> > +test_expect_success MINGW 'core.hidedotfiles = false' '
> > +	git config --global core.hidedotfiles false &&
> > +	rm -rf newdir &&
> > +	(
> > +		sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
> > +		mkdir newdir &&
> > +		cd newdir &&
> > +		git init
> > +	) &&
> 
> This is not incorrect per-se, but I think most tests do the mkdir
> outside subshell, i.e.
> 
> 	rm -rf newdir &&
> 	mkdir newdir &&
> 	(
> 		cd newdir &&
> 		sane_unset ... &&
> 		...
> 	) &&

Legit.

Thanks,
Dscho

> 
> Other than these, I find nothing questionable in the patch.  Nicely
> done.
> 
> 
> 

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

* [PATCH v2 0/1] Fix git init with core.hidedotfiles
  2019-03-07  9:35 [PATCH 0/1] Fix git init with core.hidedotfiles Johannes Schindelin via GitGitGadget
  2019-03-07  9:35 ` [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again Johannes Schindelin via GitGitGadget
@ 2019-03-11 20:10 ` Johannes Schindelin via GitGitGadget
  2019-03-11 20:10   ` [PATCH v2 1/1] mingw: respect core.hidedotfiles = false in git-init again Johannes Schindelin via GitGitGadget
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2019-03-11 20:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

This fixes an regression that was not present in Git for Windows's original 
core.hideDotFiles patch, but in the shape of the core.hideDotFiles patch
that made it into git.git.

We fixed it in one big hurry in Git for Windows, and I simply forgot to
upstream this right away.

Changes since v1:

 * Clarified in the code comment that our intention is to pick up 
   core.hidedotfiles in the first git_config() call.
 * Explained in the commit message why we cannot remove the 
   git_config(git_init_db_config, NULL) call from create_default_files(): it
   would cause a change of behavior with regard to the init.templatedir 
   setting.
 * Simplified the test case.

Johannes Schindelin (1):
  mingw: respect core.hidedotfiles = false in git-init again

 builtin/init-db.c |  7 +++++++
 t/t0001-init.sh   | 11 +++++++++++
 2 files changed, 18 insertions(+)


base-commit: e902e9bcae2010bc42648c80ab6adc6c5a16a4a5
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-131%2Fdscho%2Funhidden-git-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-131/dscho/unhidden-git-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/131

Range-diff vs v1:

 1:  008e367d26 ! 1:  f187d0d247 mingw: respect core.hidedotfiles = false in git-init again
     @@ -12,6 +12,12 @@
          The fix is obvious: read the (limited, pre-init) config *before*
          creating the .git/ directory.
      
     +    Please note that we cannot remove the identical-looking `git_config()`
     +    call from `create_default_files()`: we create the `.git/` directory
     +    between those calls. If we removed it, and if the parent directory is
     +    in a Git worktree, and if that worktree's `.git/config` contained any
     +    `init.templatedir` setting, we would all of a sudden pick that up.
     +
          This fixes https://github.com/git-for-windows/git/issues/789
      
          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
     @@ -29,11 +35,19 @@
       	return 0;
       }
       
     +@@
     + 	struct strbuf err = STRBUF_INIT;
     + 
     + 	/* Just look for `init.templatedir` */
     ++	init_db_template_dir = NULL; /* re-set in case it was set before */
     + 	git_config(git_init_db_config, NULL);
     + 
     + 	/*
      @@
       	}
       	startup_info->have_repository = 1;
       
     -+	/* Just look for `init.templatedir` and `core.hidedotfiles` */
     ++	/* Just look for `core.hidedotfiles` */
      +	git_config(git_init_db_config, NULL);
      +
       	safe_create_dir(git_dir, 0);
     @@ -50,11 +64,10 @@
      +test_expect_success MINGW 'core.hidedotfiles = false' '
      +	git config --global core.hidedotfiles false &&
      +	rm -rf newdir &&
     ++	mkdir newdir &&
      +	(
      +		sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
     -+		mkdir newdir &&
     -+		cd newdir &&
     -+		git init
     ++		git -C newdir init
      +	) &&
      +	! is_hidden newdir/.git
      +'

-- 
gitgitgadget

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

* [PATCH v2 1/1] mingw: respect core.hidedotfiles = false in git-init again
  2019-03-11 20:10 ` [PATCH v2 0/1] Fix git init with core.hidedotfiles Johannes Schindelin via GitGitGadget
@ 2019-03-11 20:10   ` Johannes Schindelin via GitGitGadget
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2019-03-11 20:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

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

This is a brown paper bag. When adding the tests, we actually failed
to verify that the config variable is heeded in git-init at all. And
when changing the original patch that marked the .git/ directory as
hidden after reading the config, it was lost on this developer that
the new code would use the hide_dotfiles variable before the config
was read.

The fix is obvious: read the (limited, pre-init) config *before*
creating the .git/ directory.

Please note that we cannot remove the identical-looking `git_config()`
call from `create_default_files()`: we create the `.git/` directory
between those calls. If we removed it, and if the parent directory is
in a Git worktree, and if that worktree's `.git/config` contained any
`init.templatedir` setting, we would all of a sudden pick that up.

This fixes https://github.com/git-for-windows/git/issues/789

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/init-db.c |  7 +++++++
 t/t0001-init.sh   | 11 +++++++++++
 2 files changed, 18 insertions(+)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 93eff7618c..190754ba39 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)
 	if (!strcmp(k, "init.templatedir"))
 		return git_config_pathname(&init_db_template_dir, k, v);
 
+	if (starts_with(k, "core."))
+		return platform_core_config(k, v, cb);
+
 	return 0;
 }
 
@@ -185,6 +188,7 @@ static int create_default_files(const char *template_path,
 	struct strbuf err = STRBUF_INIT;
 
 	/* Just look for `init.templatedir` */
+	init_db_template_dir = NULL; /* re-set in case it was set before */
 	git_config(git_init_db_config, NULL);
 
 	/*
@@ -361,6 +365,9 @@ int init_db(const char *git_dir, const char *real_git_dir,
 	}
 	startup_info->have_repository = 1;
 
+	/* Just look for `core.hidedotfiles` */
+	git_config(git_init_db_config, NULL);
+
 	safe_create_dir(git_dir, 0);
 
 	init_is_bare_repository = is_bare_repository();
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 5e27604b24..1f462204ea 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -454,6 +454,17 @@ test_expect_success 're-init from a linked worktree' '
 	)
 '
 
+test_expect_success MINGW 'core.hidedotfiles = false' '
+	git config --global core.hidedotfiles false &&
+	rm -rf newdir &&
+	mkdir newdir &&
+	(
+		sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
+		git -C newdir init
+	) &&
+	! is_hidden newdir/.git
+'
+
 test_expect_success MINGW 'redirect std handles' '
 	GIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir &&
 	test .git = "$(cat output.txt)" &&
-- 
gitgitgadget

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

end of thread, other threads:[~2019-03-11 20:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07  9:35 [PATCH 0/1] Fix git init with core.hidedotfiles Johannes Schindelin via GitGitGadget
2019-03-07  9:35 ` [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again Johannes Schindelin via GitGitGadget
2019-03-08  3:18   ` Junio C Hamano
2019-03-11 19:56     ` Johannes Schindelin
2019-03-11 20:10 ` [PATCH v2 0/1] Fix git init with core.hidedotfiles Johannes Schindelin via GitGitGadget
2019-03-11 20:10   ` [PATCH v2 1/1] mingw: respect core.hidedotfiles = false in git-init again Johannes Schindelin via GitGitGadget

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).