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

[PATCH] cg-log: cleanup line wrapping by using bash internals

From
Jonas Fonseca <fonseca@diku.dk>
Date
Jun 2, 2005, 14:46 UTC
Message-ID
<20050602144621.GB16143@diku.dk>

Use ${#var} instead of echo + wc combo. Additionally also gives a minor speedup.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
cg-log -f
new code:
	real    1m15.462s
	user    0m27.195s
	sys     0m40.639s
old code:
	real    1m38.222s
	user    0m32.563s
	sys     0m56.034s
BTW, I noticed the following errors:
	fatal: internal error in diffcore: unmodified entry remains
	fatal: internal error in diffcore: unmodified entry remains
	fatal: internal error in diffcore: unmodified entry remains
with both current cogito and git.
To reproduce run either of the following in the cogito repo:

git-diff-tree -r 7c1f9aa894ce91928d982a0b197ab596375825a3 e30dd6c68e576d37bddd011aa7131a6d30297b4c git-diff-tree -r c49cd3e4f1dfe4ccbf2b8d00188beaa251fee028 9fec8b26eff58e1f595e8619abf1e42c07645ff8

The last one also triggers in the git repo. The log entries for the two commits are:

commit 6616d1835e81ac0d2304702102d210451c04832a tree 7c1f9aa894ce91928d982a0b197ab596375825a3 parent e30dd6c68e576d37bddd011aa7131a6d30297b4c parent e8871e88adca0637eb0299a41d85400beac928bd author Petr Baudis <pasky@ucw.cz> Sun, 17 Apr 2005 19:30:32 +0200 committer Petr Baudis <xpasky@machine> Sun, 17 Apr 2005 19:30:32 +0200

    Merging: d72ff74f5fd172c6ec9630ee8e08895a0525dcfe
    Merge with Linus. Nothing particularily interesting.

commit e44794706eeb57f2ee38ed1604821aa38b8ad9d2 tree c49cd3e4f1dfe4ccbf2b8d00188beaa251fee028 parent 9fec8b26eff58e1f595e8619abf1e42c07645ff8 author Linus Torvalds <torvalds@ppc970.osdl.org> Sat, 16 Apr 2005 22:26:31 -0700 committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat, 16 Apr 2005 22:26:31 -0700

    Be much more liberal about the file mode bits.
    We only really care about the difference between a file being executable
    or not (by its owner). Everything else we leave for the user umask to
    decide.
Any ideas?
 cg-log |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -129,8 +129,8 @@ list_commit_files()
 	$list_cmd | cut -f 2- | while read file; do
 		echo -n "$sep"
 		sep=", "
-		if [ $(echo "$line$sep$file" | wc -c) -le 75 ]; then
-			line="$line$sep$file"
+		line="$line$sep$file"
+		if [ "${#line}" -le 74 ]; then
 			echo -n "$file"
 		else
 			line="      $file"
-- 
Jonas Fonseca
Next: Junio C Hamano
Message 1 of 2 in “cg-log: cleanup line wrapping by using bash internals”
  1. cg-log: cleanup line wrapping by using bash internalsJonas Fonseca, Jun 2, 2005
  2. Junio C HamanoJun 2, 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.