mirror of
https://git.ludikovsky.name/git/fugitive.git
synced 2024-09-28 14:25:26 +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:
parent
b9b53df3cc
commit
7b173c1770
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue