From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>, Petr Baudis <pasky@suse.cz>
Subject: [PATCH] Make cg-clean faster and space-safe
Date: Thu, 27 Oct 2005 22:39:21 -0400 [thread overview]
Message-ID: <1130467161.2186.25.camel@dv> (raw)
Use bash pattern matching to list all parent directories instead of
using arrays. This makes cg-clean run twice as fast on the Linux kernel
(4 seconds vs 8 seconds).
The new code is also for directory names containing spaces and other
symbols that need to be quoted. Also, the new code is easier to read.
Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/cg-clean b/cg-clean
index ea00d2b..f7b5151 100755
--- a/cg-clean
+++ b/cg-clean
@@ -53,16 +53,12 @@ clean_dirs()
git-ls-files --cached |
sed -n 's|^'"$_git_relpath"'||p' |
sed -n 's|/[^/]*$||p' |
- while IFS='/' read -a dir; do
- i=0
- while test $i != ${#dir[@]}; do
- j=0
- while test $i != $j; do
- echo -n ${dir[$j]}/
- j=$[$j+1]
- done
- echo ${dir[$i]}
- i=$[$i+1]
+ while read dir; do
+ while true; do
+ echo "$dir"
+ updir="${dir%/*}"
+ test "$dir" = "$updir" && break
+ dir="$updir"
done
done |
sort -u >"$dirlist"
--
Regards,
Pavel Roskin
reply other threads:[~2005-10-28 2:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1130467161.2186.25.camel@dv \
--to=proski@gnu.org \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).