From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] grep: simple test for operation in a bare repository
Date: Fri, 5 Feb 2010 09:40:43 +0700 [thread overview]
Message-ID: <fcaeb9bf1002041840l4d8e8ac9k3ad5e9e8761aa1b@mail.gmail.com> (raw)
In-Reply-To: <4B6B653A.8060909@lsrfire.ath.cx>
On Fri, Feb 5, 2010 at 7:24 AM, René Scharfe
<rene.scharfe@lsrfire.ath.cx> wrote:
> OK, I have to admit defeat: I can't come up with a test script. But
> the issue is reproducible: git grep in a bare repository fails when
> run with a pager.
>
> $ mkdir /tmp/a
> $ cd /tmp/a
> $ git init
> Initialized empty Git repository in /tmp/a/.git/
> $ echo a >a
> $ git add a
> $ git commit -m.
> [master (root-commit) e11f955] .
> 1 files changed, 1 insertions(+), 0 deletions(-)
> create mode 100644 a
>
> $ git clone --bare . ../b
> Initialized empty Git repository in /tmp/b/
> $ cd /tmp/b
>
> $ git grep a HEAD
> fatal: This operation must be run in a work tree
> $ git grep a HEAD | cat
> HEAD:a:a
> $ git --no-pager grep a HEAD
> HEAD:a:a
>
> Reverting 7e622650 (grep: prepare to run outside of a work tree), or
> rather just setting the flag RUN_SETUP for grep in git.c again, makes
> the first git grep call succeed, too.
>
> As does the following patch, but I don't know why. The call chain is
> quite deep. It seems that without the patch the static variable
> git_dir in environment.c isn't updated when git finds out that it runs
> in a bare repo -- but only if a pager is used.
setup_pager() calls git_config(), which indirectly calls get_git_dir()
and sets git_dir in stone. Changing GIT_DIR environment variable alone
won't work, as you have seen.
When RUN_SETUP is set, setup_git_directory() would be called before
setup_pager() can kick in, so everything is properly set.
> There are five more sites in git.c, path.c and setup.c where $GIT_DIR
> is set directly with setenv(). I wonder if they should better call
> set_git_dir() instead, too.
Yes, they should.
--
Duy
next prev parent reply other threads:[~2010-02-05 10:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-03 18:16 [PATCH] grep: simple test for operation in a bare repository René Scharfe
2010-02-03 23:50 ` René Scharfe
2010-02-05 0:24 ` René Scharfe
2010-02-05 2:40 ` Nguyen Thai Ngoc Duy [this message]
2010-02-06 9:35 ` René Scharfe
2010-02-06 18:47 ` Junio C Hamano
2010-02-05 6:50 ` Junio C Hamano
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=fcaeb9bf1002041840l4d8e8ac9k3ad5e9e8761aa1b@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=rene.scharfe@lsrfire.ath.cx \
/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).