aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@localhost>2012-12-17 06:38:26 -0900
committerroot <root@localhost>2012-12-17 06:38:26 -0900
commit1d7a760a7eb8e2541d817421b2a0c264d4a92a41 (patch)
tree0fd8bc9ca34dcde23b4e213dcc2f5b4f08bfdc62
parent100490af1f2cc13e5181804c3e85e92ec3376531 (diff)
downloadgit-remote-gcrypt-1d7a760a7eb8e2541d817421b2a0c264d4a92a41.zip
git-remote-gcrypt-1d7a760a7eb8e2541d817421b2a0c264d4a92a41.tar.gz
git-remote-gcrypt-1d7a760a7eb8e2541d817421b2a0c264d4a92a41.tar.bz2
Replace wc -l with line_count
-rwxr-xr-xgit-remote-gcrypt23
1 files changed, 16 insertions, 7 deletions
diff --git a/git-remote-gcrypt b/git-remote-gcrypt
index 9373901..d38f889 100755
--- a/git-remote-gcrypt
+++ b/git-remote-gcrypt
@@ -143,6 +143,18 @@ filter_to()
setvar "$1" "$f_result_"
}
+# Output the number of lines in $1
+line_count()
+{
+ local f_x=0 IFS=
+ IFS=$Newline
+ for f_line in $1
+ do
+ f_x=$(($f_x + 1))
+ done
+ xecho "$f_x"
+}
+
## gitception part
# Fetch giturl $1, file $2
@@ -577,7 +589,7 @@ fetch_decrypt_pack()
# $4 to list of packfiles to delete
repack_if_needed()
{
- local pack_= packline_= premote_= key_= pkeep_= n_=
+ local pack_= packline_= premote_= key_= pkeep_= n_= m_=
# $TmpPack_Encrypted set in caller
@@ -593,12 +605,9 @@ repack_if_needed()
pick_fields @premote_ 1,2 "$Packlist"
pick_fields @pkeep_ 2 "$Keeplist"
- if isnull "$pkeep_"; then
- n_=$(xecho "$Packlist" | wc -l)
- else
- n_=$(xecho "$Packlist" | grep -v -e "$pkeep_" | wc -l)
- fi
- if [ $Repack_limit -gt "$n_" ]; then
+ n_=$(line_count "$Packlist")
+ m_=$(line_count "$pkeep_")
+ if [ $Repack_limit -gt "$(($n_ - $m_))" ]; then
return
fi
echo_info "Repacking remote $NAME, ..."