# [PATCH] git-filter-branch: more detailed USAGE

12 messages from 2007-08-30 to 2007-08-31. Participants: Giuseppe Bilotta, Johannes Sixt, Junio C Hamano, David Kastrup, Johannes Schindelin.
Thread: https://gitlist.dev/t/9708

## Giuseppe Bilotta, 2007-08-30 15:56

Subject: [PATCH] git-filter-branch: more detailed USAGE
Message-ID: <11884893671845-git-send-email-giuseppe.bilotta@gmail.com>
URL: https://gitlist.dev/e/11884893671845-git-send-email-giuseppe.bilotta%40gmail.com

```
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-filter-branch.sh |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 0190060..9fcab56 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -8,7 +8,16 @@
 # a new branch. You can specify a number of filters to modify the commits,
 # files and trees.
 
-USAGE="git-filter-branch [-d TEMPDIR] [FILTERS] [REV-RANGE]"
+USAGE="[-d <tempdir>] \
+[--env-filter <command>] \
+[--tree-filter <command>] \
+[--index-filter <command>] \
+[--parent-filter <command>] \
+[--msg-filter <command>] \
+[--commit-filter <command>] \
+[--tag-name-filter <command>] \
+[--subdirectory-filter <command>] \
+[--original <namespace>] [rev-range]"
 . git-sh-setup
 
 warn () {
-- 
1.5.2.5

```

## Johannes Sixt, 2007-08-30 16:20

Subject: Re: [PATCH] git-filter-branch: more detailed USAGE
Message-ID: <46D6EE65.3040503@telecom.at>
URL: https://gitlist.dev/e/46D6EE65.3040503%40telecom.at
In-Reply-To: <11884893671845-git-send-email-giuseppe.bilotta@gmail.com>

```
Giuseppe Bilotta schrieb:
> -USAGE="git-filter-branch [-d TEMPDIR] [FILTERS] [REV-RANGE]"
> +USAGE="[-d <tempdir>] \
> +[--env-filter <command>] \
> +[--tree-filter <command>] \
> +[--index-filter <command>] \
> +[--parent-filter <command>] \
> +[--msg-filter <command>] \
> +[--commit-filter <command>] \
> +[--tag-name-filter <command>] \
> +[--subdirectory-filter <command>] \

+[--subdirectory-filter <directory>] \

> +[--original <namespace>] [rev-range]"

-- Hannes

```

## Giuseppe Bilotta, 2007-08-30 17:10

Subject: [PATCH] git-filter-branch: more detailed USAGE
Message-ID: <1188493842963-git-send-email-giuseppe.bilotta@gmail.com>
URL: https://gitlist.dev/e/1188493842963-git-send-email-giuseppe.bilotta%40gmail.com
In-Reply-To: <11884893671845-git-send-email-giuseppe.bilotta@gmail.com>

```
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-filter-branch.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 0190060..ec2f75d 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -8,7 +8,13 @@
 # a new branch. You can specify a number of filters to modify the commits,
 # files and trees.
 
-USAGE="git-filter-branch [-d TEMPDIR] [FILTERS] [REV-RANGE]"
+USAGE="[--env-filter <command>] [--tree-filter <command>] \
+[--index-filter <command>] [--parent-filter <command>] \
+[--msg-filter <command>] [--commit-filter <command>] \
+[--tag-name-filter <command>] [--subdirectory-filter <directory>] \
+[--original <namespace>] [-d <directory>] [-f | --force] \
+[<rev-list options>...]"
+
 . git-sh-setup
 
 warn () {
-- 
1.5.2.5

```

## Giuseppe Bilotta, 2007-08-30 17:10

Subject: [PATCH] git-filter-branch: document --original option
Message-ID: <11884938431525-git-send-email-giuseppe.bilotta@gmail.com>
URL: https://gitlist.dev/e/11884938431525-git-send-email-giuseppe.bilotta%40gmail.com
In-Reply-To: <1188493842963-git-send-email-giuseppe.bilotta@gmail.com>

```
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/git-filter-branch.txt |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index 8c43be6..ae03514 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -12,7 +12,8 @@ SYNOPSIS
 	[--index-filter <command>] [--parent-filter <command>]
 	[--msg-filter <command>] [--commit-filter <command>]
 	[--tag-name-filter <command>] [--subdirectory-filter <directory>]
-	[-d <directory>] [-f | --force] [<rev-list options>...]
+	[--original <namespace>] [-d <directory>] [-f | --force]
+	[<rev-list options>...]
 
 DESCRIPTION
 -----------
@@ -134,6 +135,10 @@ definition impossible to preserve signatures at any rate.)
 	The result will contain that directory (and only that) as its
 	project root.
 
+--original <namespace>::
+	Use this option to set the namespace where the original commits
+	will be stored. The default value is 'refs/original'.
+
 -d <directory>::
 	Use this option to set the path to the temporary directory used for
 	rewriting.  When applying a tree filter, the command needs to
-- 
1.5.2.5

```

## Giuseppe Bilotta, 2007-08-30 17:11

Subject: Re: [PATCH] git-filter-branch: more detailed USAGE
Message-ID: <cb7bb73a0708301011s3aa3dffaxa75d8fcee320d143@mail.gmail.com>
URL: https://gitlist.dev/e/cb7bb73a0708301011s3aa3dffaxa75d8fcee320d143%40mail.gmail.com
In-Reply-To: <46D6EE65.3040503@telecom.at>

```
On 8/30/07, Johannes Sixt <j.sixt@telecom.at> wrote:
> Giuseppe Bilotta schrieb:
> > +[--subdirectory-filter <command>] \
>
> +[--subdirectory-filter <directory>] \

Doh. I'll resend.

-- 
Giuseppe "Oblomov" Bilotta

```

## Junio C Hamano, 2007-08-30 21:55

Subject: Re: [PATCH] git-filter-branch: document --original option
Message-ID: <7vy7fs7kmc.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy7fs7kmc.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <11884938431525-git-send-email-giuseppe.bilotta@gmail.com>

```
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:

> +--original <namespace>::
> +	Use this option to set the namespace where the original commits
> +	will be stored. The default value is 'refs/original'.
> +

The default seems to be "refs/original/".

Even worse.

I think if you say --force --original refs/head (notice the lack
of "s" nor slash at the end), the code will get you in a *lot*
of trouble.

Dscho, don't we want to do something like this?

---
 git-filter-branch.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 0190060..a7f50a6 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -134,6 +134,7 @@ do
 		filter_subdir="$OPTARG"
 		;;
 	--original)
+		case "$OPTARG" in */) ;; *) OPTARG="$OPTARG/" ;; esac
 		orig_namespace="$OPTARG"
 		;;
 	*)

```

## David Kastrup, 2007-08-30 22:00

Subject: Re: [PATCH] git-filter-branch: document --original option
Message-ID: <85d4x4d6oi.fsf@lola.goethe.zz>
URL: https://gitlist.dev/e/85d4x4d6oi.fsf%40lola.goethe.zz
In-Reply-To: <7vy7fs7kmc.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
>
>> +--original <namespace>::
>> +	Use this option to set the namespace where the original commits
>> +	will be stored. The default value is 'refs/original'.
>> +
>
> The default seems to be "refs/original/".
>
> Even worse.
>
> I think if you say --force --original refs/head (notice the lack
> of "s" nor slash at the end), the code will get you in a *lot*
> of trouble.
>
> Dscho, don't we want to do something like this?
>
> ---
>  git-filter-branch.sh |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 0190060..a7f50a6 100755
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -134,6 +134,7 @@ do
>  		filter_subdir="$OPTARG"
>  		;;
>  	--original)
> +		case "$OPTARG" in */) ;; *) OPTARG="$OPTARG/" ;; esac
>  		orig_namespace="$OPTARG"
>  		;;
>  	*)

orig_namespace="${OPTARG%/}/"

Sure, it does not win the "portable to Version 7" price, but our
scripts don't do that, anyway.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

```

## Junio C Hamano, 2007-08-30 22:23

Subject: Re: [PATCH] git-filter-branch: document --original option
Message-ID: <7vodgo7jbn.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vodgo7jbn.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <85d4x4d6oi.fsf@lola.goethe.zz>

```
David Kastrup <dak@gnu.org> writes:

> Junio C Hamano <gitster@pobox.com> writes:
> ...
>>  	--original)
>> +		case "$OPTARG" in */) ;; *) OPTARG="$OPTARG/" ;; esac
>>  		orig_namespace="$OPTARG"
>>  		;;
>>  	*)
>
> orig_namespace="${OPTARG%/}/"
>
> Sure, it does not win the "portable to Version 7" price, but our
> scripts don't do that, anyway.

I agree we do not give the "portable to version 7" prize
anymore.  But you made me realize another thing.

I think it should make sure orig_namespace has one and only one
trailing slash, because otherwise "--original refs/heads//"
would lead you to the same disaster.

```

## Johannes Schindelin, 2007-08-30 23:04

Subject: Re: [PATCH] git-filter-branch: document --original option
Message-ID: <Pine.LNX.4.64.0708310004130.28586@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0708310004130.28586%40racer.site
In-Reply-To: <7vy7fs7kmc.fsf@gitster.siamese.dyndns.org>

```
Hi,

On Thu, 30 Aug 2007, Junio C Hamano wrote:

> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
> 
> > +--original <namespace>::
> > +	Use this option to set the namespace where the original commits
> > +	will be stored. The default value is 'refs/original'.
> > +
> 
> The default seems to be "refs/original/".
> 
> Even worse.
> 
> I think if you say --force --original refs/head (notice the lack
> of "s" nor slash at the end), the code will get you in a *lot*
> of trouble.
> 
> Dscho, don't we want to do something like this?

Yes, I think so, too.  The --original option is probably the least tested 
option of filter-branch :-(

Ciao,
Dscho

```

## Junio C Hamano, 2007-08-30 23:13

Subject: Re: [PATCH] git-filter-branch: document --original option
Message-ID: <7v3ay07h0h.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v3ay07h0h.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <7vodgo7jbn.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> I agree we do not give the "portable to version 7" prize
> anymore.  But you made me realize another thing.
>
> I think it should make sure orig_namespace has one and only one
> trailing slash, because otherwise "--original refs/heads//"
> would lead you to the same disaster.

Perhaps,

	orig_namespace=$(expr "$OPTARG/" : '\(.*[^/]\)/*$')/

Well, I know people hate colon-expr, but we earlier ruled out
(and we still do) ${parameter//pattern/string} as bashism beyond
the portability line, and I do not see an alternative easier to
read than this...

```

## David Kastrup, 2007-08-31 06:13

Subject: Re: [PATCH] git-filter-branch: document --original option
Message-ID: <85642wcju7.fsf@lola.goethe.zz>
URL: https://gitlist.dev/e/85642wcju7.fsf%40lola.goethe.zz
In-Reply-To: <7vodgo7jbn.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>> ...
>>>  	--original)
>>> +		case "$OPTARG" in */) ;; *) OPTARG="$OPTARG/" ;; esac
>>>  		orig_namespace="$OPTARG"
>>>  		;;
>>>  	*)
>>
>> orig_namespace="${OPTARG%/}/"
>>
>> Sure, it does not win the "portable to Version 7" price, but our
>> scripts don't do that, anyway.
>
> I agree we do not give the "portable to version 7" prize
> anymore.  But you made me realize another thing.
>
> I think it should make sure orig_namespace has one and only one
> trailing slash, because otherwise "--original refs/heads//"
> would lead you to the same disaster.

I am not sure we should bend over backwards to people courting
disaster.  Completion does not add double slashes, and that's the most
common cause for spurious slashes.  And I don't know an equally
straightforward way to remove multiple slashes at the end.

do orig_namespace="$OPTARG";OPTARG="${OPTARG%/}/"
while test "X${orig_namespace}" != "X${OPTARG}"

is not really all too pretty.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

```

## David Kastrup, 2007-08-31 06:16

Subject: Re: [PATCH] git-filter-branch: document --original option
Message-ID: <851wdkcjp4.fsf@lola.goethe.zz>
URL: https://gitlist.dev/e/851wdkcjp4.fsf%40lola.goethe.zz
In-Reply-To: <7v3ay07h0h.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> I agree we do not give the "portable to version 7" prize
>> anymore.  But you made me realize another thing.
>>
>> I think it should make sure orig_namespace has one and only one
>> trailing slash, because otherwise "--original refs/heads//"
>> would lead you to the same disaster.
>
> Perhaps,
>
> 	orig_namespace=$(expr "$OPTARG/" : '\(.*[^/]\)/*$')/
>

See separate proposal which I find still prettier (and which does not
fork).

But I really don't think we should bend over backwards: multiple end
slashes have explicit manual origin.  People deserve what they get
then.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

```
