git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 3/5] stash: convert drop and clear to builtin

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 30, 2018, 16:17 UTC
Message-ID
<xmqqin9d4jy2.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180328222129.22192-4-joel@teichroeb.net>
Joel Teichroeb <joel@teichroeb.net> writes:
Show 7 quoted lines
> +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.

Show 11 quoted lines
> +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.
Previous: Joel TeichroebNext: Joel Teichroeb
Message 6 of 11 in “Convert some stash functionality to a builtin”
  1. 0/5 Convert some stash functionality to a builtinJoel Teichroeb, Mar 28, 2018
  2. 1/5 stash: improve option parsing test coverageJoel Teichroeb, Mar 28, 2018
  3. Eric SunshineMar 29, 2018
  4. Junio C HamanoMar 29, 2018
  5. 3/5 stash: convert drop and clear to builtinJoel Teichroeb, Mar 28, 2018
  6. Junio C HamanoMar 30, 2018
  7. 2/5 stash: convert apply to builtinJoel Teichroeb, Mar 28, 2018
  8. Junio C HamanoMar 29, 2018
  9. Joel TeichroebMar 31, 2018
  10. 5/5 stash: convert pop to builtinJoel Teichroeb, Mar 28, 2018
  11. 4/5 stash: convert branch to builtinJoel Teichroeb, Mar 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.