Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: [PATCH/RFC] init, clone: support --real-git-dir for .git file

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:42

Nguyễn Thái Ngọc Duy  [off-list ref] writes:
Instead of creating the repository at $GIT_DIR, --real-git-dir will
tell git to put the repository there, then make $GIT_DIR a .git file
that points to --real-git-dir.
Just like you, I am also bad at naming things, so I cannot offhand suggest
a better name, even though I _know_ --real-git-dir sounds horrible.

The naming aside, the feature is what we have wanted to have for a long
time and is way overdue.  Thanks for showing how small-impact the
necessary changes are.

"submodule init subpro" should be able to use this to clone a submodule
with:

	git clone --xxx=.git/modules/subpro.git subpro

When we need to switch to a revision without that submodule, after making
sure that there is no precious file in subpro/ directory, we would:

	rm -rf subpro/

Now, what do we need to switch back to a revision with that submodule?  It
would involve something like this:

	... after checking if we already have .git/modules/subpro.git
        ... and seeing that we do ...

	mkdir subpro
	commit=$(git rev-parse :subpro)
        echo 'gitdir: ../.git/modules/subpro.git' >subpro/.git
	cd subpro && git checkout $commit^0

The above four lines packaged for "git submodule" script would be a useful
thing to have, especially because then nobody has to write the "echo" part.
 I intend to make 'git init --real-git-dir' move current repo to
 somewhere else if called on existing repo.
I don't know if that is useful in real life.  Do you have a concrete use
case (like the one I showed an example above) in mind?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help