From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 28EB020248 for ; Mon, 18 Mar 2019 12:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727471AbfCRMGx (ORCPT ); Mon, 18 Mar 2019 08:06:53 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:52865 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbfCRMGx (ORCPT ); Mon, 18 Mar 2019 08:06:53 -0400 Received: by mail-it1-f195.google.com with SMTP id g17so20029482ita.2 for ; Mon, 18 Mar 2019 05:06:52 -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=sug6OcjVGDRspv2PMJctftSAYLPdTuIZ5OCNipAVlwc=; b=KmhMgdBCwIilTiAm0J0aHzyUMxbzFg1mg2Zf0bOV05bUoVE1Rvj9PoEw1IggQl9UAO nDZq1gzMN1uQKXm8MQBz4+7ljjqdw5soPW3/ad/8CDeDwO2GBCiKU9uekX0XkKnr7nbq DsGHi2h954AJBlDXhMI+mu2tOmOquzd/HOiGcoo5FQuBAN7MStKZNYLwl9VcMfqC3q36 po0QjHdBKZsvu8pg3Mcz1sCqbpst3i5YExF+Gwhk6Tg87/ononIfYHCpHuJz47YbTMAq ZdA3Fkk/ciF5ueF+xRblg3BiGL5bkuP+NUc0IjN+UZSQBNDvwVxMH8hFQMgg8fF4R/nu 8zIw== 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=sug6OcjVGDRspv2PMJctftSAYLPdTuIZ5OCNipAVlwc=; b=J+2En1HkZpkPBjy1GLd91ertespb7ws5gjLOmnEzyYcdzxq1+eAdzM6IeBFfCZCF3M FEmC8Yaq5XUJww7Lt/YQGTPK8x6ScnYHmeA1wzZXLPDgmgxl+tN68QLMOXHweYjzFb9w CRVU6h8SDSH8GQ0k2RU4TvYEHIr52vQLeiJgHPi5tflcTrdJmuZD04GWnbgZWL6akW9K XnoUeP4MBdrkCWlhmId3R3ffWBoKleiudrXyrhK0OXVjPILj7m+h1s/51wGfXVZsOpeb 4GPofLhrb8sHYbYkYd5kVGj0y5cW8d6D2JMVAU9SuhNt05AxJqpkbXvRNkQYuf8niHd2 SYHQ== X-Gm-Message-State: APjAAAVpvt+/7ILouAdKOihV8clKKAbOEyfaGoRAg8pZbFGVv7od2/Q0 HNlIrq1y24JkLHhhxJnTdEFZ87yIiSKg7EerIq4= X-Google-Smtp-Source: APXvYqxfko7nJaqpTKyc5ta6SaP6qXmgP+0jRhXSASd2IsnVLvY81dE8G5BA+FJym2xmXHzkUi+IJhDvzpZXGVLOJzc= X-Received: by 2002:a24:3b0a:: with SMTP id c10mr8973121ita.10.1552910811675; Mon, 18 Mar 2019 05:06:51 -0700 (PDT) MIME-Version: 1.0 References: <20190308095752.8574-1-pclouds@gmail.com> <20190308095752.8574-11-pclouds@gmail.com> <7d3742d6-73e4-2750-6ecb-9edf761d96dd@gmail.com> <20190314091753.GA9852@ash> In-Reply-To: From: Duy Nguyen Date: Mon, 18 Mar 2019 19:06:25 +0700 Message-ID: Subject: Re: [PATCH v3 10/21] checkout: split part of it to new command 'switch' To: Junio C Hamano Cc: Elijah Newren , Eric Sunshine , Phillip Wood , Git Mailing List , =?UTF-8?Q?SZEDER_G=C3=A1bor?= , =?UTF-8?Q?Martin_=C3=85gren?= Content-Type: text/plain; charset="UTF-8" Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Mar 18, 2019 at 9:03 AM Junio C Hamano wrote: > > Elijah Newren writes: > > > I don't see why even makes sense to use with --orphan; > > you should error if both are given, IMO. The point of --orphan is to > > create some entirely new history. So, I'd expect "git switch --orphan > > " to: > > * not create refs/heads/ > > * set HEAD to refs/heads/ > > * empty all tracked files from the working tree. > > * empty the index > > > > Alternatively, you could allow to be passed with > > --orphan, adjusting the above steps so that both the index and the > > working tree are switched to match , but ONLY if > > defaults to the empty tree when --orphan is passed. > > Do you mean that it's like is not really a start-point > but is an initial tree, i.e. > > switch --orphan --initial-tree= > > is a mere short-hand for > > switch --orhpan && > restore --from-tree= . > > I think that does make sense, but at the same time, I think a major > reason why people say "checkout does too many things depending on > the arguments and conext to be easily explained" is exactly due to > its many "if you give X, it is like writing this longer command > sequence" short hands, so... Yeah is optional and probably only useful for people who do a lot of --orphan. I did think if there's any other command that could be a better host for this orphan branch creation. No such luck. PS. There's one small difference between 'switch --orphan ' and your switch/restore combination: the latter refuses if you have any local changes because it has to remove all tracked files first, while the former only refuses when the local changes are outside . If path A will be tracked by , then whatever changes in there may stay. -- Duy