threads / patch / 809

patchcg-log: cleanup line wrapping by using bash internals

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

## tl;dr

2 messages between Jun 2, 2005 and Jun 2, 2005. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Jonas Fonseca· Jun 2, 2005, 14:46 UTC · lore

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(-)
Show changes to cg-log +2 −2
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
Junio C Hamano· Jun 2, 2005, 20:01 UTC · re: Jonas Fonseca · lore

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

>>>>> "JF" == Jonas Fonseca <fonseca@diku.dk> writes:
JF> BTW, I noticed the following errors:

JF> fatal: internal error in diffcore: unmodified entry remains JF> fatal: internal error in diffcore: unmodified entry remains JF> fatal: internal error in diffcore: unmodified entry remains

JF> with both current cogito and git.

If you have acquired this fix and still see the above please let me know.

Commit 67574c403f1e27660bbd0348b81b31adc9889b20 Author Junio C Hamano <junkio@cox.net>, Wed Jun 1 11:38:07 2005 -0700 Committer Linus Torvalds <torvalds@ppc970.osdl.org>, Wed Jun 1 13:24:03 2005 -0700

[PATCH] diff: mode bits fixes

The core GIT repository has trees that record regular file mode in 0664 instead of normalized 0644 pattern. Comparing such a tree with another tree that records the same file in 0644 pattern without content changes with git-diff-tree causes it to feed otherwise unmodified pairs to the diff_change() routine, which triggers a sanity check routine and barfs. This patch fixes the problem, along with the fix to another caller that uses unnormalized mode bits to call diff_change() routine in a similar way.

Without this patch, you will see "fatal error" from diff-tree when you run git-deltafy-script on the core GIT repository itself.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

← back to recent threads