git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
PGPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Date
Sep 2, 2005, 10:31 UTC
Message-ID
<20050902103135.24918.7990.stgit@zion.home.lan>
In-Reply-To
<20050902103125.24918.905.stgit@zion.home.lan>

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
Previous: Paolo 'Blaisorblade' GiarrussoNext: Petr Baudis
Message 4 of 6 in “Fix txt installation”
  1. 1/4 Fix txt installationPaolo 'Blaisorblade' Giarrusso, Sep 2, 2005
  2. 2/4 Fix cg-{diff,mkpatch} with HEAD^Paolo 'Blaisorblade' Giarrusso, Sep 2, 2005
  3. 3/4 commit-id micro cleanupPaolo 'Blaisorblade' Giarrusso, Sep 2, 2005
  4. 4/4 cg-{diff,mkpatch}: rename/copy optional detectionPaolo 'Blaisorblade' Giarrusso, Sep 2, 2005
  5. Petr BaudisSep 12, 2005
  6. BlaisorbladeSep 13, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.