git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug? clone ignores --git-dir
@ 2019-11-26 18:07 Jack Bates
  2019-11-27 11:51 ` Jeff King
  2019-11-27 12:33 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Jack Bates @ 2019-11-26 18:07 UTC (permalink / raw)
  To: git

If you `git rebase --exec 'gulp runtests-parallel --runners user'` this 
project, the tests perform Git operations on various subprojects [1], 
but because Git exports `GIT_DIR` and `GIT_WORK_TREE`, they end up 
operating on the parent project instead.

Adding `--git-dir` and `--work-tree` overrides `GIT_DIR` and 
`GIT_WORK_TREE` [2], forcing the tests to operate on the correct 
repositories, however `clone` ignores `--git-dir`:

> git init repository
> git --git-dir git-dir clone repository directory
I'd expect Git to create a directory `git-dir` and put the index, etc. 
there, but instead it creates `directory/.git`, as usual. I'm not sure 
if this is a bug or the expected behavior?

[1] 
https://github.com/microsoft/TypeScript/blob/master/src/testRunner/externalCompileRunner.ts#L58
[2] https://github.com/microsoft/TypeScript/pull/35362

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

* Re: Bug? clone ignores --git-dir
  2019-11-26 18:07 Bug? clone ignores --git-dir Jack Bates
@ 2019-11-27 11:51 ` Jeff King
  2019-11-27 12:33 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff King @ 2019-11-27 11:51 UTC (permalink / raw)
  To: Jack Bates; +Cc: git

On Tue, Nov 26, 2019 at 11:07:27AM -0700, Jack Bates wrote:

> If you `git rebase --exec 'gulp runtests-parallel --runners user'` this
> project, the tests perform Git operations on various subprojects [1], but
> because Git exports `GIT_DIR` and `GIT_WORK_TREE`, they end up operating on
> the parent project instead.
> 
> Adding `--git-dir` and `--work-tree` overrides `GIT_DIR` and `GIT_WORK_TREE`
> [2], forcing the tests to operate on the correct repositories, however
> `clone` ignores `--git-dir`:
> 
> > git init repository
> > git --git-dir git-dir clone repository directory
> I'd expect Git to create a directory `git-dir` and put the index, etc.
> there, but instead it creates `directory/.git`, as usual. I'm not sure if
> this is a bug or the expected behavior?

This is the expected behavior. "clone" and "init" are special in that
they are creating _new_ repositories, so they explicitly ignore the
any notion of the current repository.

I'm not quite sure what you're trying to do. I'd think:

  git clone --bare repository git-dir

would do what you want, but then I'm not sure why you're specifying
"directory" in the first place, or what you expect to happen. Are you
looking for clone's --separate-git-dir option, perhaps?

-Peff

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

* Re: Bug? clone ignores --git-dir
  2019-11-26 18:07 Bug? clone ignores --git-dir Jack Bates
  2019-11-27 11:51 ` Jeff King
@ 2019-11-27 12:33 ` Junio C Hamano
  2019-11-27 20:19   ` Jack Bates
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2019-11-27 12:33 UTC (permalink / raw)
  To: Jack Bates; +Cc: git

Jack Bates <bk874k@nottheoilrig.com> writes:

> ... repositories, however `clone` ignores `--git-dir`:

An intentional design decision (and it may be an unfortunate one by
now [*1*]) was to have the GIT_DIR (hence --git-dir) talk about the
*source side* of the clone, not the destination, e.g.

	cd /home/me/working/tree
	export GIT_DIR=/home/me/repo/sitory
	export GIT_WORK_TREE=$(pwd)

	# the above told Git that /home/me/working/tree has a
	# checkout but its repository body is not anywhere in its
	# subdirectory -- it is /home/me/repo/sitory.

	# now we clone the repository we are currently working on
	# without GIT_DIR applying to the source side, it won't
	# work.
	git clone . /else/where

And we cannot allow /home/me/repo/sitory (i.e. GIT_DIR for the
source repository) become the GIT_DIR for the resulting /else/where
repository (you'd be cloning to yourself).


[Footnote]

*1* with use of "git worktree" gaining traction, perhaps the need to
    create local clone out of the shared/same GIT_DIR may have
    diminished.


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

* Re: Bug? clone ignores --git-dir
  2019-11-27 12:33 ` Junio C Hamano
@ 2019-11-27 20:19   ` Jack Bates
  0 siblings, 0 replies; 4+ messages in thread
From: Jack Bates @ 2019-11-27 20:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 2019-11-27 5:33 a.m., Junio C Hamano wrote:
> An intentional design decision (and it may be an unfortunate one by
> now [*1*]) was to have the GIT_DIR (hence --git-dir) talk about the
> *source side* of the clone, not the destination, e.g.

Ah ha, the following does what I want, regardless of 
`GIT_DIR`/`GIT_WORK_TREE`:

> git init repository
> GIT_DIR=bogus GIT_WORK_TREE=bogus git --work-tree directory clone repository directory/.git

Thank you!

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 18:07 Bug? clone ignores --git-dir Jack Bates
2019-11-27 11:51 ` Jeff King
2019-11-27 12:33 ` Junio C Hamano
2019-11-27 20:19   ` Jack Bates

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