1
0
Fork 0
mirror of https://git.ludikovsky.name/git/fugitive.git synced 2024-05-18 22:45:31 +02:00

preventing to go through foreach loops if not actually in use (there can be a lot of commits)

This commit is contained in:
p4bl0 2010-07-25 13:52:08 +02:00
parent b9b53df3cc
commit 7b173c1770

View file

@ -237,13 +237,18 @@ replace_foreach () {
temp=`tempfile -p "fugitive"`
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"