From 572d5992affadb49aaf4daa45cc5a1cdcb3c2ce8 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Fri, 10 May 2013 16:17:10 +0100 Subject: [PATCH] Tell curl to follow redirects for commit-msg hook An HTTP server may reasonably want to redirect e.g. http to https, so use -L to instruct curl to follow such a redirect. Change-Id: Ie8d9caee68330335fc1e915c5e87d9191f29ea65 --- Documentation/cmd-cherry-pick.txt | 2 +- Documentation/cmd-hook-commit-msg.txt | 4 ++-- Documentation/cmd-index.txt | 4 ++-- Documentation/user-changeid.txt | 2 +- .../google/gerrit/server/git/validators/CommitValidators.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/cmd-cherry-pick.txt b/Documentation/cmd-cherry-pick.txt index d051a9a3aa..15a8524b82 100644 --- a/Documentation/cmd-cherry-pick.txt +++ b/Documentation/cmd-cherry-pick.txt @@ -39,7 +39,7 @@ copy it to your local system: ==== $ scp -p -P 29418 john.doe@review.example.com:bin/gerrit-cherry-pick ~/bin/ - $ curl -o ~/bin/gerrit-cherry-pick http://review.example.com/tools/bin/gerrit-cherry-pick + $ curl -Lo ~/bin/gerrit-cherry-pick http://review.example.com/tools/bin/gerrit-cherry-pick ==== GERRIT diff --git a/Documentation/cmd-hook-commit-msg.txt b/Documentation/cmd-hook-commit-msg.txt index bd602c11cf..d2f9648301 100644 --- a/Documentation/cmd-hook-commit-msg.txt +++ b/Documentation/cmd-hook-commit-msg.txt @@ -61,7 +61,7 @@ You can use either of the below commands: ==== $ scp -p -P 29418 @:hooks/commit-msg /.git/hooks/ - $ curl -o /.git/hooks/commit-msg /tools/hooks/commit-msg + $ curl -Lo /.git/hooks/commit-msg /tools/hooks/commit-msg ==== A specific example of this might look something like this: @@ -70,7 +70,7 @@ A specific example of this might look something like this: ==== $ scp -p -P 29418 john.doe@review.example.com:hooks/commit-msg ~/duhproject/.git/hooks/ - $ curl -o ~/duhproject/.git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg + $ curl -Lo ~/duhproject/.git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg ==== Make sure the hook file is executable: diff --git a/Documentation/cmd-index.txt b/Documentation/cmd-index.txt index 5637e80cd5..a54803b011 100644 --- a/Documentation/cmd-index.txt +++ b/Documentation/cmd-index.txt @@ -12,8 +12,8 @@ To download a client command or hook, use scp or an http client: $ scp -p -P 29418 john.doe@review.example.com:bin/gerrit-cherry-pick ~/bin/ $ scp -p -P 29418 john.doe@review.example.com:hooks/commit-msg .git/hooks/ - $ curl -o ~/bin/gerrit-cherry-pick http://review.example.com/tools/bin/gerrit-cherry-pick - $ curl -o .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg + $ curl -Lo ~/bin/gerrit-cherry-pick http://review.example.com/tools/bin/gerrit-cherry-pick + $ curl -Lo .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg For more details on how to determine the correct SSH port number, see link:user-upload.html#test_ssh[Testing Your SSH Connection]. diff --git a/Documentation/user-changeid.txt b/Documentation/user-changeid.txt index a4224bd453..c13faa6c70 100644 --- a/Documentation/user-changeid.txt +++ b/Documentation/user-changeid.txt @@ -53,7 +53,7 @@ of the local Git repository: $ scp -p -P 29418 john.doe@review.example.com:hooks/commit-msg .git/hooks/ - $ curl -o .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg + $ curl -Lo .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg Then ensure that the execute bit is set on the hook script: diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java index 8abe501cde..8ff09149e5 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java @@ -510,7 +510,7 @@ public class CommitValidators { if (hostKeys.isEmpty()) { String p = ".git/hooks/commit-msg"; return String.format( - " curl -o %s %s/tools/hooks/commit-msg ; chmod +x %s", p, + " curl -Lo %s %s/tools/hooks/commit-msg ; chmod +x %s", p, getGerritUrl(canonicalWebUrl), p); }