git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Joel Teichroeb <joel@teichroeb.net>
Cc: Git Mailing List <git@vger.kernel.org>,
	Thomas Gummerer <t.gummerer@gmail.com>,
	Christian Couder <christian.couder@gmail.com>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH v4 3/5] stash: convert drop and clear to builtin
Date: Fri, 30 Mar 2018 09:17:09 -0700	[thread overview]
Message-ID: <xmqqin9d4jy2.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180328222129.22192-4-joel@teichroeb.net> (Joel Teichroeb's message of "Wed, 28 Mar 2018 15:21:27 -0700")

Joel Teichroeb <joel@teichroeb.net> writes:

> +static int do_clear_stash(void)
> +{
> +	struct object_id obj;
> +	if (get_oid(ref_stash, &obj))
> +		return 0;
> +	return delete_ref(NULL, ref_stash, &obj, 0);
> +}

Here you see if the "refs/stash" is there, and learn what its
current value is, using get_oid(), so that you can call delete_ref()
with it.

> +static int do_drop_stash(const char *prefix, struct stash_info *info)
> +{
> +	...
> +	cp.git_cmd = 1;
> +	/* Even though --quiet is specified, rev-parse still outputs the hash */
> +	cp.no_stdout = 1;
> +	argv_array_pushl(&cp.args, "rev-parse", "--verify", "--quiet", NULL);
> +	argv_array_pushf(&cp.args, "%s@{0}", ref_stash);
> +	ret = run_command(&cp);
> +	if (ret)
> +		do_clear_stash();

Here you call out to rev-parse as an external process.  Isn't doing
the same get_oid() sufficient?

Not limited to the above examples, the conversion in this series
feels somewhat unbalanced---doing easy things like this by forking
an external process and then doing a relatively heavyweight thing
like merge operation (in 2/5) in-process feels the other way around.

Thanks.

  reply	other threads:[~2018-03-30 16:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 22:21 [PATCH v4 0/5] Convert some stash functionality to a builtin Joel Teichroeb
2018-03-28 22:21 ` [PATCH v4 1/5] stash: improve option parsing test coverage Joel Teichroeb
2018-03-29 10:10   ` Eric Sunshine
2018-03-29 19:39   ` Junio C Hamano
2018-03-28 22:21 ` [PATCH v4 2/5] stash: convert apply to builtin Joel Teichroeb
2018-03-29 20:07   ` Junio C Hamano
2018-03-31 17:04     ` Joel Teichroeb
2018-03-28 22:21 ` [PATCH v4 3/5] stash: convert drop and clear " Joel Teichroeb
2018-03-30 16:17   ` Junio C Hamano [this message]
2018-03-28 22:21 ` [PATCH v4 4/5] stash: convert branch " Joel Teichroeb
2018-03-28 22:21 ` [PATCH v4 5/5] stash: convert pop " Joel Teichroeb

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=xmqqin9d4jy2.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=joel@teichroeb.net \
    --cc=sunshine@sunshineco.com \
    --cc=t.gummerer@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).