git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, me@ttaylorr.com, peff@peff.net,
	newren@gmail.com, Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH 3/4] sparse-checkout: create 'add' subcommand
Date: Tue, 11 Feb 2020 09:05:54 -0800	[thread overview]
Message-ID: <xmqqk14tvytp.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <663c40a6909ffac6650a3ee6883b3299f6b2bd90.1581433344.git.gitgitgadget@gmail.com> (Derrick Stolee via GitGitGadget's message of "Tue, 11 Feb 2020 15:02:23 +0000")

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

> +	switch (m) {
> +	case ADD:
> +		if (core_sparse_checkout_cone)
> +			add_patterns_cone_mode(argc, argv, &pl);
> +		else
> +			add_patterns_literal(argc, argv, &pl);
> +		break;
> +
> +	case REPLACE:
> +		add_patterns_from_input(&pl, argc, argv);
> +		break;
> +	}

Is it just me or do readers find it irritating to see the order of
the arguments seem a bit random?  Those who like Pseudo-OO-in-C
probably would want to consistently see &pl as the first parameter,
which lets them pretend various flavours of add_patterns_*() are
all "methods" to the pattern list object.

> +static void add_patterns_literal(int argc, const char **argv,
> +				 struct pattern_list *pl)
> +{
> +	char *sparse_filename = get_sparse_checkout_filename();
> +	if (add_patterns_from_file_to_list(sparse_filename, "", 0,
> +					   pl, NULL))
> +		die(_("unable to load existing sparse-checkout patterns"));
> +	free(sparse_filename);
> +	add_patterns_from_input(pl, argc, argv);
> +}

It may make it easier to read the caller if this helper were
replaced with one that does not add anything but just read from the
existing file, i.e.

		if (core_sparse_checkout_cone)
			add_patterns_cone_mode(argc, argv, &pl);
		else {
			read_existing_patterns(&pl);
			add_patterns_from_input(&pl, argc, argv);
		}


  reply	other threads:[~2020-02-11 17:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11 15:02 [PATCH 0/4] Sparse-checkout: Add subcommand and Windows paths Derrick Stolee via GitGitGadget
2020-02-11 15:02 ` [PATCH 1/4] sparse-checkout: extract add_patterns_from_input() Derrick Stolee via GitGitGadget
2020-02-11 16:56   ` Junio C Hamano
2020-02-11 15:02 ` [PATCH 2/4] sparse-checkout: extract pattern update from 'set' subcommand Derrick Stolee via GitGitGadget
2020-02-11 15:02 ` [PATCH 3/4] sparse-checkout: create 'add' subcommand Derrick Stolee via GitGitGadget
2020-02-11 17:05   ` Junio C Hamano [this message]
2020-02-11 15:02 ` [PATCH 4/4] sparse-checkout: work with Windows paths Derrick Stolee via GitGitGadget
2020-02-11 17:06 ` [PATCH 0/4] Sparse-checkout: Add subcommand and " Junio C Hamano
2020-02-11 19:48 ` Jeff King

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqk14tvytp.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    /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.
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 NNTP newsgroup(s).