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

[PATCH 9/10] Move file matching inside the loop.

From
Jonas Fonseca <fonseca@diku.dk>
Date
Jun 4, 2005, 14:43 UTC
Message-ID
<20050604144306.GM12615@diku.dk>
In-Reply-To
<20050604143831.GD12615@diku.dk>

Handling of -f is done inide the loop so no extra git-cat-file call is necessary. Store file arguments to cg-log in an array to make them easier to access from print_commit_log().

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 cg-log |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -73,6 +73,7 @@ log_start=
 log_end=
 user=
 mergebase=
+files=()
 
 while [ "$1" ]; do
 	case "$1" in
@@ -107,6 +108,7 @@ while [ "$1" ]; do
 		mergebase=1
 		;;
 	*)
+		files=("$@")
 		break
 		;;
 	esac
@@ -184,6 +186,12 @@ print_commit_log() {
 				parents[${#parents[@]}]="$rest"
 				;;
 			"")
+				if [ "$files" ]; then
+					parent="${parents[0]}"
+					diff_ops=
+					[ "$parent" ] || diff_ops=--root
+					[ "$(git-diff-tree -r $diff_ops $commit $parent "${files[@]}")" ] || return 1
+				fi
 				if [ "$user" ]; then
 					echo -e "author $author\ncommitter $committer" \
 						| grep -qi "$user" || return
@@ -221,12 +229,6 @@ print_commit_log() {
 $revls | $revsort | while read time commit parents; do
 	trap exit SIGPIPE
 	[ "$revfmt" = "git-rev-list" ] && commit="$time"
-	if [ $# -ne 0 ]; then
-		parent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')
-		diff_ops=
-		[ "$parent" ] || diff_ops=--root
-		[ "$(git-diff-tree -r $diff_ops $commit $parent "$@")" ] || continue
-	fi
 	log="$(print_commit_log $commit)"
 	if [ "$log" ]; then
 		echo "$log"
-- 
Jonas Fonseca
Previous: Jonas FonsecaNext: Jonas Fonseca
Message 10 of 11 in “[PATCHSET] cg-log cleanups and enhancements”
  1. Jonas FonsecaJun 4, 2005
  2. 1/10 Cleanup conversion to human readable dateJonas Fonseca, Jun 4, 2005
  3. 2/10 Separate handling of tree and parent in commit headersJonas Fonseca, Jun 4, 2005
  4. 3/10 Separate handling of author and committer in commit headersJonas Fonseca, Jun 4, 2005
  5. 4/10 First parse all commit header entries then print themJonas Fonseca, Jun 4, 2005
  6. 5/10 Move printing of the commit info line inside the loopJonas Fonseca, Jun 4, 2005
  7. 6/10 Remove the catch all ruleJonas Fonseca, Jun 4, 2005
  8. 7/10 Move log printing to separate functionJonas Fonseca, Jun 4, 2005
  9. 8/10 Move the username matching inside the loopJonas Fonseca, Jun 4, 2005
  10. 9/10 Move file matching inside the loop.Jonas Fonseca, Jun 4, 2005
  11. 10/10 Add -s option to show log summaryJonas Fonseca, Jun 4, 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.