summaryrefslogtreecommitdiff
path: root/post-commit.sh
diff options
context:
space:
mode:
authorp4bl0 <pablo@rauzy.name>2010-07-25 13:52:08 +0200
committerp4bl0 <pablo@rauzy.name>2010-07-25 13:52:08 +0200
commit7b173c1770bd96196c6ba912845b501749b1810b (patch)
tree8597ea83e6f1d78a363516c0903fe96c392584c8 /post-commit.sh
parentb9b53df3cc66482af91f6a52a0ab716fc88f323d (diff)
preventing to go through foreach loops if not actually in use (there can be a lot of commits)
Diffstat (limited to 'post-commit.sh')
-rw-r--r--post-commit.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/post-commit.sh b/post-commit.sh
index 1f13f0e..6929db4 100644
--- a/post-commit.sh
+++ b/post-commit.sh
@@ -238,12 +238,17 @@ replace_foreach () {
fe="foreach:$1"
cat > "$temp"
cat "$temp" | \
+ sed -n "/<?fugitive\s\+$fe\s*?>/,/<?fugitive\s\+end$fe\s*?>/p" | \
+ tail -n +2 | head -n -1 > "$foreach_body"
+ if [ ! -s "$foreach_body" ]; then
+ cat "$temp"
+ rm "$foreach_body" "$tmpfile" "$temp"
+ return
+ fi
+ cat "$temp" | \
sed "s/<?fugitive\s\+$fe\s*?>/<?fugitive foreach_body ?>\n\0/" | \
sed "/<?fugitive\s\+$fe\s*?>/,/<?fugitive\s\+end$fe\s*?>/d" | \
cat > "$tmpfile"
- cat "$temp" | \
- sed -n "/<?fugitive\s\+$fe\s*?>/,/<?fugitive\s\+end$fe\s*?>/p" | \
- tail -n +2 | head -n -1 > "$foreach_body"
for i in `cat "$2"`; do
cat "$foreach_body" | replace_$1_info "$i"
done > "$temp"