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

Re: [PATCH v3] stash: implement '--staged' option for 'push' and 'save'

From
Sergey Organov <sorganov@gmail.com>
Date
Oct 27, 2021, 15:11 UTC
Message-ID
<8735ombizs.fsf@osv.gnss.ru>
In-Reply-To
<YXeMkC/jPxjzNgWF@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 38 quoted lines
> On Mon, Oct 18, 2021 at 07:09:06PM +0300, Sergey Organov wrote:
>
>> +static int stash_staged(struct stash_info *info, const struct pathspec *ps,
>> +			struct strbuf *out_patch, int quiet)
>> +{
>> +	int ret = 0;
>> +	struct child_process cp_diff_tree = CHILD_PROCESS_INIT;
>> +	struct index_state istate = { NULL };
>> +
>> + if (write_index_as_tree(&info->w_tree, &istate,
>> the_repository->index_file,
>> +				0, NULL)) {
>> +		ret = -1;
>> +		goto done;
>> +	}
>> +
>> +	cp_diff_tree.git_cmd = 1;
>> +	strvec_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD",
>> +		     oid_to_hex(&info->w_tree), "--", NULL);
>> +	if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) {
>> +		ret = -1;
>> +		goto done;
>> +	}
>> +
>> +	if (!out_patch->len) {
>> +		if (!quiet)
>> +			fprintf_ln(stderr, _("No staged changes"));
>> +		ret = 1;
>> +	}
>> +
>> +done:
>> +	discard_index(&istate);
>> +	return ret;
>> +}
>
> This function doesn't look at its "struct pathspec" parameter at all.
> I'm not sure if that's a bug (i.e., it should be restricting the diff
> here) or if it was just pulled unnecessarily over from stash_patch().

Yep, it's a remnant from copy-paste of stash_patch(). I'm used to getting a warning from compiler for such cases and didn't pay enough attention. The warning belongs to -Wextra though and is not turned on for Git compilation.

Thanks for catching!
-- Sergey Organov
Previous: Jeff KingNext: Sergey Organov
Message 22 of 26 in “stash: implement '--staged' option for 'push' and 'save'”
  1. stash: implement '--staged' option for 'push' and 'save'Sergey Organov, Oct 1, 2021
  2. stash: implement '--staged' option for 'push' and 'save'Sergey Organov, Oct 11, 2021
  3. Eric SunshineOct 11, 2021
  4. Sergey OrganovOct 11, 2021
  5. Ævar Arnfjörð BjarmasonOct 12, 2021
  6. Sergey OrganovOct 12, 2021
  7. Junio C HamanoOct 12, 2021
  8. Junio C HamanoOct 12, 2021
  9. Sergey OrganovOct 12, 2021
  10. Junio C HamanoOct 12, 2021
  11. Sergey OrganovOct 12, 2021
  12. Junio C HamanoOct 13, 2021
  13. Sergey OrganovOct 13, 2021
  14. stash: implement '--staged' option for 'push' and 'save'Sergey Organov, Oct 15, 2021
  15. Junio C HamanoOct 15, 2021
  16. Sergey OrganovOct 15, 2021
  17. Junio C HamanoOct 15, 2021
  18. Sergey OrganovOct 15, 2021
  19. Sergey OrganovOct 15, 2021
  20. stash: implement '--staged' option for 'push' and 'save'Sergey Organov, Oct 18, 2021
  21. Jeff KingOct 26, 2021
  22. Sergey OrganovOct 27, 2021
  23. stash: implement '--staged' option for 'push' and 'save'Sergey Organov, Oct 27, 2021
  24. Junio C HamanoOct 27, 2021
  25. stash: get rid of unused argument in stash_staged()Sergey Organov, Oct 28, 2021
  26. Junio C HamanoOct 28, 2021

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.