git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Lederhofer <matled@gmx.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] filter-branch: always export GIT_DIR if it is set
Date: Tue, 5 Jun 2007 18:49:57 +0200	[thread overview]
Message-ID: <20070605164957.GA12358@moooo.ath.cx> (raw)
In-Reply-To: <7vodjudei2.fsf@assigned-by-dhcp.cox.net>

Currently filter-branch exports GIT_DIR only if it is a
relative path but git-sh-setup might also set GIT_DIR to an
absolute path that is not exported yet.  Additionally we need
to export GIT_WORK_TREE with GIT_DIR to ensure that the
current working directory is used as working tree even for
bare repositories.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Junio C Hamano <gitster@pobox.com> wrote:
> Hmph.
> 
> When this series is applied on top of 'next' (or whatever
> contains t7003-filter-branch.sh), this seems to break it quite
> badly.

With the GIT_WORK_TREE patch series a relative path in GIT_DIR is
expanded to an absolute path.  Therefore
    GIT_DIR=$(GIT_DIR=.git git rev-parse --git-dir)
in git-sh-setup will give the full path to the repository.
git-filter-branch exports GIT_DIR only if the path is relative.  In
consequence GIT_DIR was not set at all and the following git commands
failed.  Additionally GIT_WORK_TREE has to be exported because to make
sure that the current directory is used as working tree even for bare
repositories.

I merged the worktree branch to next and applied the patch, all tests
passed.

This problem reveals a small change which might cause trouble with other
scripts.  I looked at the git repository and found no other script which
should have problems with this series.  With
    $ git grep -e export --and -e GIT_DIR
I found:
    Documentation/install-doc-quick.sh
    git-clone.sh
    git-instaweb.sh
        These do not need a working tree.
    git-cvsexportcommit.perl
        git apply is used with GIT_DIR='', this forces git-apply not to
        use the git repository.

I'm not sure if any other script out there tries to do this.  Perhaps we
should just keep the old behaviour and use the current directory as
working tree when the repository name ends in /.git even though
core.bare is true?
---
 git-filter-branch.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 0c8a7df..f4cfbea 100644
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -313,9 +313,12 @@ workdir="$(pwd)"
 
 case "$GIT_DIR" in
 /*)
+	export GIT_DIR
+	export GIT_WORK_TREE=.
 	;;
 *)
 	export GIT_DIR="$(pwd)/../../$GIT_DIR"
+	export GIT_WORK_TREE=.
 	;;
 esac
 
-- 
1.5.2.1.120.g3877-dirty

  reply	other threads:[~2007-06-05 16:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-03 14:44 [RFC] GIT_WORK_TREE Matthias Lederhofer
2007-06-03 14:46 ` [PATCH 1/7] rev-parse: document --is-inside-git-dir Matthias Lederhofer
2007-06-03 14:46 ` [PATCH 2/7] rev-parse: introduce --is-bare-repository Matthias Lederhofer
2007-06-03 14:47 ` [PATCH 3/7] test git rev-parse Matthias Lederhofer
2007-06-06  7:01   ` [PATCH 3/7 (amend)] " Matthias Lederhofer
2007-06-03 14:47 ` [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree Matthias Lederhofer
2007-06-05  7:52   ` Junio C Hamano
2007-06-05 16:49     ` Matthias Lederhofer [this message]
2007-06-05 17:27       ` [PATCH] filter-branch: always export GIT_DIR if it is set Johannes Schindelin
2007-06-05 20:39         ` Junio C Hamano
2007-06-06  7:16       ` [PATCH (amend)] " Matthias Lederhofer
2007-06-06  7:10   ` [PATCH 4/7 (amend)] introduce GIT_WORK_TREE to specify the work tree Matthias Lederhofer
2007-06-03 14:48 ` [RFC] GIT_WORK_TREE Matthias Lederhofer
2007-06-03 14:51   ` Matthias Lederhofer
2007-06-03 14:48 ` [PATCH 6/7] extend rev-parse test for --is-inside-work-tree Matthias Lederhofer
2007-06-06  7:13   ` [PATCH 6/7 (amend)] " Matthias Lederhofer
2007-06-03 14:49 ` [PATCH 7/7] test GIT_WORK_TREE Matthias Lederhofer
2007-06-06  7:14   ` [PATCH 7/7 (amend)] " Matthias Lederhofer
2007-06-03 16:02 ` [RFC] GIT_WORK_TREE Sergio
2007-06-03 19:32   ` Matthias Lederhofer
2007-06-03 21:34     ` Sergio
2007-06-06 21:29 ` [PATCH] setup_git_directory: fix segfault if repository is found in cwd Matthias Lederhofer

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=20070605164957.GA12358@moooo.ath.cx \
    --to=matled@gmx.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).