threads / patch / 9708

patchgit-filter-branch: more detailed USAGE

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

## tl;dr

12 messages between Aug 30, 2007 and Aug 31, 2007. Diffs are folded; open one to read it.

replies: 11people: 5as markdown or json

Giuseppe Bilotta· Aug 30, 2007, 15:56 UTC · lore
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-filter-branch.sh |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
Show changes to git-filter-branch.sh +10 −1
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· Aug 30, 2007, 16:20 UTC · re: Giuseppe Bilotta · lore

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

Giuseppe Bilotta schrieb:
Show 10 quoted lines
> -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· Aug 30, 2007, 17:11 UTC · re: Johannes Sixt · lore

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

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
Giuseppe Bilotta· Aug 30, 2007, 17:10 UTC · re: Giuseppe Bilotta · lore
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 git-filter-branch.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Show changes to git-filter-branch.sh +7 −1
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· Aug 30, 2007, 17:10 UTC · re: Giuseppe Bilotta · lore

[PATCH] git-filter-branch: document --original option

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 Documentation/git-filter-branch.txt |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Show changes to Documentation/git-filter-branch.txt +6 −1
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
Junio C Hamano· Aug 30, 2007, 21:55 UTC · re: Giuseppe Bilotta · lore

Re: [PATCH] git-filter-branch: document --original option

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(-)
Show changes to git-filter-branch.sh +1 −0
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· Aug 30, 2007, 22:00 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-filter-branch: document --original option

Junio C Hamano <gitster@pobox.com> writes:
Show 33 quoted lines
> 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· Aug 30, 2007, 22:23 UTC · re: David Kastrup · lore

Re: [PATCH] git-filter-branch: document --original option

David Kastrup <dak@gnu.org> writes:
Show 12 quoted lines
> 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.

Junio C Hamano· Aug 30, 2007, 23:13 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-filter-branch: document --original option

Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> 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· Aug 31, 2007, 06:16 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-filter-branch: document --original option

Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> 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
David Kastrup· Aug 31, 2007, 06:13 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-filter-branch: document --original option

Junio C Hamano <gitster@pobox.com> writes:
Show 21 quoted lines
> 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
Johannes Schindelin· Aug 30, 2007, 23:04 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-filter-branch: document --original option

Hi,
On Thu, 30 Aug 2007, Junio C Hamano wrote:
Show 16 quoted lines
> 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

← back to recent threads