Skip to contentSkip to conversation

cg-log: cleanup line wrapping by using bash internals

PATCH In review Jonas Fonseca 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cg-log: cleanup line wrapping by using bash internals

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

---

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 <[email protected]> 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 <[email protected]> Sat, 16 Apr 2005 22:26:31 -0700 committer Linus Torvalds <[email protected]> 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(-)
cg-log +2 -2
@@ -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"
Signature · 1 line
Jonas Fonseca
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"JF" == Jonas Fonseca <[email protected]> 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 <[email protected]>, Wed Jun 1 11:38:07 2005 -0700
Committer Linus Torvalds <[email protected]>, 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.