diff options
| author | Paul Eggert | 2017-04-29 11:28:52 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-04-29 11:42:13 -0700 |
| commit | e20ad449deefa7470386bf99e05fd8c67227f678 (patch) | |
| tree | e7ba1ccf30798e4c3d5542b80a8dcee43520d703 | |
| parent | bfc0f610bac3f97930941e9a66cbcd11cd382167 (diff) | |
| download | emacs-e20ad449deefa7470386bf99e05fd8c67227f678.tar.gz emacs-e20ad449deefa7470386bf99e05fd8c67227f678.zip | |
Allow bypassing of some checks when merging
* build-aux/git-hooks/pre-commit: Don't check merged-in changes.
| -rwxr-xr-x | build-aux/git-hooks/pre-commit | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/build-aux/git-hooks/pre-commit b/build-aux/git-hooks/pre-commit index 6483bfc6b3e..548bf933f0c 100755 --- a/build-aux/git-hooks/pre-commit +++ b/build-aux/git-hooks/pre-commit | |||
| @@ -25,16 +25,32 @@ exec >&2 | |||
| 25 | 25 | ||
| 26 | . git-sh-setup | 26 | . git-sh-setup |
| 27 | 27 | ||
| 28 | # When doing a two-way merge, ignore problems that came from the other | ||
| 29 | # side of the merge. | ||
| 30 | head=HEAD | ||
| 31 | if test -e "$GIT_DIR"/MERGE_HEAD; then | ||
| 32 | merge_heads=`cat "$GIT_DIR"/MERGE_HEAD` || exit | ||
| 33 | for merge_head in $merge_heads; do | ||
| 34 | case $head in | ||
| 35 | HEAD) head=$merge_head;; | ||
| 36 | # For multi-head merges, there's no easy way to ignore merged-in | ||
| 37 | # changes. But if you're doing multi-head merges, presumably | ||
| 38 | # you know how to handle any ensuing problems. | ||
| 39 | *) head=HEAD; break;; | ||
| 40 | esac | ||
| 41 | done | ||
| 42 | fi | ||
| 43 | |||
| 28 | git_diff='git diff --cached --name-only --diff-filter=A' | 44 | git_diff='git diff --cached --name-only --diff-filter=A' |
| 29 | ok_chars='\0+[=-=]./0-9A-Z_a-z' | 45 | ok_chars='\0+[=-=]./0-9A-Z_a-z' |
| 30 | nbadchars=`$git_diff -z HEAD | tr -d "$ok_chars" | wc -c` | 46 | nbadchars=`$git_diff -z $head | tr -d "$ok_chars" | wc -c` |
| 31 | 47 | ||
| 32 | if test "$nbadchars" -ne 0; then | 48 | if test "$nbadchars" -ne 0; then |
| 33 | echo "File name does not consist of -+./_ or ASCII letters or digits." | 49 | echo "File name does not consist of -+./_ or ASCII letters or digits." |
| 34 | exit 1 | 50 | exit 1 |
| 35 | fi | 51 | fi |
| 36 | 52 | ||
| 37 | for new_name in `$git_diff HEAD`; do | 53 | for new_name in `$git_diff $head`; do |
| 38 | case $new_name in | 54 | case $new_name in |
| 39 | -* | */-*) | 55 | -* | */-*) |
| 40 | echo "$new_name: File name component begins with '-'." | 56 | echo "$new_name: File name component begins with '-'." |
| @@ -53,4 +69,4 @@ done | |||
| 53 | # tests so that trailing spaces are generated on the fly rather than | 69 | # tests so that trailing spaces are generated on the fly rather than |
| 54 | # being committed as source. | 70 | # being committed as source. |
| 55 | 71 | ||
| 56 | exec git diff-index --check --cached HEAD -- | 72 | exec git diff-index --check --cached $head -- |