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

Changing mktemp calls and some two sed calls to make it work with BSD coreutils (and still GNU coreutils valid)

This commit is contained in:
Leif Walsh 2011-07-24 20:27:07 +02:00 committed by p4bl0
parent 31dffefdd3
commit 0062605559
4 changed files with 27 additions and 24 deletions

View file

@ -2,11 +2,12 @@
include_file() { include_file() {
f=`echo -n $2 | sed 's/\//\\\\\//g'` f=`echo -n $2 | sed 's/\//\\\\\//g'`
tmp=`mktemp` tmp=`mktemp fugitiveXXXXXX`
cat "$2" | gzip | base64 > "$tmp" cat "$2" | gzip | base64 > "$tmp"
cat "$1" | sed "/#INCLUDE:$f#/ { cat "$1" | sed "/#INCLUDE:$f#/ {
r $tmp r $tmp
d }" d
}"
rm "$tmp" rm "$tmp"
} }

View file

@ -16,9 +16,8 @@ if [ "$tpl_change" -gt 0 ]; then
modified_files=`git log $first..HEAD^ --name-status --pretty="format:" | \ modified_files=`git log $first..HEAD^ --name-status --pretty="format:" | \
grep -E '^A' | cut -f2 | sort | uniq` grep -E '^A' | cut -f2 | sort | uniq`
deleted_files= deleted_files=
tmpart=`mktemp` tmpart=`mktemp fugitiveXXXXXX`
tmpmod=`mktemp` tmpmod=`mktemp fugitiveXXXXXX`
tmpadd=`mktemp`
ls "$articles_dir"/* > "$tmpart" ls "$articles_dir"/* > "$tmpart"
echo "$modified_files" | tr " " "\n" > "$tmpmod" echo "$modified_files" | tr " " "\n" > "$tmpmod"
modified_files=`comm -12 --nocheck-order "$tmpmod" "$tmpart"` modified_files=`comm -12 --nocheck-order "$tmpmod" "$tmpart"`
@ -26,9 +25,9 @@ if [ "$tpl_change" -gt 0 ]; then
echo "[fugitive] Templates changed, regenerating everything..." echo "[fugitive] Templates changed, regenerating everything..."
fi fi
generated_files=`mktemp` generated_files=`mktemp fugitiveXXXXXX`
articles_sorted=`mktemp` articles_sorted=`mktemp fugitiveXXXXXX`
for f in "$articles_dir"/*; do for f in "$articles_dir"/*; do
ts=`git log --format="%at" -- "$f" | tail -1` ts=`git log --format="%at" -- "$f" | tail -1`
if [ "$ts" != "" ]; then if [ "$ts" != "" ]; then
@ -40,7 +39,7 @@ if [ "`head -1 $articles_sorted`" = "" ]; then
echo "[fugitive] WARNING: there's no article, errors may occur." >&2 echo "[fugitive] WARNING: there's no article, errors may occur." >&2
fi fi
articles_sorted_with_delete=`mktemp` articles_sorted_with_delete=`mktemp fugitiveXXXXXX`
for f in "$articles_dir"/* $deleted_files; do for f in "$articles_dir"/* $deleted_files; do
ts=`git log --format="%at" -- "$f" | tail -1` ts=`git log --format="%at" -- "$f" | tail -1`
if [ "$ts" != "" ]; then if [ "$ts" != "" ]; then
@ -48,7 +47,7 @@ for f in "$articles_dir"/* $deleted_files; do
fi fi
done | sort -k1,1nr | cut -d' ' -f2 > "$articles_sorted_with_delete" done | sort -k1,1nr | cut -d' ' -f2 > "$articles_sorted_with_delete"
commits=`mktemp` commits=`mktemp fugitiveXXXXXX`
git log --oneline | cut -d' ' -f1 > "$commits" git log --oneline | cut -d' ' -f1 > "$commits"
get_article_info() { get_article_info() {
@ -84,7 +83,7 @@ get_article_title() {
fi fi
} }
get_article_content() { get_article_content() {
tmp=`mktemp` tmp=`mktemp fugitiveXXXXXX`
tail -n+2 "$articles_dir/$1" > "$tmp" tail -n+2 "$articles_dir/$1" > "$tmp"
echo "$tmp" echo "$tmp"
} }
@ -93,10 +92,12 @@ get_commit_info() {
git show -s --format="$1" "$2" git show -s --format="$1" "$2"
} }
get_commit_body() { get_commit_body() {
tmp=`mktemp` tmp=`mktemp fugitiveXXXXXX`
git show -s --format="%b" "$1" > "$tmp" git show -s --format="%b" "$1" > "$tmp"
if [ "`cat \"$tmp\" | sed \"/^$/d\" | wc -l`" != "0" ]; then if [ "`cat \"$tmp\" | sed \"/^$/d\" | wc -l`" != "0" ]; then
echo "$tmp" echo "$tmp"
else
rm "$tmp"
fi fi
} }
@ -138,8 +139,8 @@ replace_file() {
} }
replace_includes() { replace_includes() {
buf=`mktemp` buf=`mktemp fugitiveXXXXXX`
buf2=`mktemp` buf2=`mktemp fugitiveXXXXXX`
cat > "$buf" cat > "$buf"
includes=`cat "$buf" | \ includes=`cat "$buf" | \
sed "s/<?fugitive[[:space:]]\+include:.\+[[:space:]]*?>/\n\0\n/g" | \ sed "s/<?fugitive[[:space:]]\+include:.\+[[:space:]]*?>/\n\0\n/g" | \
@ -151,7 +152,8 @@ replace_includes() {
cat "$buf" | \ cat "$buf" | \
sed "/<?fugitive[[:space:]]\+include:$esc[[:space:]]*?>/ { sed "/<?fugitive[[:space:]]\+include:$esc[[:space:]]*?>/ {
r $inc r $inc
d }" > "$buf2" d
}" > "$buf2"
tmpbuf="$buf" tmpbuf="$buf"
buf="$buf2" buf="$buf2"
buf2="$tmpbuf" buf2="$tmpbuf"
@ -260,9 +262,9 @@ replace_empty_article_info() {
} }
replace_foreach () { replace_foreach () {
foreach_body=`mktemp` foreach_body=`mktemp fugitiveXXXXXX`
tmpfile=`mktemp` tmpfile=`mktemp fugitiveXXXXXX`
temp=`mktemp` temp=`mktemp fugitiveXXXXXX`
fe="foreach:$1" fe="foreach:$1"
cat > "$temp" cat > "$temp"
cat "$temp" | \ cat "$temp" | \
@ -379,9 +381,9 @@ if [ $modification -gt 0 ]; then
sed "/^[[:space:]]*$/d" > "$public_dir/archives.html" sed "/^[[:space:]]*$/d" > "$public_dir/archives.html"
echo "done." echo "done."
echo -n "[fugitive] Generating $public_dir/feed.xml... " echo -n "[fugitive] Generating $public_dir/feed.xml... "
last_5_articles=`mktemp` last_5_articles=`mktemp fugitiveXXXXXX`
head -5 "$articles_sorted" > "$last_5_articles" head -5 "$articles_sorted" > "$last_5_articles"
last_5_commits=`mktemp` last_5_commits=`mktemp fugitiveXXXXXX`
head -5 "$commits" > "$last_5_commits" head -5 "$commits" > "$last_5_commits"
cat "$templates_dir/feed.xml" | \ cat "$templates_dir/feed.xml" | \
replace_includes | \ replace_includes | \

View file

@ -23,10 +23,10 @@ modified_files=`git log $range --name-status --pretty="format:" | \
deleted_files=`git log $range --name-status --pretty="format:" | \ deleted_files=`git log $range --name-status --pretty="format:" | \
grep -E '^D' | cut -f2 | sort | uniq` grep -E '^D' | cut -f2 | sort | uniq`
tmpart=`mktemp` tmpart=`mktemp fugitiveXXXXXX`
tmpadd=`mktemp` tmpadd=`mktemp fugitiveXXXXXX`
tmpmod=`mktemp` tmpmod=`mktemp fugitiveXXXXXX`
tmpdel=`mktemp` tmpdel=`mktemp fugitiveXXXXXX`
ls "$articles_dir"/* > "$tmpart" ls "$articles_dir"/* > "$tmpart"
echo "$added_files" | tr " " "\n" > "$tmpadd" echo "$added_files" | tr " " "\n" > "$tmpadd"
echo "$modified_files" | tr " " "\n" > "$tmpmod" echo "$modified_files" | tr " " "\n" > "$tmpmod"

View file

@ -2,7 +2,7 @@
articles_dir=`git config --get fugitive.articles-dir` articles_dir=`git config --get fugitive.articles-dir`
article_exists=`mktemp` article_exists=`mktemp fugitiveXXXXXX`
for f in "$articles_dir"/*; do for f in "$articles_dir"/*; do
ts=`git log --format="%at" -- "$f" | tail -1` ts=`git log --format="%at" -- "$f" | tail -1`
if [ "$ts" != "" ]; then if [ "$ts" != "" ]; then