Skip to content

Commit

Permalink
Don't write directly to a make target ($@).
Browse files Browse the repository at this point in the history
Otherwise, if make is suspended, or killed with prejudice, or if the
system crashes, you could be left with an up-to-date, yet corrupt,
generated file.

I left off the `clean' addition, because I believe "make clean" should
not remove wildcard patterns like "*+", on the off-chance that someone
uses names like that for files they care about.  Besides, in practice,
those temporary files are left behind so rarely that they're not a bother,
and they're removed again as part of the next build.

[jc: sign-off?]

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jim Meyering authored and Junio C Hamano committed May 26, 2006
1 parent 4d599e6 commit fc36f6a
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -496,37 +496,43 @@ $(BUILT_INS): git$X
rm -f $@ && ln git$X $@

common-cmds.h: Documentation/git-*.txt
./generate-cmdlist.sh > $@
./generate-cmdlist.sh > $@+
mv $@+ $@

$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
rm -f $@
rm -f $@ $@+
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
-e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
$@.sh >$@
chmod +x $@
$@.sh >$@+
chmod +x $@+
mv $@+ $@

$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
rm -f $@
rm -f $@ $@+
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
$@.perl >$@
chmod +x $@
$@.perl >$@+
chmod +x $@+
mv $@+ $@

$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
rm -f $@
rm -f $@ $@+
sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
-e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
$@.py >$@
chmod +x $@
$@.py >$@+
chmod +x $@+
mv $@+ $@

git-cherry-pick: git-revert
cp $< $@
cp $< $@+
mv $@+ $@

git-status: git-commit
cp $< $@
cp $< $@+
mv $@+ $@

# These can record GIT_VERSION
git$X git.spec \
Expand Down Expand Up @@ -653,7 +659,8 @@ install-doc:
### Maintainer's dist rules

git.spec: git.spec.in
sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
mv $@+ $@

GIT_TARNAME=git-$(GIT_VERSION)
dist: git.spec git-tar-tree
Expand Down Expand Up @@ -724,4 +731,3 @@ check-docs::
*) echo "no link: $$v";; \
esac ; \
done | sort

0 comments on commit fc36f6a

Please sign in to comment.