git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "W. Trevor King" <wking@tremily.us>
Cc: Git <git@vger.kernel.org>
Subject: Re: [PATCH v2 02/15] user-manual: Update for receive.denyCurrentBranch=refuse
Date: Sun, 10 Feb 2013 13:24:47 -0800	[thread overview]
Message-ID: <7vd2w7uajk.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <ba62167be6df7a6ba666373913bfd235bcc29c9d.1360508415.git.wking@tremily.us> (W. Trevor King's message of "Sun, 10 Feb 2013 10:10:28 -0500")

"W. Trevor King" <wking@tremily.us> writes:

> From: "W. Trevor King" <wking@tremily.us>
>
> acd2a45 (Refuse updating the current branch in a non-bare repository
> via push, 2009-02-11) changed the default to refuse such a push, but
> it forgot to update the docs.
>
> 7d182f5 (Documentation: receive.denyCurrentBranch defaults to
> 'refuse', 2010-03-17) updated Documentation/config.txt, but forgot to
> update the user manual.
>
> Signed-off-by: W. Trevor King <wking@tremily.us>
> ---
>  Documentation/user-manual.txt | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
> index 222545b..8524c08 100644
> --- a/Documentation/user-manual.txt
> +++ b/Documentation/user-manual.txt
> @@ -1988,8 +1988,10 @@ handling this case.
>  Note that the target of a "push" is normally a
>  <<def_bare_repository,bare>> repository.  You can also push to a
>  repository that has a checked-out working tree, but the working tree
> -will not be updated by the push.  This may lead to unexpected results if
> -the branch you push to is the currently checked-out branch!
> +will not be updated by the push.  To protect against this, pushes to
> +the currently checked-out branch of a repository are denied by
> +default.  See the description of the receive.denyCurrentBranch option
> +in linkgit:git-config[1] for details.

Nobody else felt the same logic gap between "will not be updated"
and "to protect against this" I sensed while reading this?

I would not be surprised if some readers felt as if "then why not
update it instead of rejecting?" were a valid question, without a
bit more explanation.

	You can also push to a repository that has a working tree,
	but a push to the currently checked out branch is denied for
	two reasons:

        (1) if the push were allowed to update the working tree to
            match the pushed commit, it will overwrite and lose the
            work in progress in the working tree;

	(2) the push does _not_ update the working tree for the
	    above reason, but then if the push were allowed to
	    update the tip of the branch, the next commit made based
	    on the work done in the working tree will be based on
	    the state of the tree _before_ the push but will be
	    recorded as a descendant of the pushed commit, reverting
	    changes to the contents made by the pushed commit.
	
	If you want to handle the above two risks yourself (e.g. you
	can promise that you will never make changes to the files in
	the working tree or make commit from the working tree, and
	install a post-push hook that does "git reset --hard" to
	match the working tree state to the commit that was pushed),
	you can override this by setting receive.denyCurrentBranch.

It almost makes me wonder if it also makes sense to supersede the
denyCurrentBranch setting with a new receive.currentBranch variable
(setting it to "deny" is equivalent to setting denyCurrentBranch to
true), and make "receive.currentBranch = reset" to allow a push and
always run "git reset --hard" afterwards.

If we were to do so, I would strongly be against adding "checkout"
mode that does "git reset --keep" instead of "--hard". Those who can
accept the unconditional ovewriting with "reset --hard" are the only
ones that are safe if "push" updated the tip of the branch and the
working tree.  Updating the working tree with a "reset --keep" may
appear safe because it will catch the case where a file that needs
updating by "push" is modified, but that is an incorrect assumption.
It does not mean nobody has the contents in the editor buffer with
changes yet to be written out.  An automated update to the working
tree condition has to be allowed only to a repository with nobody
sitting at the keyboard editing files in there.

  reply	other threads:[~2013-02-10 21:25 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 16:43 [PATCH] user-manual: Rewrite git-gc section for automatic packing W. Trevor King
2013-02-08 17:36 ` Junio C Hamano
2013-02-08 18:35   ` W. Trevor King
2013-02-08 23:04     ` Junio C Hamano
2013-02-08 23:04     ` Junio C Hamano
2013-02-10 15:10       ` [PATCH v2 00/15] User manual updates W. Trevor King
2013-02-10 15:10         ` [PATCH v2 01/15] user-manual: Rewrite git-gc section for automatic packing W. Trevor King
2013-02-10 15:10         ` [PATCH v2 02/15] user-manual: Update for receive.denyCurrentBranch=refuse W. Trevor King
2013-02-10 21:24           ` Junio C Hamano [this message]
2013-02-10 21:46             ` W. Trevor King
2013-02-10 22:36               ` Junio C Hamano
2013-02-14 18:57                 ` Junio C Hamano
2013-02-17 17:06                   ` W. Trevor King
2013-02-18  0:15                     ` [PATCH v3 0/9] User manual updates W. Trevor King
2013-02-18  0:15                       ` [PATCH v3 1/9] user-manual: Use 'remote add' to setup push URLs W. Trevor King
2013-02-18  1:58                         ` Junio C Hamano
2013-02-18  2:15                           ` Jonathan Nieder
2013-02-18  0:15                       ` [PATCH v3 2/9] user-manual: Reorganize the reroll sections, adding 'git rebase -i' W. Trevor King
2013-02-18  2:23                         ` Junio C Hamano
2013-02-18  2:39                           ` W. Trevor King
2013-02-18  3:48                             ` Junio C Hamano
2013-02-18  0:15                       ` [PATCH v3 3/9] user-manual: Give 'git push -f' as an alternative to +master W. Trevor King
2013-02-18  2:24                         ` Junio C Hamano
2013-02-18  0:15                       ` [PATCH v3 4/9] user-manual: Mention 'git remote add' for remote branch config W. Trevor King
2013-02-18  2:26                         ` Junio C Hamano
2013-02-18  2:41                           ` W. Trevor King
2013-02-18  0:15                       ` [PATCH v3 5/9] user-manual: Standardize backtick quoting W. Trevor King
2013-02-25 22:53                         ` [PATCH v5] " W. Trevor King
2013-02-18  0:15                       ` [PATCH v3 6/9] user-manual: Use 'git config --global user.*' for setup W. Trevor King
2013-02-18  2:47                         ` Junio C Hamano
2013-02-18 12:12                           ` W. Trevor King
2013-02-18  0:15                       ` [PATCH v3 7/9] user-manual: Use request-pull to generate "please pull" text W. Trevor King
2013-02-18  2:50                         ` Junio C Hamano
2013-02-18  0:16                       ` [PATCH v3 8/9] user-manual: Flesh out uncommitted changes and submodule updates W. Trevor King
2013-02-18  2:53                         ` Junio C Hamano
2013-02-19  9:35                           ` W. Trevor King
2013-02-18  0:16                       ` [PATCH v3 9/9] user-manual: Use -o latest.tar.gz to create a gzipped tarball W. Trevor King
2013-02-18  2:58                         ` Junio C Hamano
2013-02-18 12:16                           ` W. Trevor King
2013-02-18  8:56                       ` [PATCH v3 0/9] User manual updates Junio C Hamano
2013-02-18 12:27                         ` W. Trevor King
2013-02-18 13:00                   ` [PATCH v2 02/15] user-manual: Update for receive.denyCurrentBranch=refuse Drew Northup
2013-02-18 21:26                     ` Junio C Hamano
2013-02-10 15:10         ` [PATCH v2 03/15] user-manual: Use 'remote add' to setup push URLs W. Trevor King
2013-02-10 21:33           ` Junio C Hamano
2013-02-10 21:54             ` W. Trevor King
2013-02-10 22:08               ` Jonathan Nieder
2013-02-10 22:19                 ` W. Trevor King
2013-02-10 22:45               ` Junio C Hamano
2013-02-10 22:57                 ` W. Trevor King
2013-02-10 15:10         ` [PATCH v2 04/15] user-manual: Use git branch --merged W. Trevor King
2013-02-10 21:37           ` Junio C Hamano
2013-02-10 21:56             ` W. Trevor King
2013-02-10 15:10         ` [PATCH v2 05/15] user-manual: Add a few references to 'git rebase -i' W. Trevor King
2013-02-10 21:53           ` Junio C Hamano
2013-02-10 22:00             ` W. Trevor King
2013-02-10 15:10         ` [PATCH v2 06/15] user-manual: Give 'git push -f' as an alternative to +master W. Trevor King
2013-02-10 22:00           ` Junio C Hamano
2013-02-10 22:04             ` W. Trevor King
2013-02-10 23:19             ` Junio C Hamano
2013-02-10 15:10         ` [PATCH v2 07/15] user-manual: Mention 'git remote add' for remote branch config W. Trevor King
2013-02-10 22:08           ` Junio C Hamano
2013-02-10 22:09           ` Junio C Hamano
2013-02-10 22:22             ` W. Trevor King
2013-02-10 15:10         ` [PATCH v2 08/15] user-manual: Standardize backtick quoting W. Trevor King
2013-02-10 15:22           ` W. Trevor King
2013-02-10 15:10         ` [PATCH v2 09/15] user-manual: Use 'git config --global user.*' for setup W. Trevor King
2013-02-10 22:12           ` Junio C Hamano
2013-02-10 22:25             ` W. Trevor King
2013-02-10 22:48               ` Junio C Hamano
2013-02-10 22:52                 ` W. Trevor King
2013-02-10 15:10         ` [PATCH v2 10/15] user-manual: Fix 'both: so' -> 'both; so' typo W. Trevor King
2013-02-10 15:10         ` [PATCH v2 11/15] user-manual: Fix 'http' -> 'HTTP' typos W. Trevor King
2013-02-10 15:10         ` [PATCH v2 12/15] user-manual: Use request-pull to generate "please pull" text W. Trevor King
2013-02-10 22:23           ` Junio C Hamano
2013-02-10 22:29             ` W. Trevor King
2013-02-10 15:10         ` [PATCH v2 13/15] user-manual: Fix 'you - Git' -> 'you--Git' typo W. Trevor King
2013-02-10 15:10         ` [PATCH v2 14/15] user-manual: Flesh out uncommitted changes and submodule updates W. Trevor King
2013-02-10 15:10         ` [PATCH v2 15/15] user-manual: Use --format=tar.gz to create a gzipped tarball W. Trevor King
2013-02-10 22:27           ` Junio C Hamano
2013-02-10 22:32             ` W. Trevor King
2013-02-10 22:52               ` Junio C Hamano
2013-02-10 23:01                 ` W. Trevor King
2013-02-10 22:31         ` [PATCH v2 00/15] User manual updates Junio C Hamano
2013-02-10 22:36           ` W. Trevor King
2013-02-19  9:34             ` [PATCH v3 0/9] " W. Trevor King
2013-02-19 10:04               ` [PATCH v4 0/3] " W. Trevor King
2013-02-19 10:05                 ` [PATCH v4 1/3] user-manual: Reorganize the reroll sections, adding 'git rebase -i' W. Trevor King
2013-02-19 18:47                   ` Junio C Hamano
2013-02-19 18:51                     ` W. Trevor King
2013-02-19 20:56                       ` Junio C Hamano
2013-03-24 12:23                         ` [PATCH] user-manual: Fix the interactive rebase example commit range W. Trevor King
2013-03-24 20:00                           ` Eric Sunshine
2013-03-24 20:22                             ` W. Trevor King
2013-02-19 10:05                 ` [PATCH v4 2/3] user-manual: Use request-pull to generate "please pull" text W. Trevor King
2013-02-19 10:05                 ` [PATCH v4 3/3] user-manual: Flesh out uncommitted changes and submodule updates W. Trevor King
2013-02-09  1:13 ` [PATCH] user-manual: Rewrite git-gc section for automatic packing Javier Tia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vd2w7uajk.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=wking@tremily.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).