Skip to content

Commit 0882666

Browse files
committed
fixing bad return of "find" call
1 parent a2fa383 commit 0882666

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
env.list

program.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,28 @@ download_repository() {
2727
fi
2828
}
2929

30+
find_repositories() {
31+
find "$1" -name .git -exec dirname {} \;
32+
}
33+
3034
optimize_sync() {
3135
echo "optimizing using git gc"
32-
cd "$SYNC" || error "optimizing_sync: cd $SYNC" || return
33-
DIRS=$(find . -mindepth 4 -maxdepth 4 -type d -not -path "\./\.git*")
34-
for i in $DIRS
36+
for repo in $(find_repositories $SYNC)
3537
do
36-
echo "$i"
37-
cd "$i" || error "optimizing_sync: cd $i" || continue
38+
echo "optimizing $repo"
39+
cd "$repo" || error "optimizing_sync: cd $repo" || continue
3840
git gc
3941
cd - || error "optimizing_sync: cd - (assert false)" || continue
4042
done
41-
git gc
42-
cd ..
4343
echo "optimizing done"
4444
}
4545

4646
clone_sync() {
4747
rm -rf ${BACKUP:?}/$SYNC
4848
echo "cloning sync to avoid concurrency when writing"
49-
find $SYNC -name .git | while read -r repository; do
50-
git clone "$repository" $BACKUP/"$repository"
49+
for repo in $(find_repositories $SYNC)
50+
do
51+
git clone "$repo" $BACKUP/"$repo"
5152
done
5253
# copy directories which are not repositories yet
5354
echo "cp -rn $SYNC $BACKUP/$SYNC"

0 commit comments

Comments
 (0)