From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
git@vger.kernel.org,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: Re: [Funky] "git -p cmd" inside a bare repository
Date: Fri, 14 Dec 2007 00:12:23 -0500 [thread overview]
Message-ID: <20071214051223.GD10169@sigill.intra.peff.net> (raw)
In-Reply-To: <7vmysexdvw.fsf@gitster.siamese.dyndns.org>
On Thu, Dec 13, 2007 at 05:29:23PM -0800, Junio C Hamano wrote:
> I _think_ what is happening is that setup_pager() tries to run
> git_config(), which runs setup(), and then RUN_SETUP set for "ls-tree"
> (or "show") internal command runs setup again. HEAD is given to
> resolve_ref() and git_path("%s", ref) makes it to ".git/HEAD", even
> though in a bare repository git_dir should be set to ".", and of course
> we cannot find such a path in the git directory.
I think that there is perhaps a larger bug here, which is that running
setup twice gives bad results, and should either be fixed or have its
own "don't run me twice" guard.
But it makes sense to always spawn the pager at the same time for
consistency. As a bonus, this makes "git -p bogus" a little more
friendly by not spawning the pager until we verify the command name.
-- >8 --
delay "git -p" page spawning until command runtime
This makes the timing consistent with those commands that always spawn a
pager. It also avoids a funny interaction related to calling
setup_pager() before setup().
---
diff --git a/git.c b/git.c
index c8b7e74..21d204f 100644
--- a/git.c
+++ b/git.c
@@ -6,6 +6,8 @@
const char git_usage_string[] =
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
+static int user_asked_for_pager;
+
static int handle_options(const char*** argv, int* argc, int* envchanged)
{
int handled = 0;
@@ -35,7 +37,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
exit(0);
}
} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
- setup_pager();
+ user_asked_for_pager = 1;
} else if (!strcmp(cmd, "--no-pager")) {
setenv("GIT_PAGER", "cat", 1);
if (envchanged)
@@ -256,7 +258,7 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
prefix = NULL;
if (p->option & RUN_SETUP)
prefix = setup_git_directory();
- if (p->option & USE_PAGER)
+ if (p->option & USE_PAGER || user_asked_for_pager)
setup_pager();
if (p->option & NEED_WORK_TREE)
setup_work_tree();
next prev parent reply other threads:[~2007-12-14 5:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 12:21 [PATCH v2] Do check_repository_format() early Nguyễn Thái Ngọc Duy
2007-12-14 1:29 ` [Funky] "git -p cmd" inside a bare repository Junio C Hamano
2007-12-14 5:03 ` [PATCH] make git start-up sequence a bit more robust Junio C Hamano
2007-12-14 5:12 ` Jeff King [this message]
2007-12-14 5:14 ` [Funky] "git -p cmd" inside a bare repository Jeff King
2007-12-14 6:07 ` Junio C Hamano
2007-12-14 13:58 ` Nguyen Thai Ngoc Duy
2007-12-14 19:44 ` Johannes Schindelin
2007-12-14 20:18 ` Junio C Hamano
2007-12-14 20:37 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071214051223.GD10169@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).