Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: build/git-hooks/pre-commit

Issue 192443006: git-hooks/pre-commit: Allow merging deps2submodules changes from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/bin/sh
2 2
3 submods=$(git diff-index --cached --ignore-submodules=dirty HEAD | grep -e '^:16 0000' -e '^:...... 160000' | xargs) 3 submodule_diff() {
4 if test -n "$2"; then
5 git diff-tree -r --ignore-submodules=dirty "$1" "$2" | grep -e '^:160000' -e '^:...... 160000' | xargs
6 else
7 git diff-index --cached --ignore-submodules=dirty "$1" | grep -e '^:160000' -e '^:...... 160000' | xargs
8 fi
9 }
10
11 if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then
12 merge_base=$(git merge-base HEAD MERGE_HEAD)
13 if test -z "$(submodule_diff $merge_base HEAD)"; then
14 # Most up-to-date submodules are in MERGE_HEAD.
15 head_ref=MERGE_HEAD
16 else
17 # Most up-to-date submodules are in HEAD.
18 head_ref=HEAD
19 fi
20 else
21 # No merge in progress. Submodules must match HEAD.
22 head_ref=HEAD
23 fi
24
25 submods=$(submodule_diff $head_ref)
4 if test "$submods"; then 26 if test "$submods"; then
5 echo "You are trying to commit changes to the following submodules:" 1>&2 27 echo "You are trying to commit changes to the following submodules:" 1>&2
6 echo 1>&2 28 echo 1>&2
7 echo $submods | cut -d ' ' -f 6 | sed 's/^/ /g' 1>&2 29 echo $submods | cut -d ' ' -f 6 | sed 's/^/ /g' 1>&2
8 cat <<EOF 1>&2 30 cat <<EOF 1>&2
9 31
10 Submodule commits are not allowed. Please run: 32 Submodule commits are not allowed. Please run:
11 33
12 git status --ignore-submodules=dirty 34 git status --ignore-submodules=dirty
13 35
14 and/or: 36 and/or:
15 37
16 git diff-index --cached --ignore-submodules=dirty HEAD 38 git diff-index --cached --ignore-submodules=dirty HEAD
17 39
18 ... to see what's in your index. 40 ... to see what's in your index.
19 41
20 If you're really and truly trying to roll the version of a submodule, you should 42 If you're really and truly trying to roll the version of a submodule, you should
21 commit the new version to DEPS, instead. 43 commit the new version to DEPS, instead.
22 EOF 44 EOF
23 exit 1 45 exit 1
24 fi 46 fi
25 47
26 if [ -n "$(git ls-files .gitmodules)" ] && 48 gitmodules_diff() {
27 [ -n "$(git diff-index --cached HEAD .gitmodules)" ]; then 49 git diff-index --cached "$1" .gitmodules
50 }
51
52 if test "$(git ls-files .gitmodules)" -a "$(gitmodules_diff $head_ref)"; then
Ami GONE FROM CHROMIUM 2014/04/04 18:07:13 This change undid the benefit of r257470 because t
spang 2014/04/04 18:14:02 My bad.
28 cat <<EOF 1>&2 53 cat <<EOF 1>&2
29 You are trying to commit a change to .gitmodules. That is not allowed. 54 You are trying to commit a change to .gitmodules. That is not allowed.
30 To make changes to submodule names/paths, edit DEPS. 55 To make changes to submodule names/paths, edit DEPS.
31 EOF 56 EOF
32 exit 1 57 exit 1
33 fi 58 fi
34 59
35 exit 0 60 exit 0
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698