Skip to contentSkip to conversation

git-filter-branch: more detailed USAGE

PATCH In review Giuseppe Bilotta 5 participants 12 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-filter-branch: more detailed USAGE

---
 git-filter-branch.sh |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
git-filter-branch.sh +10 -1
index 0190060..9fcab56 100755
@@ -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 () {
Signature · 1 line
1.5.2.5
#1 lore raw

PATCH 1/1 git-filter-branch: more detailed USAGE

---
 git-filter-branch.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
git-filter-branch.sh +7 -1
index 0190060..ec2f75d 100755
@@ -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 () {
Signature · 1 line
1.5.2.5
#2 lore raw

PATCH 1/1 git-filter-branch: document --original option

---
 Documentation/git-filter-branch.txt |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Documentation/git-filter-branch.txt +6 -1
index 8c43be6..ae03514 100644
@@ -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
Signature · 1 line
1.5.2.5
#3 lore raw

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

Review

Quoted 4 lines · Giuseppe Bilotta

+--original <namespace>::

(quoted diff) +3 -0
+	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(-)
git-filter-branch.sh +1 -0
index 0190060..a7f50a6 100755
@@ -134,6 +134,7 @@ do
 		filter_subdir="$OPTARG"
 		;;
 	--original)
+		case "$OPTARG" in */) ;; *) OPTARG="$OPTARG/" ;; esac
 		orig_namespace="$OPTARG"
 		;;
 	*)
#4 lore raw

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

Quoted 26 lines · Junio C Hamano

Review

Quoted 4 lines · Giuseppe Bilotta

+--original <namespace>::

(quoted diff) +3 -0
+	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(-)
git-filter-branch.sh +0 -0
index 0190060..a7f50a6 100755

git-filter-branch.sh do · line 140

Quoted 7 lines
git-filter-branch.sh +1 -0
@@ -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.

Signature · 1 line
David Kastrup, Kriemhildstr. 15, 44793 Bochum
#5 lore raw

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

Quoted 10 lines · David Kastrup

Junio C Hamano <[email protected]> writes:
...

git-filter-branch.sh do · line 140

Quoted 5 lines
git-filter-branch.sh +1 -0
 	--original)
+		case "$OPTARG" in */) ;; *) OPTARG="$OPTARG/" ;; esac
 		orig_namespace="$OPTARG"
 		;;
 	*)

orig_namespace="${OPTARG%/}/"

Quoted 2 lines

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.

#6 lore raw

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

Quoted 6 lines · Junio C Hamano

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...

#7 lore raw

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

Quoted 5 lines · Junio C Hamano
Quoted 3 lines · Junio C Hamano

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

Quoted 8 lines
Quoted 3 lines

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.

Signature · 1 line
David Kastrup, Kriemhildstr. 15, 44793 Bochum
#8 lore raw

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

In reply to Junio C Hamano
Quoted 15 lines · Junio C Hamano
Quoted 10 lines · David Kastrup

Junio C Hamano <[email protected]> writes:
...

git-filter-branch.sh do · line 140

Quoted 5 lines
git-filter-branch.sh +1 -0
 	--original)
+		case "$OPTARG" in */) ;; *) OPTARG="$OPTARG/" ;; esac
 		orig_namespace="$OPTARG"
 		;;
 	*)

orig_namespace="${OPTARG%/}/"

Quoted 2 lines

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

Quoted 6 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.

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.

Signature · 1 line
David Kastrup, Kriemhildstr. 15, 44793 Bochum
#9 lore raw

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

In reply to Junio C Hamano

Hi,

Quoted 9 lines · Junio C Hamano

Review

Quoted 4 lines · Giuseppe Bilotta

+--original <namespace>::

(quoted diff) +3 -0
+	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/".

Quoted 7 lines

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

#10 lore raw
In reply to Giuseppe Bilotta

git-filter-branch.sh line 19

Quoted 10 lines · Giuseppe Bilotta
git-filter-branch.sh +9 -1
-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>] \

Quoted 1 line

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

-- Hannes

#11 lore raw
Quoted 4 lines · Johannes Sixt
Quoted 1 line · Giuseppe Bilotta

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

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

Doh. I'll resend.

Signature · 1 line
Giuseppe "Oblomov" Bilotta