[PATCH 4/4] cg-{diff,mkpatch}: rename/copy optional detection

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Date: 2005-09-02 20:31:38
Add -B, -M and -C options to detect content rewrites, renames and changes
to cg-diff and cg-mkpatch, to be passed right down to git-diff-*.
I've not added a way to pass down any option, since not everything may make
sense, and a shell script colorizing --name-only-z output would not play so
nice (and I mean "unreliable behaviour" - not tested obviously).

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 cg-diff    |   17 +++++++++++++++--
 cg-mkpatch |   15 ++++++++++++++-
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/cg-diff b/cg-diff
--- a/cg-diff
+++ b/cg-diff
@@ -28,6 +28,12 @@
 #	Base the diff at the merge base of the -r arguments (defaulting
 #	to HEAD and origin).
 #
+# -M::
+# -C::
+# -B::
+#	Passed down to git-diff-*, to mean respectively "detect renames",
+#	"detect copies", "detect file rewriting".
+#
 # ENVIRONMENT VARIABLES
 # ---------------------
 # PAGER::
@@ -92,6 +98,7 @@ id2=" "
 parent=
 opt_color=
 mergebase=
+gitflags=
 
 while optparse; do
 	if optparse -c; then
@@ -115,6 +122,12 @@ while optparse; do
 		fi
 	elif optparse -m; then
 		mergebase=1
+	elif optparse -M; then
+		gitflags="$gitflags -M"
+	elif optparse -C; then
+		gitflags="$gitflags -C"
+	elif optparse -B; then
+		gitflags="$gitflags -B"
 	else
 		optfail
 	fi
@@ -155,7 +168,7 @@ if [ "$id2" = " " ]; then
 	# FIXME: Update ret based on what did we match. And take "$@"
 	# to account after all.
 	ret=
-	cat $filter | xargs git-diff-cache -r -p $tree | colorize | pager
+	cat $filter | xargs git-diff-cache $gitflags -r -p $tree | colorize | pager
 
 	rm $filter
 
@@ -169,7 +182,7 @@ id2=$(tree-id "$id2") || exit 1
 
 [ "$id1" = "$id2" ] && die "trying to diff $id1 against itself"
 
-cat $filter | xargs git-diff-tree -r -p $id1 $id2 | colorize | pager
+cat $filter | xargs git-diff-tree $gitflags -r -p $id1 $id2 | colorize | pager
 
 rm $filter
 exit 0
diff --git a/cg-mkpatch b/cg-mkpatch
--- a/cg-mkpatch
+++ b/cg-mkpatch
@@ -22,6 +22,12 @@
 # -m::
 #	Base the patches at the merge base of the -r arguments
 #	(defaulting to HEAD and origin).
+
+# -M::
+# -C::
+# -B::
+#	Passed down to git-diff-*, to mean respectively "detect renames",
+#	"detect copies", "detect file rewriting".
 #
 # EXAMPLE USAGE
 # -------------
@@ -45,7 +51,7 @@ showpatch()
 	header=$(mktemp -t gitpatch.XXXXXX)
 	patch=$(mktemp -t gitpatch.XXXXXX)
 	id=$1
-	cg-diff -p -r $id >$patch
+	cg-diff $gitflags -p -r $id >$patch
 	git-cat-file commit $id | while read key rest; do
 		case "$key" in
 		"author"|"committer")
@@ -81,6 +87,7 @@ omit_header=
 log_start=
 log_end=
 mergebase=
+gitflags=
 
 while optparse; do
 	if optparse -s; then
@@ -101,6 +108,12 @@ while optparse; do
 		fi
 	elif optparse -m; then
 		mergebase=1
+	elif optparse -M; then
+		gitflags="$gitflags -M"
+	elif optparse -C; then
+		gitflags="$gitflags -C"
+	elif optparse -B; then
+		gitflags="$gitflags -B"
 	else
 		optfail
 	fi

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Sep 02 20:36:02 2005

This archive was generated by hypermail 2.1.8 : 2005-09-02 20:36:34 EST