Git development
 help / color / mirror / Atom feed
* What commands can and can not be used with bare repositories?
@ 2006-12-31  1:48 Theodore Ts'o
  2006-12-31  1:57 ` J. Bruce Fields
  2006-12-31  1:57 ` Shawn Pearce
  0 siblings, 2 replies; 6+ messages in thread
From: Theodore Ts'o @ 2006-12-31  1:48 UTC (permalink / raw)
  To: git

In order to minimize the amount of files which need to be backed up, I
decided to create an "upstream" repository which contains nothing but
Linus's tree, which I packed into a single pack file, and which I would
then only update every 3-6 months.

The git tree(s) that I would use for Linux hacking would then use the
upstream repository as an alternate source of objects.  That way the
"git gc" command is much faster, and it doesn't end up thrashing the
main pack file found in the "upstream" repository (which is currently
about 135 megs).  This streamlines my backups a tad (every little bit
helps).

The only real problem with this is that I don't really need to have a
working directory in the "upstream" repository, so I decided to try
using a "bare repository".  This is only barely (sorry) documented in
the git Documentation, where in the git-clone manpage there is a
description of how the administrative files end up in the top-level
directory instead of the .git subdirectory.  

What isn't documented is what commands actually can deal with a bare
repository.  At the moment, it looks like a bare repository can be a
target of a git pull, push, and merge commands, and it can be a source
for a git clone, but that seems to be about it.  All other commands,
such as "git log" blow up with the error message "Not a git repository".
This to me seems a bit lame, since why isn't a "bare repository" also a
"git repository"?  All of the information is there for "git log" to
work.  Commands that require a working directory obviously can't work,
but there are plenty of git commands for which there's no reason why
they shouldn't be able to operate on a bare repository.  For example,
"git repack", "git log", "git fetch", etc.

So as a suggestion, it would be good if exactly what you can and can't
use a "bare repository" for were documented.  If it really is push,
pull, fetch, and clone, I'll happily submit a patch to enhance the
documentation accordingly.   

The next obvious question, though, is *should* that be all that works?
A somewhat squinky hack that works quite nicely is to create a symlink
from . to .git in the bare repository.  At this point "git log", "git
fetch", "git repack", etc., all start working.  Of course, commands such
as "git status" that involve a working directory will be pretty
confused, but maybe we could fix that.  What if we were to change "git
clone --bare" to create the .git -> . symlink, and then add a check to
commands that require a working directory to see if ".git" is a symlink
to ., and if so, give an error message, "operation not supported on bare
repository"?

					- Ted

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

* Re: What commands can and can not be used with bare repositories?
  2006-12-31  1:48 What commands can and can not be used with bare repositories? Theodore Ts'o
@ 2006-12-31  1:57 ` J. Bruce Fields
  2006-12-31  1:57 ` Shawn Pearce
  1 sibling, 0 replies; 6+ messages in thread
From: J. Bruce Fields @ 2006-12-31  1:57 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: git

On Sat, Dec 30, 2006 at 08:48:22PM -0500, Theodore Ts'o wrote:
> What isn't documented is what commands actually can deal with a bare
> repository.  At the moment, it looks like a bare repository can be a
> target of a git pull, push, and merge commands, and it can be a source
> for a git clone, but that seems to be about it.  All other commands,
> such as "git log" blow up with the error message "Not a git repository".
> This to me seems a bit lame, since why isn't a "bare repository" also a
> "git repository"?  All of the information is there for "git log" to
> work.  Commands that require a working directory obviously can't work,
> but there are plenty of git commands for which there's no reason why
> they shouldn't be able to operate on a bare repository.  For example,
> "git repack", "git log", "git fetch", etc.

Yup.  Anything that should work actually does; you just need to know to
use one of:

	GIT_DIR=. git log
	git --git-dir=. log
	git --bare log

Why git couldn't figure this out for you, I don't know....

--b.

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

* Re: What commands can and can not be used with bare repositories?
  2006-12-31  1:48 What commands can and can not be used with bare repositories? Theodore Ts'o
  2006-12-31  1:57 ` J. Bruce Fields
@ 2006-12-31  1:57 ` Shawn Pearce
  2006-12-31  2:12   ` Theodore Tso
  1 sibling, 1 reply; 6+ messages in thread
From: Shawn Pearce @ 2006-12-31  1:57 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: git

Theodore Ts'o <tytso@mit.edu> wrote:
> What isn't documented is what commands actually can deal with a bare
> repository.  At the moment, it looks like a bare repository can be a
> target of a git pull, push, and merge commands

Sorry but 'git merge' cannot be used in a bare repository (no working
directory to update during the merge) and 'git merge' can only work on
the current repository, which rules out the bare repository.

> and it can be a source
> for a git clone, but that seems to be about it.  All other commands,
> such as "git log" blow up with the error message "Not a git repository".

Try "git --bare log".  Or "git --git-dir=/path/to log".

> This to me seems a bit lame, since why isn't a "bare repository" also a
> "git repository"?  All of the information is there for "git log" to
> work.  Commands that require a working directory obviously can't work,
> but there are plenty of git commands for which there's no reason why
> they shouldn't be able to operate on a bare repository.  For example,
> "git repack", "git log", "git fetch", etc.

Actually most commands work on a bare repository.
Very few don't: the ones that require a working directory.
E.g. status/revert/cherry-pick/commit/am/merge/pull.  (You can
pull from a bare repository, but you cannot run pull *in* a bare
repository.)

> confused, but maybe we could fix that.  What if we were to change "git
> clone --bare" to create the .git -> . symlink, and then add a check to
> commands that require a working directory to see if ".git" is a symlink
> to ., and if so, give an error message, "operation not supported on bare
> repository"?

No.  Better would be to make git's repository setup logic
automatically detect if "." is a Git repository, and if so let the
commands that work without a working directory run.

-- 
Shawn.

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

* Re: What commands can and can not be used with bare repositories?
  2006-12-31  1:57 ` Shawn Pearce
@ 2006-12-31  2:12   ` Theodore Tso
  2006-12-31  5:32     ` Michael S. Tsirkin
  2006-12-31  5:52     ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Theodore Tso @ 2006-12-31  2:12 UTC (permalink / raw)
  To: Shawn Pearce; +Cc: git

On Sat, Dec 30, 2006 at 08:57:32PM -0500, Shawn Pearce wrote:
> Try "git --bare log".  Or "git --git-dir=/path/to log".
>
> Actually most commands work on a bare repository.
> Very few don't: the ones that require a working directory.
> E.g. status/revert/cherry-pick/commit/am/merge/pull.  (You can
> pull from a bare repository, but you cannot run pull *in* a bare
> repository.)

Ah, right.  Thanks, I missed the --bare option.  It should probably be
mentioned in the git-clone man page, instead of only in the top-level
git manpage.

> > confused, but maybe we could fix that.  What if we were to change "git
> > clone --bare" to create the .git -> . symlink, and then add a check to
> > commands that require a working directory to see if ".git" is a symlink
> > to ., and if so, give an error message, "operation not supported on bare
> > repository"?
> 
> No.  Better would be to make git's repository setup logic
> automatically detect if "." is a Git repository, and if so let the
> commands that work without a working directory run.

That makes sense, although the hueristic for determining whether or
not "." is a Git repository might be a little interesting.  Say, if
there is no containing directory which has a .git directory, and the
directories "objects", "info", and "refs" are present?

						- Ted

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

* Re: What commands can and can not be used with bare repositories?
  2006-12-31  2:12   ` Theodore Tso
@ 2006-12-31  5:32     ` Michael S. Tsirkin
  2006-12-31  5:52     ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2006-12-31  5:32 UTC (permalink / raw)
  To: Theodore Tso; +Cc: Shawn Pearce, git

> That makes sense, although the hueristic for determining whether or
> not "." is a Git repository might be a little interesting.  Say, if
> there is no containing directory which has a .git directory, and the
> directories "objects", "info", and "refs" are present?

Maybe, git clone --bare should create a special file under the
repository directory?
	
-- 
MST

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

* Re: What commands can and can not be used with bare repositories?
  2006-12-31  2:12   ` Theodore Tso
  2006-12-31  5:32     ` Michael S. Tsirkin
@ 2006-12-31  5:52     ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2006-12-31  5:52 UTC (permalink / raw)
  To: Theodore Tso; +Cc: git

Theodore Tso <tytso@mit.edu> writes:

> That makes sense, although the hueristic for determining whether or
> not "." is a Git repository might be a little interesting.  Say, if
> there is no containing directory which has a .git directory, and the
> directories "objects", "info", and "refs" are present?

We have something called is_bare_git_dir() that does much
simpler and hacky check.

See my other message to Shawn regarding tradeoffs between
possible improvements and backward compatibility.

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

end of thread, other threads:[~2006-12-31  5:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-31  1:48 What commands can and can not be used with bare repositories? Theodore Ts'o
2006-12-31  1:57 ` J. Bruce Fields
2006-12-31  1:57 ` Shawn Pearce
2006-12-31  2:12   ` Theodore Tso
2006-12-31  5:32     ` Michael S. Tsirkin
2006-12-31  5:52     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox