From patchwork Sat Jun 13 14:25:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11602831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1B66912 for ; Sat, 13 Jun 2020 14:25:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BACB020792 for ; Sat, 13 Jun 2020 14:25:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MjMahsNO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbgFMOZ3 (ORCPT ); Sat, 13 Jun 2020 10:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgFMOZ2 (ORCPT ); Sat, 13 Jun 2020 10:25:28 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 030F7C03E96F for ; Sat, 13 Jun 2020 07:25:27 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id q8so11712662qkm.12 for ; Sat, 13 Jun 2020 07:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=DghuTSbX4zxMdv4AE3Dx+fuWr8PHfn3QrPhRR6s/d90=; b=MjMahsNOYe7zBv9b+B9wv5ai/L7G04tOjuqnjuDR9VyQBPmP026INHWb2Nb6ui1xSh VC4iXiJT6F76Ma3IGs4QnO4tfx9bK+5SiTkiY/wPFsk01yL0XL4MIfuCMAsaLmNgTnJg V09ZbY9b/hlCJD7PieVYFTvwkSELuS8rneBjWmqtXVdqDy/yxnTM7G+DvG70hTT/b8/y G44tfkgFX+gOqDgJALMDGBDTw3msKe3FeuUrqtxrRKrIRTxcye+/tgasLdCw43HFyFcT f3gqmpwKfdYerFpaIB2ZBDYWEigUnSWM8dXydaskDdVWkTewnbhdyHtpThZmHkte4M93 lpYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=DghuTSbX4zxMdv4AE3Dx+fuWr8PHfn3QrPhRR6s/d90=; b=K9ElpxE+hhSimYO8/N7jYyS0YDM1IYH9CnR4TWCXho8SswiozJyOnjGEUfCH+++Yqf znbpY41osaEwsZMlnpNQ4XcBYaE/VckhiefVf7UT3ZmmX5ndyrykZWNWNxb1q9zcfnoG JG/BO+YVaSOL0MXDsFiAQIXqtJ5YFqsvrgGqbgDmYqlvTGLgEBYUlNmHVmOpQdBA7w60 kqYngYLrqDrJaKgRuCdel2y6k5WdDhfk5HiMVsqSUjBZj5Oyl6u/U8QiuhztDG3T6rLc DXsdnsvrQ3Sq0BwcOROESdM5qJH/mf7liq9L9Hb2tcN80lkyQGOmEAvl3py+tCQ6w5R8 3ggA== X-Gm-Message-State: AOAM5317Kd2AFZkSst3Xi+T3SO6AL2Ss3toywwsfoBuXbzOCnD1+QXBP IDanYxPMb/EBi/mDBmjBOp1uy2QKAWU= X-Google-Smtp-Source: ABdhPJzTfktEqtWlPPpbv9lZJ8wmKYZ4nU7ijdTUET3CN3N0W1EgmWMdnP5R5zG/FgaqzVfgyhNrQQ== X-Received: by 2002:a37:a648:: with SMTP id p69mr7842561qke.190.1592058326747; Sat, 13 Jun 2020 07:25:26 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id x36sm7144232qtd.97.2020.06.13.07.25.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Jun 2020 07:25:26 -0700 (PDT) From: Denton Liu To: Git Mailing List Subject: [PATCH] checkout: teach --worktree Date: Sat, 13 Jun 2020 10:25:12 -0400 Message-Id: X-Mailer: git-send-email 2.27.0.132.g321788e831 MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org A complaint that has come up frequently in the past is that it is not possible to checkout files directly into a worktree without modifying the index. Even though this could be worked around by redirecting the output of `git show` to overwrite files, this was not feasible if one wanted to use patch mode. Since `git restore` was implemented, this has since been possible using the `--worktree` option. However, some long-time users of Git still prefer to use `git checkout` over `git restore` and would like to see the functionality ported over. Teach `git checkout --worktree`, allowing users to checkout files directly into the worktree without affecting the index. Signed-off-by: Denton Liu --- Documentation/git-checkout.txt | 22 ++++++++++----- builtin/checkout.c | 17 ++++++++++++ t/t2028-checkout-worktree.sh | 51 ++++++++++++++++++++++++++++++++++ t/t9902-completion.sh | 1 + 4 files changed, 84 insertions(+), 7 deletions(-) create mode 100755 t/t2028-checkout-worktree.sh diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 5b697eee1b..ba9c0a900c 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -12,9 +12,9 @@ SYNOPSIS 'git checkout' [-q] [-f] [-m] --detach [] 'git checkout' [-q] [-f] [-m] [--detach] 'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] ] [] -'git checkout' [-f|--ours|--theirs|-m|--conflict=