Makefile: detect errors in running spatch
[gitweb.git] / Makefile
index 001126931d0b770cb94e73461880aabf31a76eba..c3001709c782710118edea3b50195bd629229145 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2152,14 +2152,18 @@ po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
 FIND_SOURCE_FILES = ( \
        git ls-files \
                '*.[hcS]' \
+               '*.sh' \
                ':!*[tp][0-9][0-9][0-9][0-9]*' \
+               ':!contrib' \
                2>/dev/null || \
        $(FIND) . \
                \( -name .git -type d -prune \) \
-               -o \( -name '[tp][0-9][0-9][0-9][0-9]' -type d -prune \) \
+               -o \( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \) \
+               -o \( -name contrib -type d -prune \) \
                -o \( -name build -type d -prune \) \
                -o \( -name 'trash*' -type d -prune \) \
                -o \( -name '*.[hcS]' -type f -print \) \
+               -o \( -name '*.sh' -type f -print \) \
        )
 
 $(ETAGS_TARGET): FORCE
@@ -2325,9 +2329,17 @@ check: common-cmds.h
 C_SOURCES = $(patsubst %.o,%.c,$(C_OBJ))
 %.cocci.patch: %.cocci $(C_SOURCES)
        @echo '    ' SPATCH $<; \
+       ret=0; \
        for f in $(C_SOURCES); do \
-               $(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS); \
-       done >$@ 2>$@.log; \
+               $(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS) || \
+                       { ret=$$?; break; }; \
+       done >$@+ 2>$@.log; \
+       if test $$ret != 0; \
+       then \
+               cat $@.log; \
+               exit 1; \
+       fi; \
+       mv $@+ $@; \
        if test -s $@; \
        then \
                echo '    ' SPATCH result: $@; \