From: Eric Sunshine <sunshine@sunshineco.com>
To: Elia Pinto <gitter.spiros@gmail.com>
Cc: "Git List" <git@vger.kernel.org>,
"Martin Ågren" <martin.agren@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Karen Arutyunov" <karen@codesynthesis.com>
Subject: Re: [PATCH v2] worktree: add --quiet option
Date: Thu, 16 Aug 2018 04:43:44 -0400 [thread overview]
Message-ID: <CAPig+cTSZNtKUXLoR6gqvWT3bD-JgWOF38ZD7i+OocRs4p=GMA@mail.gmail.com> (raw)
In-Reply-To: <20180815205630.32876-1-gitter.spiros@gmail.com>
On Wed, Aug 15, 2018 at 4:56 PM Elia Pinto <gitter.spiros@gmail.com> wrote:
> Add the '--quiet' option to git worktree,
> as for the other git commands. 'add' is the
> only command affected by it since all other
> commands, except 'list', are currently
> silent by default.
Nit: wrap the commit message at around 70 columns rather than 45 or so.
> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
> ---
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> @@ -303,9 +304,13 @@ static int add_worktree(const char *path, const char *refname,
> + else {
> argv_array_pushl(&cp.args, "symbolic-ref", "HEAD",
> symref.buf, NULL);
> + if (opts->quiet)
> + argv_array_push(&cp.args, "--quiet");
> + }
This constructs the command as "git symbolic-ref HEAD <ref> --quiet".
Although that's not wrong per-se, it does perhaps set an undesirable
precedent. A more standard construction would be:
argv_array_push(..., "symbolic-ref");
if (opts->quiet)
argv_array_push(..., "--quiet");
argv_array_pushl(..., "HEAD", symref.buf, NULL);
I used "pushl" on the last one to indicate the semantic relationship
between those two arguments.
> +
Nit: the above code is directly related to the code just below, so the
new blank line you add here somewhat (undesirably) divorces the pieces
of code from each other
> cp.env = child_env.argv;
> ret = run_command(&cp);
> if (ret)
> @@ -315,6 +320,8 @@ static int add_worktree(const char *path, const char *refname,
> argv_array_pushl(&cp.args, "reset", "--hard", NULL);
> + if (opts->quiet)
> + argv_array_push(&cp.args, "--quiet");
I could also see this one re-written as:
argv_array_push(...,"reset");
argv_array_push(...,"--hard");
if (opts->quiet)
argv_array_push(...,"--quiet");
now that the command invocation has added another option.
Not at all worth a re-roll.
> diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
> @@ -252,6 +252,11 @@ test_expect_success 'add -B' '
> +test_expect_success 'add --quiet' '
> + git worktree add --quiet ../foo master >expected 2>&1 &&
> + test_must_be_empty expected
> +'
This test is going to create the new worktree directly in Git's t/
directory due to "../foo". Please don't do that. Use a name without
the leading "../".
Also, you should make sure that the worktree doesn't already exist
(wasn't created by an earlier test), otherwise the "git worktree add"
command will fail. So, either choose a distinct worktree name or use
"test_might_fail git worktree remove -f <worktree>" before the "git
worktree add" command.
next prev parent reply other threads:[~2018-08-16 8:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-15 20:56 [PATCH v2] worktree: add --quiet option Elia Pinto
2018-08-15 22:36 ` Thomas Gummerer
2018-08-16 4:40 ` Martin Ågren
2018-08-16 8:25 ` Eric Sunshine
2018-08-16 10:11 ` Martin Ågren
2018-08-16 8:43 ` Eric Sunshine [this message]
2018-08-16 20:38 ` Junio C Hamano
2018-08-16 20:42 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPig+cTSZNtKUXLoR6gqvWT3bD-JgWOF38ZD7i+OocRs4p=GMA@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=gitter.spiros@gmail.com \
--cc=karen@codesynthesis.com \
--cc=martin.agren@gmail.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).