From 7b173c1770bd96196c6ba912845b501749b1810b Mon Sep 17 00:00:00 2001 From: p4bl0 Date: Sun, 25 Jul 2010 13:52:08 +0200 Subject: preventing to go through foreach loops if not actually in use (there can be a lot of commits) --- post-commit.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'post-commit.sh') diff --git a/post-commit.sh b/post-commit.sh index 1f13f0e..6929db4 100644 --- a/post-commit.sh +++ b/post-commit.sh @@ -237,13 +237,18 @@ replace_foreach () { temp=`tempfile -p "fugitive"` fe="foreach:$1" cat > "$temp" + cat "$temp" | \ + sed -n "//,//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//\n\0/" | \ sed "//,//d" | \ cat > "$tmpfile" - cat "$temp" | \ - sed -n "//,//p" | \ - tail -n +2 | head -n -1 > "$foreach_body" for i in `cat "$2"`; do cat "$foreach_body" | replace_$1_info "$i" done > "$temp" -- cgit v1.2.3