threads / patch / 17535

patchfilter-branch: really allow running in a bare repository

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

## tl;dr

4 messages between Feb 3, 2009 and Feb 3, 2009. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Johannes Schindelin· Feb 3, 2009, 18:10 UTC · lore

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(-)
Show changes to git-filter-branch.sh +12 −12
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· Feb 3, 2009, 19:31 UTC · re: Johannes Schindelin · lore

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

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· Feb 3, 2009, 20:46 UTC · re: Eric Kidd · lore

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

Hi,
On Tue, 3 Feb 2009, Eric Kidd wrote:
Show 12 quoted lines
> 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· Feb 3, 2009, 20:56 UTC · re: Eric Kidd · lore

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

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

← back to recent threads