{"thread":{"id":"48035","subject":"[PATCH] Documentation/githooks: Clarify the behavior of post-checkout hook","startedAt":"2018-03-13T19:59:33Z","lastAt":"2018-03-14T00:38:24Z","messageCount":2,"participants":["Magne Land","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"341579","messageId":"0102016220f23987-d4661c81-cf6e-4c96-8487-acce6bb365c8-000000@eu-west-1.amazonses.com","threadId":"48035","inReplyTo":null,"subject":"[PATCH] Documentation/githooks: Clarify the behavior of post-checkout hook","fromName":"Magne Land","fromEmail":"magne.land@gmail.com","sentAt":"2018-03-13T19:59:28Z","receivedAt":"2018-03-13T19:59:33Z","isPatch":true,"sender":{"key":"magne.land@gmail.com","avatar":null},"body":"From: Magne Land <magne.land@appfolio.com>\n\nThis can happen when using 'git rebase -i’:\ncould not detach HEAD\n\nBased on discovering this Stack Overflow discussion:\nhttps://stackoverflow.com/questions/25561485/git-rebase-i-with-squash-cannot-detach-head\n---\n Documentation/githooks.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/githooks.txt b/Documentation/githooks.txt\nindex f877f7b7cd19c..3a4e027d0d175 100644\n--- a/Documentation/githooks.txt\n+++ b/Documentation/githooks.txt\n@@ -166,7 +166,9 @@ worktree.  The hook is given three parameters: the ref of the previous HEAD,\n the ref of the new HEAD (which may or may not have changed), and a flag\n indicating whether the checkout was a branch checkout (changing branches,\n flag=1) or a file checkout (retrieving a file from the index, flag=0).\n-This hook cannot affect the outcome of 'git checkout'.\n+\n+If this hook exits with a non-zero status, 'git checkout' will exit with the\n+same status.\n \n It is also run after 'git clone', unless the --no-checkout (-n) option is\n used. The first parameter given to the hook is the null-ref, the second the\n\n--\nhttps://github.com/git/git/pull/470\n"},{"id":"341608","messageId":"20180314003816.GE147135@aiede.svl.corp.google.com","threadId":"48035","inReplyTo":"0102016220f23987-d4661c81-cf6e-4c96-8487-acce6bb365c8-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH] Documentation/githooks: Clarify the behavior of post-checkout hook","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-03-14T00:38:16Z","receivedAt":"2018-03-14T00:38:24Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nMagne Land wrote:\n\n> From: Magne Land <magne.land@appfolio.com>\n>\n> This can happen when using 'git rebase -i’:\n> could not detach HEAD\n>\n> Based on discovering this Stack Overflow discussion:\n> https://stackoverflow.com/questions/25561485/git-rebase-i-with-squash-cannot-detach-head\n> ---\n>  Documentation/githooks.txt | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n\nThanks for investigating and writing this.\n\nMay we forge your sign-off?  See Documentation/SubmittingPatches\nsection [[sign-off] 'Certify your work' for more about what this\nmeans.\n\nThe above leaves one question unanswered: is this the *right* behavior\nfor \"git checkout\" to have?  I.e. is it useful for \"git checkout\" to\nfail when the post-checkout hook fails, or would it be better for it\nto e.g. simply print a message and exit with status 0?\n\nNot a rhetorical question: I'm asking because I don't know the answer.\nWhat do you think?\n\nThanks,\nJonathan\n\n> --- a/Documentation/githooks.txt\n> +++ b/Documentation/githooks.txt\n> @@ -166,7 +166,9 @@ worktree.  The hook is given three parameters: the ref of the previous HEAD,\n>  the ref of the new HEAD (which may or may not have changed), and a flag\n>  indicating whether the checkout was a branch checkout (changing branches,\n>  flag=1) or a file checkout (retrieving a file from the index, flag=0).\n> -This hook cannot affect the outcome of 'git checkout'.\n> +\n> +If this hook exits with a non-zero status, 'git checkout' will exit with the\n> +same status.\n>  \n>  It is also run after 'git clone', unless the --no-checkout (-n) option is\n>  used. The first parameter given to the hook is the null-ref, the second the\n"}]}