From patchwork Sat Jun 13 07:14:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Guriev X-Patchwork-Id: 11602577 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 BF528913 for ; Sat, 13 Jun 2020 07:34:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B020120739 for ; Sat, 13 Jun 2020 07:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726361AbgFMHeL (ORCPT ); Sat, 13 Jun 2020 03:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726048AbgFMHeL (ORCPT ); Sat, 13 Jun 2020 03:34:11 -0400 X-Greylist: delayed 235 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 13 Jun 2020 00:34:10 PDT Received: from dandelion.mymedia.su (unknown [IPv6:2604:180:2:1574::c9e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC4BC03E96F for ; Sat, 13 Jun 2020 00:34:10 -0700 (PDT) Received: from dandelion.mymedia.su (localhost.localdomain [127.0.0.1]) by dandelion.mymedia.su (8.15.2/8.15.2/Debian-3) with ESMTP id 05D7UBwQ010560 for ; Sat, 13 Jun 2020 10:30:11 +0300 Received: (from mymedia@localhost) by dandelion.mymedia.su (8.15.2/8.15.2/Submit) id 05D7UB99010559 for git@vger.kernel.org; Sat, 13 Jun 2020 10:30:11 +0300 Message-Id: <202006130730.05D7UB99010559@dandelion.mymedia.su> From: Nicholas Guriev Date: Sat, 13 Jun 2020 10:14:21 +0300 Subject: [PATCH] worktree: treat "list" as default command To: git@vger.kernel.org Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Perceive simple "git worktree" without a subcommand as "git worktree list" for consistency with "git submodule" that already can work in such a way. Signed-off-by: Nicholas Guriev --- builtin/worktree.c | 4 ++-- t/t2402-worktree-list.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index d99db356..ad949eb5 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -960,10 +960,10 @@ int cmd_worktree(int ac, const char **av, const char *prefix) git_config(git_worktree_config, NULL); - if (ac < 2) - usage_with_options(worktree_usage, options); if (!prefix) prefix = ""; + if (ac < 2 || av[1][0] == '-') + return list(ac, av, prefix); if (!strcmp(av[1], "add")) return add(ac - 1, av + 1, prefix); if (!strcmp(av[1], "prune")) diff --git a/t/t2402-worktree-list.sh b/t/t2402-worktree-list.sh index 52585ec2..e53bafa3 100755 --- a/t/t2402-worktree-list.sh +++ b/t/t2402-worktree-list.sh @@ -157,4 +157,16 @@ test_expect_success 'worktree path when called in .git directory' ' test_cmp list1 list2 ' +test_expect_success '"list" is the default command' ' + git worktree >out1 && + git worktree list >out2 && + test_cmp out1 out2 +' + +test_expect_success 'options are passed to default command' ' + git worktree --porcelain >out1 && + git worktree list --porcelain >out2 && + test_cmp out1 out2 +' + test_done