|
|
Created:
6 years, 9 months ago by spang Modified:
6 years, 8 months ago CC:
chromium-reviews, Ami GONE FROM CHROMIUM Base URL:
https://chromium.googlesource.com/chromium/src.git@master Visibility:
Public. |
Descriptiongit-hooks/pre-commit: Allow merging deps2submodules changes from upstream
This also checks the 2nd parent during a merge, to allow commiting a
merge that contains newer versions of the submodules. In particular
merging chromium master into a local branch will now work.
TEST=git checkout -b test origin/master~200
git merge --no-ff --no-commit origin/master
git commit
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=259711
Patch Set 1 #Patch Set 2 : always diff vs parent with latest submodules #Patch Set 3 : rebase #
Total comments: 2
Messages
Total messages: 37 (0 generated)
I'd prefer to do this slightly differently; if a merge is in progress, I'd like the hook to verify that the index doesn't have any submodule or .gitmodules changes other than what is in MERGE_HEAD. I think you can do this: gitdir=$(git rev-parse --git-dir) if [ -e "${gitdir}/MERGE_HEAD" ]; then head_ref=MERGE_HEAD else head_ref=HEAD fi ... and then s/HEAD/\$head_ref/g in the rest of the script.
I'd prefer to do this slightly differently; if a merge is in progress, I'd like the hook to verify that the index doesn't have any submodule or .gitmodules changes other than what is in MERGE_HEAD. I think you can do this: gitdir=$(git rev-parse --git-dir) if [ -e "${gitdir}/MERGE_HEAD" ]; then head_ref=MERGE_HEAD else head_ref=HEAD fi ... and then s/HEAD/\$head_ref/g in the rest of the script.
On 2014/03/17 05:18:37, szager1 wrote: > I'd prefer to do this slightly differently; if a merge is in progress, I'd like > the hook to verify that the index doesn't have any submodule or .gitmodules > changes other than what is in MERGE_HEAD. I think you can do this: > > gitdir=$(git rev-parse --git-dir) > if [ -e "${gitdir}/MERGE_HEAD" ]; then > head_ref=MERGE_HEAD > else > head_ref=HEAD > fi > > ... and then s/HEAD/\$head_ref/g in the rest of the script. That breaks the symmetric merge with the two parents swapped. That is, you won't be able to do: git checkout -b master origin/master git merge topic-branch If we want more accuracy than I have in this CL, then it's not too bad to work out which parent contains a more recent copy of ToT, but I'm not sure it's really necessary.
On 2014/03/17 05:51:26, spang wrote: > On 2014/03/17 05:18:37, szager1 wrote: > > I'd prefer to do this slightly differently; if a merge is in progress, I'd > like > > the hook to verify that the index doesn't have any submodule or .gitmodules > > changes other than what is in MERGE_HEAD. I think you can do this: > > > > gitdir=$(git rev-parse --git-dir) > > if [ -e "${gitdir}/MERGE_HEAD" ]; then > > head_ref=MERGE_HEAD > > else > > head_ref=HEAD > > fi > > > > ... and then s/HEAD/\$head_ref/g in the rest of the script. > > That breaks the symmetric merge with the two parents swapped. That is, you won't > be able to do: > > git checkout -b master origin/master > git merge topic-branch True, but that is a very uncommon operation. I think it's worth enforcing this for the much more common case.
On 2014/03/17 05:51:26, spang wrote: > On 2014/03/17 05:18:37, szager1 wrote: > > I'd prefer to do this slightly differently; if a merge is in progress, I'd > like > > the hook to verify that the index doesn't have any submodule or .gitmodules > > changes other than what is in MERGE_HEAD. I think you can do this: > > > > gitdir=$(git rev-parse --git-dir) > > if [ -e "${gitdir}/MERGE_HEAD" ]; then > > head_ref=MERGE_HEAD > > else > > head_ref=HEAD > > fi > > > > ... and then s/HEAD/\$head_ref/g in the rest of the script. > > That breaks the symmetric merge with the two parents swapped. That is, you won't > be able to do: > > git checkout -b master origin/master > git merge topic-branch > > If we want more accuracy than I have in this CL, then it's not too bad to work > out which parent contains a more recent copy of ToT, but I'm not sure it's > really necessary. I guess if you really want to be pedantic, you could do this: if [[ -e "${git_dir}/MERGE_HEAD" && -n $(git branch -r --contains MERGE_HEAD origin/master) ]] ... but that, of course, assumes that your remote is named "origin", and you're working off branch "master".
On 2014/03/17 06:27:33, szager1 wrote: > On 2014/03/17 05:51:26, spang wrote: > > On 2014/03/17 05:18:37, szager1 wrote: > > > I'd prefer to do this slightly differently; if a merge is in progress, I'd > > like > > > the hook to verify that the index doesn't have any submodule or .gitmodules > > > changes other than what is in MERGE_HEAD. I think you can do this: > > > > > > gitdir=$(git rev-parse --git-dir) > > > if [ -e "${gitdir}/MERGE_HEAD" ]; then > > > head_ref=MERGE_HEAD > > > else > > > head_ref=HEAD > > > fi > > > > > > ... and then s/HEAD/\$head_ref/g in the rest of the script. > > > > That breaks the symmetric merge with the two parents swapped. That is, you > won't > > be able to do: > > > > git checkout -b master origin/master > > git merge topic-branch > > True, but that is a very uncommon operation. I think it's worth enforcing this > for the much more common case. I definitely do this type of merge sometimes. Also, swapping the parents was one of the workflows mentioned as a workaround to the current behavior.
On 2014/03/17 06:34:20, szager1 wrote: > On 2014/03/17 05:51:26, spang wrote: > > On 2014/03/17 05:18:37, szager1 wrote: > > > I'd prefer to do this slightly differently; if a merge is in progress, I'd > > like > > > the hook to verify that the index doesn't have any submodule or .gitmodules > > > changes other than what is in MERGE_HEAD. I think you can do this: > > > > > > gitdir=$(git rev-parse --git-dir) > > > if [ -e "${gitdir}/MERGE_HEAD" ]; then > > > head_ref=MERGE_HEAD > > > else > > > head_ref=HEAD > > > fi > > > > > > ... and then s/HEAD/\$head_ref/g in the rest of the script. > > > > That breaks the symmetric merge with the two parents swapped. That is, you > won't > > be able to do: > > > > git checkout -b master origin/master > > git merge topic-branch > > > > If we want more accuracy than I have in this CL, then it's not too bad to work > > out which parent contains a more recent copy of ToT, but I'm not sure it's > > really necessary. > > I guess if you really want to be pedantic, you could do this: > > if [[ -e "${git_dir}/MERGE_HEAD" && -n $(git branch -r --contains MERGE_HEAD > origin/master) ]] This should work without relying on the remote origin being up-to-date: merge_base=$(git merge-base HEAD MERGE_HEAD) if test "$(submodules_diff $merge_base HEAD)"; then head_ref=HEAD else head_ref=MERGE_HEAD fi > > ... but that, of course, assumes that your remote is named "origin", and you're > working off branch "master".
On 2014/03/17 17:12:35, spang wrote: > On 2014/03/17 06:34:20, szager1 wrote: > > On 2014/03/17 05:51:26, spang wrote: > > > On 2014/03/17 05:18:37, szager1 wrote: > > > > I'd prefer to do this slightly differently; if a merge is in progress, I'd > > > like > > > > the hook to verify that the index doesn't have any submodule or > .gitmodules > > > > changes other than what is in MERGE_HEAD. I think you can do this: > > > > > > > > gitdir=$(git rev-parse --git-dir) > > > > if [ -e "${gitdir}/MERGE_HEAD" ]; then > > > > head_ref=MERGE_HEAD > > > > else > > > > head_ref=HEAD > > > > fi > > > > > > > > ... and then s/HEAD/\$head_ref/g in the rest of the script. > > > > > > That breaks the symmetric merge with the two parents swapped. That is, you > > won't > > > be able to do: > > > > > > git checkout -b master origin/master > > > git merge topic-branch > > > > > > If we want more accuracy than I have in this CL, then it's not too bad to > work > > > out which parent contains a more recent copy of ToT, but I'm not sure it's > > > really necessary. > > > > I guess if you really want to be pedantic, you could do this: > > > > if [[ -e "${git_dir}/MERGE_HEAD" && -n $(git branch -r --contains MERGE_HEAD > > origin/master) ]] > > This should work without relying on the remote origin being up-to-date: > > merge_base=$(git merge-base HEAD MERGE_HEAD) > > if test "$(submodules_diff $merge_base HEAD)"; then > head_ref=HEAD > else > head_ref=MERGE_HEAD > fi I've updated the patch with this strategy & tested several cases: No merge: - No submodule changes (pass) - Submodule changes (fail) Merge: - HEAD is newer, correct merge (pass) - MERGE_HEAD is newer, correct merge (pass) - HEAD is newer, mismerged submodules (fail) - MERGE_HEAD is newer, mismerged submodules (fail) > > > > > ... but that, of course, assumes that your remote is named "origin", and > you're > > working off branch "master".
This doesn't address the case that has been by far the biggest source of errors: developer on a local branch uses 'git commit -a', which includes a submodule change because (1) the developer was testing a different version of a submodule, and (2) their submodule.<name>.ignore config setting was set incorrectly. As a practical matter, this hook only has value if it catches that case.
On 2014/03/17 18:12:02, szager1 wrote: > This doesn't address the case that has been by far the biggest source of errors: > developer on a local branch uses 'git commit -a', which includes a submodule > change because (1) the developer was testing a different version of a submodule, > and (2) their submodule.<name>.ignore config setting was set incorrectly. > > As a practical matter, this hook only has value if it catches that case. I think this conclusion is wrong. I did test that the hook catches accidental changes to submodules such as the above "git commit -a" scenario. If you can provide a concrete example, that would be helpful.
On 2014/03/17 18:27:26, spang wrote: > On 2014/03/17 18:12:02, szager1 wrote: > > This doesn't address the case that has been by far the biggest source of > errors: > > developer on a local branch uses 'git commit -a', which includes a submodule > > change because (1) the developer was testing a different version of a > submodule, > > and (2) their submodule.<name>.ignore config setting was set incorrectly. > > > > As a practical matter, this hook only has value if it catches that case. > > I think this conclusion is wrong. I did test that the hook catches accidental > changes to submodules such as the above "git commit -a" scenario. > > If you can provide a concrete example, that would be helpful. It's exactly the case you mentioned before: git checkout -b mybranch origin/master # Make changes, including an inadvertent submodule change git checkout origin/master git merge mybranch
On 2014/03/17 18:37:19, szager1 wrote: > On 2014/03/17 18:27:26, spang wrote: > > On 2014/03/17 18:12:02, szager1 wrote: > > > This doesn't address the case that has been by far the biggest source of > > errors: > > > developer on a local branch uses 'git commit -a', which includes a submodule > > > change because (1) the developer was testing a different version of a > > submodule, > > > and (2) their submodule.<name>.ignore config setting was set incorrectly. > > > > > > As a practical matter, this hook only has value if it catches that case. > > > > I think this conclusion is wrong. I did test that the hook catches accidental > > changes to submodules such as the above "git commit -a" scenario. > > > > If you can provide a concrete example, that would be helpful. > > It's exactly the case you mentioned before: > > git checkout -b mybranch origin/master > # Make changes, including an inadvertent submodule change > git checkout origin/master > git merge mybranch In the above scenario, we'll end up doing submodule_diff HEAD which will contain the accidental edits, and the nonempty diff will fail the hook. You must merge correctly for the hook to succeed.
On 2014/03/17 18:46:29, spang wrote: > On 2014/03/17 18:37:19, szager1 wrote: > > git checkout -b mybranch origin/master > > # Make changes, including an inadvertent submodule change > > git checkout origin/master > > git merge mybranch > > In the above scenario, we'll end up doing > > submodule_diff HEAD > > which will contain the accidental edits, and the nonempty diff will fail the > hook. > > You must merge correctly for the hook to succeed. I don't follow you. As I read it: # This is 'true', because there is a merge in progress 11 if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then # merge_base is something in the history of origin/master 12 merge_base=$(git merge-base HEAD MERGE_HEAD) # This is true if there are submodule commits between merge_base and origin/master 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 # ... # This evaluates to 'submodule_diff MERGE_HEAD' 25 submods=$(submodule_diff $head_ref)
On 2014/03/17 18:56:28, szager1 wrote: > On 2014/03/17 18:46:29, spang wrote: > > On 2014/03/17 18:37:19, szager1 wrote: > > > > git checkout -b mybranch origin/master > > > # Make changes, including an inadvertent submodule change > > > git checkout origin/master > > > git merge mybranch > > > > In the above scenario, we'll end up doing > > > > submodule_diff HEAD > > > > which will contain the accidental edits, and the nonempty diff will fail the > > hook. > > > > You must merge correctly for the hook to succeed. > > I don't follow you. As I read it: > > > # This is 'true', because there is a merge in progress > 11 if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then > > # merge_base is something in the history of origin/master > 12 merge_base=$(git merge-base HEAD MERGE_HEAD) > > # This is true if there are submodule commits between merge_base and > origin/master It is true if there are NO submodule commits between merge_base and HEAD. If there aren't any submodules changes in HEAD, then we diff vs MERGE_BASE. If there are submodule changes in HEAD, then we diff vs HEAD. Maybe I have written this confusingly by using "-z" here. I can reverse the if/else if that's clearer. > 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 > # ... > > # This evaluates to 'submodule_diff MERGE_HEAD' > 25 submods=$(submodule_diff $head_ref)
On 2014/03/17 19:03:51, spang wrote: > On 2014/03/17 18:56:28, szager1 wrote: > > On 2014/03/17 18:46:29, spang wrote: > > > On 2014/03/17 18:37:19, szager1 wrote: > > > > > > git checkout -b mybranch origin/master > > > > # Make changes, including an inadvertent submodule change > > > > git checkout origin/master > > > > git merge mybranch > > > > > > In the above scenario, we'll end up doing > > > > > > submodule_diff HEAD > > > > > > which will contain the accidental edits, and the nonempty diff will fail the > > > hook. > > > > > > You must merge correctly for the hook to succeed. > > > > I don't follow you. As I read it: > > > > > > # This is 'true', because there is a merge in progress > > 11 if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then > > > > # merge_base is something in the history of origin/master > > 12 merge_base=$(git merge-base HEAD MERGE_HEAD) > > > > # This is true if there are submodule commits between merge_base and > > origin/master > > It is true if there are NO submodule commits between merge_base and HEAD. > > If there aren't any submodules changes in HEAD, then we diff vs MERGE_BASE. > > If there are submodule changes in HEAD, then we diff vs HEAD. > > Maybe I have written this confusingly by using "-z" here. I can reverse the > if/else if that's clearer. Ah, right. OK, then what about this sequence: git checkout -b mybranch origin/master # Accidentally commit a submodule change git fetch origin # No submodule changes fetched git checkout origin/master git merge mybranch
On 2014/03/17 19:49:49, szager1 wrote: > On 2014/03/17 19:03:51, spang wrote: > > On 2014/03/17 18:56:28, szager1 wrote: > > > On 2014/03/17 18:46:29, spang wrote: > > > > On 2014/03/17 18:37:19, szager1 wrote: > > > > > > > > git checkout -b mybranch origin/master > > > > > # Make changes, including an inadvertent submodule change > > > > > git checkout origin/master > > > > > git merge mybranch > > > > > > > > In the above scenario, we'll end up doing > > > > > > > > submodule_diff HEAD > > > > > > > > which will contain the accidental edits, and the nonempty diff will fail > the > > > > hook. > > > > > > > > You must merge correctly for the hook to succeed. > > > > > > I don't follow you. As I read it: > > > > > > > > > # This is 'true', because there is a merge in progress > > > 11 if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then > > > > > > # merge_base is something in the history of origin/master > > > 12 merge_base=$(git merge-base HEAD MERGE_HEAD) > > > > > > # This is true if there are submodule commits between merge_base and > > > origin/master > > > > It is true if there are NO submodule commits between merge_base and HEAD. > > > > If there aren't any submodules changes in HEAD, then we diff vs MERGE_BASE. > > > > If there are submodule changes in HEAD, then we diff vs HEAD. > > > > Maybe I have written this confusingly by using "-z" here. I can reverse the > > if/else if that's clearer. > > Ah, right. OK, then what about this sequence: > > git checkout -b mybranch origin/master > # Accidentally commit a submodule change You can't commit it since this fails the no-merge case. > git fetch origin # No submodule changes fetched > git checkout origin/master > git merge mybranch
On 2014/03/17 21:10:15, spang wrote: > On 2014/03/17 19:49:49, szager1 wrote: > > On 2014/03/17 19:03:51, spang wrote: > > > On 2014/03/17 18:56:28, szager1 wrote: > > > > On 2014/03/17 18:46:29, spang wrote: > > > > > On 2014/03/17 18:37:19, szager1 wrote: > > > > > > > > > > git checkout -b mybranch origin/master > > > > > > # Make changes, including an inadvertent submodule change > > > > > > git checkout origin/master > > > > > > git merge mybranch > > > > > > > > > > In the above scenario, we'll end up doing > > > > > > > > > > submodule_diff HEAD > > > > > > > > > > which will contain the accidental edits, and the nonempty diff will fail > > the > > > > > hook. > > > > > > > > > > You must merge correctly for the hook to succeed. > > > > > > > > I don't follow you. As I read it: > > > > > > > > > > > > # This is 'true', because there is a merge in progress > > > > 11 if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then > > > > > > > > # merge_base is something in the history of origin/master > > > > 12 merge_base=$(git merge-base HEAD MERGE_HEAD) > > > > > > > > # This is true if there are submodule commits between merge_base and > > > > origin/master > > > > > > It is true if there are NO submodule commits between merge_base and HEAD. > > > > > > If there aren't any submodules changes in HEAD, then we diff vs MERGE_BASE. > > > > > > If there are submodule changes in HEAD, then we diff vs HEAD. > > > > > > Maybe I have written this confusingly by using "-z" here. I can reverse the > > > if/else if that's clearer. > > > > Ah, right. OK, then what about this sequence: > > > > git checkout -b mybranch origin/master > > # Accidentally commit a submodule change > > You can't commit it since this fails the no-merge case. > > > git fetch origin # No submodule changes fetched > > git checkout origin/master > > git merge mybranch ping
On 2014/03/21 18:34:07, spang wrote: > On 2014/03/17 21:10:15, spang wrote: > > On 2014/03/17 19:49:49, szager1 wrote: > > > On 2014/03/17 19:03:51, spang wrote: > > > > On 2014/03/17 18:56:28, szager1 wrote: > > > > > On 2014/03/17 18:46:29, spang wrote: > > > > > > On 2014/03/17 18:37:19, szager1 wrote: > > > > > > > > > > > > git checkout -b mybranch origin/master > > > > > > > # Make changes, including an inadvertent submodule change > > > > > > > git checkout origin/master > > > > > > > git merge mybranch > > > > > > > > > > > > In the above scenario, we'll end up doing > > > > > > > > > > > > submodule_diff HEAD > > > > > > > > > > > > which will contain the accidental edits, and the nonempty diff will > fail > > > the > > > > > > hook. > > > > > > > > > > > > You must merge correctly for the hook to succeed. > > > > > > > > > > I don't follow you. As I read it: > > > > > > > > > > > > > > > # This is 'true', because there is a merge in progress > > > > > 11 if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then > > > > > > > > > > # merge_base is something in the history of origin/master > > > > > 12 merge_base=$(git merge-base HEAD MERGE_HEAD) > > > > > > > > > > # This is true if there are submodule commits between merge_base and > > > > > origin/master > > > > > > > > It is true if there are NO submodule commits between merge_base and HEAD. > > > > > > > > If there aren't any submodules changes in HEAD, then we diff vs > MERGE_BASE. > > > > > > > > If there are submodule changes in HEAD, then we diff vs HEAD. > > > > > > > > Maybe I have written this confusingly by using "-z" here. I can reverse > the > > > > if/else if that's clearer. > > > > > > Ah, right. OK, then what about this sequence: > > > > > > git checkout -b mybranch origin/master > > > # Accidentally commit a submodule change > > > > You can't commit it since this fails the no-merge case. > > > > > git fetch origin # No submodule changes fetched > > > git checkout origin/master > > > git merge mybranch > > ping Thanks for pushing on this Michael! I agree we should be able to use a merge workflow (and certainly it shouldn't fail in this totally confusing way).
Sorry for the delay; I have been interrupt-driven lately. I still find the logic a bit squirrely, particularly where it relies on "correct" behavior when the previous commit happened. Having said that: the submodule flow is going to disappear soon enough, so there's probably no harm in landing this now. lgtm
The CQ bit was checked by spang@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/spang@chromium.org/192443006/20001
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for build/git-hooks/pre-commit: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file build/git-hooks/pre-commit Hunk #2 FAILED at 45. 1 out of 2 hunks FAILED -- saving rejects to file build/git-hooks/pre-commit.rej Patch: build/git-hooks/pre-commit Index: build/git-hooks/pre-commit diff --git a/build/git-hooks/pre-commit b/build/git-hooks/pre-commit index 3391a777e760afca4f6a1401863e04f87c095319..366b9ada930ab98cdcf29c9b4137a1c0e0ef006f 100755 --- a/build/git-hooks/pre-commit +++ b/build/git-hooks/pre-commit @@ -1,6 +1,28 @@ #!/bin/sh -submods=$(git diff-index --cached --ignore-submodules=dirty HEAD | grep -e '^:160000' -e '^:...... 160000' | xargs) +submodule_diff() { + if test -n "$2"; then + git diff-tree -r --ignore-submodules=dirty "$1" "$2" | grep -e '^:160000' -e '^:...... 160000' | xargs + else + git diff-index --cached --ignore-submodules=dirty "$1" | grep -e '^:160000' -e '^:...... 160000' | xargs + fi +} + +if git rev-parse --verify --quiet --no-revs MERGE_HEAD; then + merge_base=$(git merge-base HEAD MERGE_HEAD) + if test -z "$(submodule_diff $merge_base HEAD)"; then + # Most up-to-date submodules are in MERGE_HEAD. + head_ref=MERGE_HEAD + else + # Most up-to-date submodules are in HEAD. + head_ref=HEAD + fi +else + # No merge in progress. Submodules must match HEAD. + head_ref=HEAD +fi + +submods=$(submodule_diff $head_ref) if test "$submods"; then echo "You are trying to commit changes to the following submodules:" 1>&2 echo 1>&2 @@ -23,7 +45,11 @@ EOF exit 1 fi -if test "$(git diff-index --cached HEAD .gitmodules)"; then +gitmodules_diff() { + git diff-index --cached "$1" .gitmodules +} + +if test "$(gitmodules_diff $head_ref)"; then cat <<EOF 1>&2 You are trying to commit a change to .gitmodules. That is not allowed. To make changes to submodule names/paths, edit DEPS.
The CQ bit was checked by spang@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/spang@chromium.org/192443006/40001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: tryserver.chromium on linux_chromium_rel
The CQ bit was checked by spang@chromium.org
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/spang@chromium.org/192443006/40001
Message was sent while issue was closed.
Change committed as 259711
Message was sent while issue was closed.
post-commit drive-by https://codereview.chromium.org/192443006/diff/40001/build/git-hooks/pre-commit File build/git-hooks/pre-commit (right): https://codereview.chromium.org/192443006/diff/40001/build/git-hooks/pre-comm... build/git-hooks/pre-commit:52: if test "$(git ls-files .gitmodules)" -a "$(gitmodules_diff $head_ref)"; then This change undid the benefit of r257470 because test "$(/bin/false)" -a "$(echo foo >&2)" doesn't short-circuit before running the second command, whereas [ "$(/bin/false)" ] && [ "$(echo foo >&2)" ] does short-circuit. Was there any reason to make the change from [ to test other than aesthetics? (any objection to me flipping it back?)
Message was sent while issue was closed.
https://codereview.chromium.org/192443006/diff/40001/build/git-hooks/pre-commit File build/git-hooks/pre-commit (right): https://codereview.chromium.org/192443006/diff/40001/build/git-hooks/pre-comm... build/git-hooks/pre-commit:52: if test "$(git ls-files .gitmodules)" -a "$(gitmodules_diff $head_ref)"; then On 2014/04/04 18:07:13, Ami Fischman wrote: > This change undid the benefit of r257470 because > test "$(/bin/false)" -a "$(echo foo >&2)" > doesn't short-circuit before running the second command, whereas > [ "$(/bin/false)" ] && [ "$(echo foo >&2)" ] > does short-circuit. > My bad. > Was there any reason to make the change from [ to test other than aesthetics? > (any objection to me flipping it back?) There's no intentional change here, since it was always "test". Your CL changed it to [[, and then it changed to [.
The [[ -> [ change was intentional to work with dash or some other non-bash. Will send a CL to flip test back to [. Thanks. On Fri, Apr 4, 2014 at 11:14 AM, <spang@chromium.org> wrote: > > https://codereview.chromium.org/192443006/diff/40001/ > build/git-hooks/pre-commit > File build/git-hooks/pre-commit (right): > > https://codereview.chromium.org/192443006/diff/40001/ > build/git-hooks/pre-commit#newcode52 > build/git-hooks/pre-commit:52: if test "$(git ls-files .gitmodules)" -a > "$(gitmodules_diff $head_ref)"; then > On 2014/04/04 18:07:13, Ami Fischman wrote: > >> This change undid the benefit of r257470 because >> test "$(/bin/false)" -a "$(echo foo >&2)" >> doesn't short-circuit before running the second command, whereas >> [ "$(/bin/false)" ] && [ "$(echo foo >&2)" ] >> does short-circuit. >> > > > My bad. > > > Was there any reason to make the change from [ to test other than >> > aesthetics? > >> (any objection to me flipping it back?) >> > > There's no intentional change here, since it was always "test". > > Your CL changed it to [[, and then it changed to [. > > https://codereview.chromium.org/192443006/ > To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
I'm just saying, I'm not really sure why you changed it from test in the first place, so when I went to merge my change with yours I just left it as test. On Fri, Apr 4, 2014 at 2:19 PM, Ami Fischman <fischman@chromium.org> wrote: > The [[ -> [ change was intentional to work with dash or some other > non-bash. > Will send a CL to flip test back to [. > Thanks. > > > On Fri, Apr 4, 2014 at 11:14 AM, <spang@chromium.org> wrote: > >> >> https://codereview.chromium.org/192443006/diff/40001/ >> build/git-hooks/pre-commit >> File build/git-hooks/pre-commit (right): >> >> https://codereview.chromium.org/192443006/diff/40001/ >> build/git-hooks/pre-commit#newcode52 >> build/git-hooks/pre-commit:52: if test "$(git ls-files .gitmodules)" -a >> "$(gitmodules_diff $head_ref)"; then >> On 2014/04/04 18:07:13, Ami Fischman wrote: >> >>> This change undid the benefit of r257470 because >>> test "$(/bin/false)" -a "$(echo foo >&2)" >>> doesn't short-circuit before running the second command, whereas >>> [ "$(/bin/false)" ] && [ "$(echo foo >&2)" ] >>> does short-circuit. >>> >> >> >> My bad. >> >> >> Was there any reason to make the change from [ to test other than >>> >> aesthetics? >> >>> (any objection to me flipping it back?) >>> >> >> There's no intentional change here, since it was always "test". >> >> Your CL changed it to [[, and then it changed to [. >> >> https://codereview.chromium.org/192443006/ >> > > To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
FTR https://codereview.chromium.org/225583008/ On Fri, Apr 4, 2014 at 11:23 AM, Michael Spang <spang@chromium.org> wrote: > I'm just saying, I'm not really sure why you changed it from test in the > first place, so when I went to merge my change with yours I just left it as > test. > > On Fri, Apr 4, 2014 at 2:19 PM, Ami Fischman <fischman@chromium.org>wrote: > >> The [[ -> [ change was intentional to work with dash or some other >> non-bash. >> Will send a CL to flip test back to [. >> Thanks. >> >> >> On Fri, Apr 4, 2014 at 11:14 AM, <spang@chromium.org> wrote: >> >>> >>> https://codereview.chromium.org/192443006/diff/40001/ >>> build/git-hooks/pre-commit >>> File build/git-hooks/pre-commit (right): >>> >>> https://codereview.chromium.org/192443006/diff/40001/ >>> build/git-hooks/pre-commit#newcode52 >>> build/git-hooks/pre-commit:52: if test "$(git ls-files .gitmodules)" -a >>> "$(gitmodules_diff $head_ref)"; then >>> On 2014/04/04 18:07:13, Ami Fischman wrote: >>> >>>> This change undid the benefit of r257470 because >>>> test "$(/bin/false)" -a "$(echo foo >&2)" >>>> doesn't short-circuit before running the second command, whereas >>>> [ "$(/bin/false)" ] && [ "$(echo foo >&2)" ] >>>> does short-circuit. >>>> >>> >>> >>> My bad. >>> >>> >>> Was there any reason to make the change from [ to test other than >>>> >>> aesthetics? >>> >>>> (any objection to me flipping it back?) >>>> >>> >>> There's no intentional change here, since it was always "test". >>> >>> Your CL changed it to [[, and then it changed to [. >>> >>> https://codereview.chromium.org/192443006/ >>> >> >> > To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org. |