# [PATCH] filter-branch: really allow running in a bare repository

4 messages from 2009-02-03 to 2009-02-03. Participants: Johannes Schindelin, Eric Kidd.
Thread: https://gitlist.dev/t/17535

## Johannes Schindelin, 2009-02-03 18:10

Subject: [PATCH] filter-branch: really allow running in a bare repository
Message-ID: <alpine.DEB.1.00.0902031910001.9822@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902031910001.9822%40pacific.mpi-cbg.de
In-Reply-To: <cover.1233684552u.git.johannes.schindelin@gmx.de>

```
When checking if running in a bare repository, the work tree has to be
reset, otherwise we will be checking the temporary state, which is
always non-bare.

This commit augments a4661b0(git-filter-branch.sh: Allow running in bare
repositories).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-filter-branch.sh |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index eb62f71..8cbce4e 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -469,19 +469,19 @@ rm -rf "$tempdir"
 
 trap - 0
 
+unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
+test -z "$ORIG_GIT_DIR" || {
+	GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
+}
+test -z "$ORIG_GIT_WORK_TREE" || {
+	GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
+	export GIT_WORK_TREE
+}
+test -z "$ORIG_GIT_INDEX_FILE" || {
+	GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
+	export GIT_INDEX_FILE
+}
 if [ "$(is_bare_repository)" = false ]; then
-	unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
-	test -z "$ORIG_GIT_DIR" || {
-		GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
-	}
-	test -z "$ORIG_GIT_WORK_TREE" || {
-		GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
-		export GIT_WORK_TREE
-	}
-	test -z "$ORIG_GIT_INDEX_FILE" || {
-		GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
-		export GIT_INDEX_FILE
-	}
 	git read-tree -u -m HEAD
 fi
 
-- 
1.6.1.2.574.g140d5

```

## Eric Kidd, 2009-02-03 19:31

Subject: Re: [PATCH] filter-branch: really allow running in a bare repository
Message-ID: <431341160902031131s63f34665ne9db25d8a4d1f0f9@mail.gmail.com>
URL: https://gitlist.dev/e/431341160902031131s63f34665ne9db25d8a4d1f0f9%40mail.gmail.com
In-Reply-To: <alpine.DEB.1.00.0902031910001.9822@pacific.mpi-cbg.de>

```
On Tue, Feb 3, 2009 at 1:10 PM, Johannes Schindelin
<johannes.schindelin@gmx.de> wrote:
> When checking if running in a bare repository, the work tree has to be
> reset, otherwise we will be checking the temporary state, which is
> always non-bare.

Just a few minutes after you posted this patch, I posted a
nearly-identical fix for the same issue:

  http://marc.info/?l=git&m=123368695831812&w=2

(My patch includes a test case, too, but it's not very important.)

This raises another interesting question: Why doesn't 'git
filter-branch' actually check whether subcommands succeed?

Cheers,
Eric

```

## Johannes Schindelin, 2009-02-03 20:46

Subject: Re: [PATCH] filter-branch: really allow running in a bare repository
Message-ID: <alpine.DEB.1.00.0902032145250.9822@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902032145250.9822%40pacific.mpi-cbg.de
In-Reply-To: <431341160902031131s63f34665ne9db25d8a4d1f0f9@mail.gmail.com>

```
Hi,

On Tue, 3 Feb 2009, Eric Kidd wrote:

> On Tue, Feb 3, 2009 at 1:10 PM, Johannes Schindelin
> <johannes.schindelin@gmx.de> wrote:
> > When checking if running in a bare repository, the work tree has to be
> > reset, otherwise we will be checking the temporary state, which is
> > always non-bare.
> 
> Just a few minutes after you posted this patch, I posted a
> nearly-identical fix for the same issue:
> 
>   http://marc.info/?l=git&m=123368695831812&w=2
> 
> (My patch includes a test case, too, but it's not very important.)

So clearly yours is superior.

> This raises another interesting question: Why doesn't 'git
> filter-branch' actually check whether subcommands succeed?

That's unintentional; AFAIR there was a "set -e" in cg-admin-rewritehist 
that I tried to do away with by introducing explicit '&&' conjunctions 
where needed.

So all those unchecked subcommands are bugs.

Thanks,
Dscho

```

## Eric Kidd, 2009-02-03 20:56

Subject: Re: [PATCH] filter-branch: really allow running in a bare repository
Message-ID: <431341160902031256k689bb0efo766b4a4f2e356d3d@mail.gmail.com>
URL: https://gitlist.dev/e/431341160902031256k689bb0efo766b4a4f2e356d3d%40mail.gmail.com
In-Reply-To: <431341160902031131s63f34665ne9db25d8a4d1f0f9@mail.gmail.com>

```
On Tue, Feb 3, 2009 at 2:31 PM, Eric Kidd <emk.lists@randomhacks.net> wrote:
> Just a few minutes after you posted this patch, I posted a
> nearly-identical fix for the same issue:
>
>  http://marc.info/?l=git&m=123368695831812&w=2

A point of clarification: These two bug fixes are independent, and I
was fighting with my mail queue when I saw Johannes' patch.

Cheers,
Eric

```
