git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* index-pack outside of repository?
@ 2016-12-15 20:40 Jeff King
  2016-12-16  0:13 ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Jeff King @ 2016-12-15 20:40 UTC (permalink / raw)
  To: git

Running git on 'next', you can trigger a BUG:

  $ cd /some/repo
  $ git pack-objects --all --stdout </dev/null >/tmp/foo.pack
  $ cd /not-a-git-repo
  $ git index-pack --stdin </tmp/foo.pack
  fatal: BUG: setup_git_env called without repository

This obviously comes from my b1ef400eec (setup_git_env: avoid blind
fall-back to ".git", 2016-10-20). What's going on is that index-pack
uses RUN_SETUP_GENTLY, but never actually handles the out-of-repo case.
When we use the internal git_dir to make "objects/pack/pack-xxx.pack",
it barfs.

In older versions of git will just blindly write into
".git/objects/pack", even though there's no repository there.

So I think complaining to the user is the right thing to do here. I
started to write a patch to have index-pack notice when it needs a repo
and doesn't have one, but the logic is actually a bit unclear.  Do we
need to complain early _just_ when --stdin is specified, or does that
miss somes cases?  Likewise, are there cases where --stdin can operate
without a repo? I couldn't think of any.

I'm actually wondering if the way it calls die() in 'next' is a pretty
reasonable way for things to work in general. It happens when we lazily
try to ask for the repository directory. So we don't have to replicate
logic to say "are we going to need a repo"; at the moment we need it, we
notice we don't have it and die. The only problem is that it says "BUG"
and not "this operation must be run in a git repository".

That strategy _might_ be a problem for some programs, which would want
to notice the issue early before doing work. But it seems like a
reasonable outcome for index-pack. Thoughts?

-Peff

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

end of thread, other threads:[~2016-12-16 21:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-15 20:40 index-pack outside of repository? Jeff King
2016-12-16  0:13 ` Junio C Hamano
2016-12-16  1:37   ` Jeff King
2016-12-16  2:29     ` Jeff King
2016-12-16  2:30       ` [PATCH 1/3] t5000: extract nongit function to test-lib-functions.sh Jeff King
2016-12-16  2:30       ` [PATCH 2/3] index-pack: complain when --stdin is used outside of a repo Jeff King
2016-12-16  2:31       ` [PATCH 3/3] t: use nongit() function where applicable Jeff King
2016-12-16 17:52       ` index-pack outside of repository? Junio C Hamano
2016-12-16 17:59         ` Junio C Hamano
2016-12-16 18:01           ` Junio C Hamano
2016-12-16 21:43             ` Jeff King
2016-12-16 21:55               ` Junio C Hamano
2016-12-16 18:54   ` Junio C Hamano
2016-12-16 21:44     ` 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).