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 BE8AC20248 for ; Fri, 8 Mar 2019 10:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbfCHKRL (ORCPT ); Fri, 8 Mar 2019 05:17:11 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42500 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726348AbfCHKRL (ORCPT ); Fri, 8 Mar 2019 05:17:11 -0500 Received: by mail-pg1-f196.google.com with SMTP id b2so13790623pgl.9 for ; Fri, 08 Mar 2019 02:17:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kn8n5IG9NYC3/TaRM95ov/lXkrPLzuG0QVmFzYMbtTw=; b=OF8pJV+2Vg60g8k1Xdj/ILBR7EYWN3pmH4tlVUcxOzDyhs4cbIuLgFHoy912+Imouo mfupvhY3hqggluRH5Pu0Q1ZnsfVPUdwAuM3TiL1FsHFQ5a7e008liW2zNgDLnS4JESXP EBaa/b/M93bUTiFKFAQgClIRCJ3rgPPhg+tiPQXaN6hAgCvPBW2FNu6shqvNDUzYDoeR KhGN6h6jWWMUMj2svBP7WBqsKUGGDOw0SetqZ92V9+zBHrJQdyYPm8NyFX99d+QFhMjV MPdy/no1p8bjLUaFU0aZ+DMhwU5XE+AaxqS23qxjphB5gv6yJ6WxBxX96BSPWAIWG0r7 TN/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kn8n5IG9NYC3/TaRM95ov/lXkrPLzuG0QVmFzYMbtTw=; b=WBq5diQ7pGkRSXNfmzjA3oYk8TVke+AqK3VKfWymVL2Dw88J7I59fRz1M7Vi6zgGlw MOZhkSCeNBCkrZkAmkkxEn5kJlHn36XCrISaDEckV5UXpL9s+SZbdSYGu0Gsuqm9ESHz 0i33qcxpw4tEGl6prL0vBnvHGJ0fLBrN9lnES1ePNJ46d3sAlApO22DlaKCBs4r/I4EG GlGAb3dayrLIdDzjYJL5ZE2FOg5fFkOEV5fTf+eKADncbBIXJ3J5W5d6Qo7TjAzrJn8B dn5GkAZ0xmat8yOSQHCT/sDs9eYPWDqp+JooJ05W/H9WEfUZMpl4l6Qq0Yy0Cy+vGmi2 nXGQ== X-Gm-Message-State: APjAAAUVXZY+0NVlp2QsEDL4KrqDPoPv+kSRQSk+IJSEHyUI54I6OKz9 kNkcSSmgSHY36nQQDIuBzXraMrtU X-Google-Smtp-Source: APXvYqyCadaLE9PVvdDJ4ucBdI25hWxfWcbtpi6MEYHAH4K1hHheYYhfM9Sd3FudhZ7LX7RiwxUzfg== X-Received: by 2002:a65:62d4:: with SMTP id m20mr16125007pgv.416.1552040229672; Fri, 08 Mar 2019 02:17:09 -0800 (PST) Received: from ash ([171.226.148.85]) by smtp.gmail.com with ESMTPSA id z7sm15742141pfl.4.2019.03.08.02.17.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 02:17:08 -0800 (PST) Received: by ash (sSMTP sendmail emulation); Fri, 08 Mar 2019 17:17:05 +0700 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Subject: [PATCH v1 01/11] checkout: split part of it to new command 'restore' Date: Fri, 8 Mar 2019 17:16:45 +0700 Message-Id: <20190308101655.9767-2-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.rc1.337.gdf7f8d0522 In-Reply-To: <20190308101655.9767-1-pclouds@gmail.com> References: <20190308101655.9767-1-pclouds@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Previously the switching branch business of 'git checkout' becomes a new command. This adds restore command for the checking out paths path. Similar to switch, a new man page is added to describe what the command will become. The implementation will be updated shortly to match the man page. A couple of differences from 'git checkout' worth highlighting: - 'restore' by default will only update worktree. This matters more when --source is specified ('checkout ' updates both worktree and index). - 'restore --index' can be used to restore the index. This command overlaps with 'git reset '. - both worktree and index could also be restored at the same time (from a tree). This overlaps with 'git checkout ' - default source for restoring worktree and index is the index and HEAD respectively. A different (tree) source could be specified as with --source (*). - when both index and worktree are restored, --source must be specified since the default source for these two individual targets are different (**) - --no-overlay is enabled by default, if an entry is missing in the source, restoring means deleting the entry (*) I originally went with --from instead of --source. I still think --from is a better name. The short option -f however is already taken by force. And I do think short option is good to have, e.g. to write -s@ or -s@^ instead of --source=HEAD. (**) If you sit down and think about it, moving worktree's source from the index to HEAD makes sense, but nobody is really thinking it through when they type the commands. Signed-off-by: Nguyễn Thái Ngọc Duy --- .gitignore | 1 + Documentation/config/interactive.txt | 3 +- Documentation/git-checkout.txt | 1 + Documentation/git-restore.txt (new) | 172 +++++++++++++++++++++++++++ Makefile | 1 + builtin.h | 1 + builtin/checkout.c | 26 ++++ command-list.txt | 1 + git.c | 1 + 9 files changed, 206 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c687b92b1c..fb377106be 100644 --- a/.gitignore +++ b/.gitignore @@ -143,6 +143,7 @@ /git-request-pull /git-rerere /git-reset +/git-restore /git-rev-list /git-rev-parse /git-revert diff --git a/Documentation/config/interactive.txt b/Documentation/config/interactive.txt index ad846dd7c9..a2d3c7ec44 100644 --- a/Documentation/config/interactive.txt +++ b/Documentation/config/interactive.txt @@ -2,7 +2,8 @@ interactive.singleKey:: In interactive commands, allow the user to provide one-letter input with a single key (i.e., without hitting enter). Currently this is used by the `--patch` mode of - linkgit:git-add[1], linkgit:git-checkout[1], linkgit:git-commit[1], + linkgit:git-add[1], linkgit:git-checkout[1], + linkgit:git-restore[1], linkgit:git-commit[1], linkgit:git-reset[1], and linkgit:git-stash[1]. Note that this setting is silently ignored if portable keystroke input is not available; requires the Perl module Term::ReadKey. diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 2b776c1269..e107099c8c 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -571,6 +571,7 @@ $ git add frotz SEE ALSO -------- linkgit:git-switch[1] +linkgit:git-restore[1] GIT --- diff --git a/Documentation/git-restore.txt b/Documentation/git-restore.txt new file mode 100644 index 0000000000..a667a5ced4 --- /dev/null +++ b/Documentation/git-restore.txt @@ -0,0 +1,172 @@ +git-restore(1) +============== + +NAME +---- +git-restore - Restore working tree files + +SYNOPSIS +-------- +[verse] +'git restore' [] [--source=] ... +'git restore' (-p|--patch) [--source=] [...] + +DESCRIPTION +----------- +Restore paths in the working tree by replacing with the contents in +the restore source or remove if the paths do not exist in the restore +source. The source is by default the index but could be from a commit. +The command can also optionally restore content in the index from a +commit. + +When a `` is given, the paths that match the `` are +updated both in the index and in the working tree. + +OPTIONS +------- +-s:: +--source=:: + Restore the working tree files with the content from the given + tree or any revision that leads to a tree (e.g. a commit or a + branch). + +-p:: +--patch:: + Interactively select hunks in the difference between the + `` (or the index, if unspecified) and the working + tree. See the ``Interactive Mode'' section of linkgit:git-add[1] + to learn how to operate the `--patch` mode. + +-W:: +--worktree:: +-I:: +--index:: + Specify the restore location. If neither option is specified, + by default the working tree is restored. If `--index` is + specified without `--worktree` or `--source`, `--source=HEAD` + is implied. These options only make sense to use with + `--source`. + +-q:: +--quiet:: + Quiet, suppress feedback messages. + +--progress:: +--no-progress:: + Progress status is reported on the standard error stream + by default when it is attached to a terminal, unless `--quiet` + is specified. This flag enables progress reporting even if not + attached to a terminal, regardless of `--quiet`. + +-f:: +--force:: + If `--source` is not specified, unmerged entries are left alone + and will not fail the operation. Unmerged entries are always + replaced if `--source` is specified, regardless of `--force`. + +--ours:: +--theirs:: + Check out stage #2 ('ours') or #3 ('theirs') for unmerged + paths. ++ +Note that during `git rebase` and `git pull --rebase`, 'ours' and +'theirs' may appear swapped. See the explanation of the same options +in linkgit:git-checkout[1] for details. + +-m:: +--merge:: + Recreate the conflicted merge in the specified paths. + +--conflict=