From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B7A7C2B9F7 for ; Fri, 28 May 2021 17:44:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0ECCC61108 for ; Fri, 28 May 2021 17:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229565AbhE1RqT (ORCPT ); Fri, 28 May 2021 13:46:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbhE1RqS (ORCPT ); Fri, 28 May 2021 13:46:18 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 971EEC061574 for ; Fri, 28 May 2021 10:44:42 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id d21so4989345oic.11 for ; Fri, 28 May 2021 10:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sHz28V9SZ9HQfQkuWuZZ1uX7zYkpAWV2xxk63t7nGA8=; b=spJKBRm4phWnoh5Vyh+EbIKyjUjUfmiQThycM5lVywNOPIu8Ws7Jgmei8/JoCZsVkD bXQnHiYMCuI+OyA6hEYV5CpFlVSY/zLdQJ4Nyu6y3b8OBLh+m9w/Gl5ETsY6MytdJJwy JtHnc9uLmEUZLeMVIvnto87CPoqfPVgGtyJb7ZT3z8jdyIjvvJ/o9lVeNZ9JxcBR93kz BZzGd7e9rwasZekTig8jZF9VqMy2IdGwhGoIauy/8Qa4kRMiNDpJGyjIq9P3wXR6A9sk wU2ERRe7JwYyrbneHAuxwWXNwsOshf8uqkyVOxe4LKPEFwu1a4EhrnQQp8U6VvEMuneV yXfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sHz28V9SZ9HQfQkuWuZZ1uX7zYkpAWV2xxk63t7nGA8=; b=mMV5rQJr0/uJF5XGmF23d3URfaZcJ1Vruagv3J/Q++ueYpdFDVoH7vTL9cADDyxOW9 AKRQZjQpUgxpzBcEE0drHdMD2ns7Sav7aPQ5bk8nNhQT199Nv9PPR9ND+2c2PFMCm4kb J9KbvYuRHQjmSFl7v33KfkwW0pYBA2avxALbVD2ys01IEzPhkBgCtRDG3vjcnPYnPO+I 4qtDH4whsDFgSVRq/2pJ81Fs/iiBpFmz5mtpSkqpStwcNR0Np8qq1Mv4+7bZcYlcsoy0 pG/Rl9p0+DmWA4j1p0Ox9KhzQZ0iPuqwwvPYI7onNqXhm43KnJ3HLk6ByNV3XY9ouVUZ veAw== X-Gm-Message-State: AOAM530JJDKpBeAEEmkuF4GigHBQ+gmy/asEy7nF/tQg0x7Fh4blXmWh ovspK+IeeRCkiBu6JgfUUtYX3TpaPCj/sMBSMk8= X-Google-Smtp-Source: ABdhPJwj3YbTiWki/F9DPYpFbwS2MtUExC+aKGluAr/jIEDr/9JUQIpptiibTwC8P7pdaFDid4mIbSfk1aQslbDIDbs= X-Received: by 2002:a05:6808:13d5:: with SMTP id d21mr6865375oiw.31.1622223881980; Fri, 28 May 2021 10:44:41 -0700 (PDT) MIME-Version: 1.0 References: <3b9bc214-a30a-ba49-af96-7eeaf37b7bbd@gmail.com> <60b126e8cf42e_51908208d4@natae.notmuch> In-Reply-To: <60b126e8cf42e_51908208d4@natae.notmuch> From: Elijah Newren Date: Fri, 28 May 2021 10:44:30 -0700 Message-ID: Subject: Re: git push doesn't use local branch name as default To: Felipe Contreras Cc: Mathias Kunter , Git Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, May 28, 2021 at 10:22 AM Felipe Contreras wrote: > > Elijah Newren wrote: > > > If there is no upstream, then there also is no "remote I normally pull > > > from", and thus, according to the doc, `simple` should actually work > > > like `current` in this case. Am I wrong here? > > > > The relevant code is > > > > return (fetch_remote && fetch_remote != remote); > > > > so you only get the "current" behavior when fetch_remote is non-NULL. > > fetch_remote is practically never non-NULL. > > fetch_remote is remote_get(NULL), which is basically the equivalent of: > > remote_get(remote_for_branch(current_branch, ...)); > > Typically when an upstream branch is not configured, this is the same > as: > > remote_get("origin"); > > The only time fetch_remote is NULL is when the configured remote is > invalid. Ah, thanks for correcting and clarifying here. > > So you don't get the "current" behavior when pushing to "origin". > > Perhaps: > > --- a/Documentation/config/push.txt > +++ b/Documentation/config/push.txt > @@ -29,8 +29,8 @@ push.default:: > different from the local one. > + > When pushing to a remote that is different from the remote you normally > -pull from, work as `current`. This is the safest option and is suited > -for beginners. > +pull from (typically "origin"), work as `current`. This is the safest option > +and is suited for beginners. This is certainly an improvement. I wonder if it might still be considered ambiguous or hard to parse, though. If so, maybe something like: If you have a default remote configured for the current branch and are pushing to a remote other than that one (or if you have no default remote configured and are pushing to a remote other than 'origin'), then work as 'current'. It may also be helpful to move the "This is the safest option and is suited for beginners" out of its current paragraph and combine it with the "This mode has become the default" in the next paragraph.