git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH Cogito] cg-diff: add -s option to summarize (diffstat) changes
@ 2005-10-02 10:14 Jonas Fonseca
  0 siblings, 0 replies; only message in thread
From: Jonas Fonseca @ 2005-10-02 10:14 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

Pipes the diff output through git-apply --stat --summary.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

---
commit 20282cdd610ecef03c8c97853bc0749ef3ab32b3
tree 6dd04a780217d116c44c1f78c5e831fc40a32df9
parent b41f8cafc556233613412ff3545e3507202b666a
author Jonas Fonseca <fonseca@diku.dk> Thu, 29 Sep 2005 15:09:42 +0200
committer Jonas Fonseca <fonseca@stud1-9.itu.dk> Thu, 29 Sep 2005 15:09:42 +0200

 cg-diff |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/cg-diff b/cg-diff
--- a/cg-diff
+++ b/cg-diff
@@ -17,6 +17,11 @@
 #	Instead of one ID denotes a parent commit to the specified ID
 #	(which must not be a tree, obviously).
 #
+# -s::
+#	Summarize the diff by showing a histogram for removed and added
+#	lines (similar to the output of diffstat(1)) and information
+#	about added and renamed files and mode changes.
+#
 # -r FROM_ID[:TO_ID]::
 #	Specify the revisions to diff using either '-r rev1:rev2' or
 #	'-r rev1 -r rev2'. If no revision is specified, the current
@@ -41,7 +46,7 @@
 #	to before invoking $PAGER. It defaults to $LESS concatenated
 #	with the `R` flag to allow displaying of colorized output.
 
-USAGE="cg-diff [-c] [-m] [-p] [-r FROM_ID[:TO_ID]] [FILE]..."
+USAGE="cg-diff [-c] [-m] [-s] [-p] [-r FROM_ID[:TO_ID]] [FILE]..."
 
 . ${COGITO_LIB}cg-Xlib || exit 1
 
@@ -65,7 +70,12 @@ setup_colors()
 
 colorize()
 {
-	if [ "$opt_color" ]; then
+	if [ "$opt_summary" ]; then
+		# Add an empty line so the diffstat indentation won't
+		# get messed up
+		echo
+		git-apply --summary --stat
+	elif [ "$opt_color" ]; then
 		gawk '
 		{ if (/^(diff --git) /)
 		    print "'$coldiffhdr'" $0 "'$coldefault'"
@@ -96,6 +106,7 @@ id2=" "
 parent=
 opt_color=
 mergebase=
+opt_summary=
 
 while optparse; do
 	if optparse -c; then
@@ -103,6 +114,8 @@ while optparse; do
 		setup_colors
 	elif optparse -p; then
 		parent=1
+	elif optparse -s; then
+		opt_summary=1
 	elif optparse -r=; then
 		if echo "$OPTARG" | fgrep -q '..'; then
 			id2=${OPTARG#*..}

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-02 10:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-02 10:14 [PATCH Cogito] cg-diff: add -s option to summarize (diffstat) changes Jonas Fonseca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).