git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH Cogito] Add -u option to cg-log to show only commits from a specific user
@ 2005-05-09  0:49 Marcel Holtmann
  2005-05-12 20:23 ` Petr Baudis
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2005-05-09  0:49 UTC (permalink / raw)
  To: Petr Baudis; +Cc: GIT Mailing List

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

Hi Petr,

the attached patch introduces the -u option for cg-log. Now you can give
a username or a part of a username and only commits with a matching
author or committer will be displayed.

This patch also changes the option parsing, because otherwise we are
stuck to a specific order.

Regards

Marcel


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2105 bytes --]

cg-log: needs update
Index: cg-log
===================================================================
--- 00b94eea5b99d5dd1d1bbe9c9ca3502d11aec581/cg-log  (mode:100755)
+++ uncommitted/cg-log  (mode:100755)
@@ -15,6 +15,9 @@
 #
 # Takes an -f option to list which files was changed.
 #
+# Takes -u"username" to list only commits where author or
+# committer contains username.
+#
 # Takes an -r followed with id resolving to a commit to start from
 # (HEAD by default), or id1:id2 representing an (id1;id2] range
 # of commits to show.
@@ -27,29 +30,39 @@
 # at least somewhere it does. Bash is broken.
 trap exit SIGPIPE
 
-if [ "$1" = "-c" ]; then
-	shift
-	# See terminfo(5), "Color Handling"
-	colheader="$(tput setaf 2)"    # Green
-	colauthor="$(tput setaf 6)"    # Cyan
-	colcommitter="$(tput setaf 5)" # Magenta
-	colfiles="$(tput setaf 4)"     # Blue
-	colsignoff="$(tput setaf 3)"   # Yellow
-	coldefault="$(tput op)"        # Restore default
-else
-	colheader=
-	colauthor=
-	colcommitter=
-	colfiles=
-	colsignoff=
-	coldefault=
-fi
-
+colheader=
+colauthor=
+colcommitter=
+colfiles=
+colsignoff=
+coldefault=
 list_files=
-if [ "$1" = "-f" ]; then
-	shift
-	list_files=1
-fi
+user=
+while [ "$1" ]; do
+	case "$1" in
+	-c)
+		# See terminfo(5), "Color Handling"
+		colheader="$(tput setaf 2)"    # Green
+		colauthor="$(tput setaf 6)"    # Cyan
+		colcommitter="$(tput setaf 5)" # Magenta
+		colfiles="$(tput setaf 4)"     # Blue
+		colsignoff="$(tput setaf 3)"   # Yellow
+		coldefault="$(tput op)"        # Restore default
+		shift
+		;;
+	-f)
+		list_files=1
+		shift
+		;;
+	-u*)
+		user="${1#-u}"
+		shift
+		;;
+	*)
+		break
+		;;
+	esac
+done
 
 list_commit_files()
 {
@@ -109,6 +122,9 @@
 		parent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')
 		[ "$parent" ] && [ "$(git-diff-tree -r $commit $parent "$@")" ] || continue
 	fi
+	if [ "$user" ]; then
+		git-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi "$user" || continue
+	fi
 	echo $colheader""commit ${commit%:*} $coldefault;
 	git-cat-file commit $commit | \
 		while read key rest; do

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH Cogito] Add -u option to cg-log to show only commits from a specific user
@ 2005-05-12 21:58 Marcel Holtmann
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2005-05-12 21:58 UTC (permalink / raw)
  To: Petr Baudis; +Cc: GIT Mailing List

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

Hi Petr,

the attached patch introduces the -u option for cg-log. Now you can give
a username or a part of an username and only commits with a matching
author or committer will be displayed. Based on a patch from Sean.

Regards

Marcel


Signed-off-by: Marcel Holtmann <marcel@holtmann.org>


[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 1168 bytes --]

Index: cg-log
===================================================================
--- 7fa81b554162c34c616e74392960939412d18081/cg-log  (mode:100755)
+++ uncommitted/cg-log  (mode:100755)
@@ -15,6 +15,9 @@
 #
 # Takes an -f option to list which files was changed.
 #
+# Takes -u"username" to list only commits where author or
+# committer contains username.
+#
 # Takes an -r followed with id resolving to a commit to start from
 # (HEAD by default), or id1:id2 representing an (id1;id2] range
 # of commits to show.
@@ -34,6 +37,7 @@
 colsignoff=
 coldefault=
 list_files=
+user=
 while [ "$1" ]; do
 	# TODO: Parse -r here too.
 	case "$1" in
@@ -51,6 +55,10 @@
 		list_files=1
 		shift
 		;;
+	-u*)
+		user="${1#-u}"
+		shift
+		;;
 	*)
 		break
 		;;
@@ -123,6 +131,9 @@
 		parent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')
 		[ "$parent" ] && [ "$(git-diff-tree -r $commit $parent "$@")" ] || continue
 	fi
+	if [ "$user" ]; then
+		git-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi "$user" || continue
+	fi
 	echo $colheader""commit ${commit%:*} $coldefault;
 	git-cat-file commit $commit | \
 		while read key rest; do

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-12 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-09  0:49 [PATCH Cogito] Add -u option to cg-log to show only commits from a specific user Marcel Holtmann
2005-05-12 20:23 ` Petr Baudis
  -- strict thread matches above, loose matches on Subject: below --
2005-05-12 21:58 Marcel Holtmann

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