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

Re: [PATCH 2/3] stripspace: respect repository config

From
Jeff King <peff@peff.net>
Date
Nov 22, 2016, 21:43 UTC
Message-ID
<20161122214305.yrn4uqh4dzzafkd2@sigill.intra.peff.net>
In-Reply-To
<xmqqeg23p5v3.fsf@gitster.mtv.corp.google.com>
On Tue, Nov 22, 2016 at 01:22:24PM -0800, Junio C Hamano wrote:
> OK.  The "mailinfo" part turns out a bit more than RUN_SETUP_GENTLY
> as it takes paths from the command line that needs to be adjusted
> for the prefix.

I wondered at first if our lack of parse-options here was holding us back from using OPT_FILENAME. Though even if that was the case, it is probably better to do the minimal fix in this instance, rather than converting the option parsing.

However, the paths which need munged are not even options, they are arguments. So we wouldn't be able to rely on OPT_FILENAME anyway. I'm surprised we haven't had to deal with this elsewhere, but I guess most commands don't take arbitrary filenames (things like `add` take pathspecs, and then the pathspec machinery takes care of the details).

The only other case I could think of is git-apply, and it does use prefix_filename() correctly.

Show 6 quoted lines
> +static char *prefix_copy(const char *prefix, const char *filename)
> +{
> +	if (!prefix || is_absolute_path(filename))
> +		return xstrdup(filename);
> +	return xstrdup(prefix_filename(prefix, strlen(prefix), filename));
> +}

So this is more or less a copy of parse-option's fix_filename(), which makes sense.

I noticed that git-apply does not check is_absolute_path(), but that's OK, as prefix_filename() does. So I think it would be correct to drop it here, but it doesn't matter much either way.

Show 11 quoted lines
>  int cmd_mailinfo(int argc, const char **argv, const char *prefix)
>  {
>  	const char *def_charset;
>  	struct mailinfo mi;
>  	int status;
> +	char *msgfile, *patchfile;
>  
> -	/* NEEDSWORK: might want to do the optional .git/ directory
> -	 * discovery
> -	 */
>  	setup_mailinfo(&mi);

This part looks straightforward and correct. Dropping the NEEDSWORK is a nice bonus.

Show 11 quoted lines
> +test_expect_success 'mailinfo with mailinfo.scissors config' '
> +	test_config mailinfo.scissors true &&
> +	(
> +		mkdir sub &&
> +		cd sub &&
> +		git mailinfo ../msg0014.sc ../patch0014.sc <../0014 >../info0014.sc
> +	) &&
> +	test_cmp "$DATA/msg0014--scissors" msg0014.sc &&
> +	test_cmp "$DATA/patch0014--scissors" patch0014.sc &&
> +	test_cmp "$DATA/info0014--scissors" info0014.sc
> +'

And this test makes sense. Even without "sub", it would show the regression, but it's a good idea to test the sub-directory case to cover the path-munging.

In the "archive --remote" test I added, we may want to do the same to show that "--output" points at the correct path.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 40 in “Fix problems with rebase -i when core.commentchar is defined”
  1. 0/3 Fix problems with rebase -i when core.commentchar is definedJohannes Schindelin, Nov 21, 2016
  2. 2/3 stripspace: respect repository configJohannes Schindelin, Nov 21, 2016
  3. Duy NguyenNov 22, 2016
  4. Johannes SchindelinNov 22, 2016
  5. Junio C HamanoNov 22, 2016
  6. Junio C HamanoNov 22, 2016
  7. Jeff KingNov 22, 2016
  8. Junio C HamanoNov 22, 2016
  9. Jeff KingNov 22, 2016
  10. Junio C HamanoNov 22, 2016
  11. Jeff KingNov 22, 2016
  12. Junio C HamanoNov 22, 2016
  13. Jeff KingNov 23, 2016
  14. Jeff KingNov 22, 2016
  15. 1/3 rebase -i: identify problems with core.commentcharJohannes Schindelin, Nov 21, 2016
  16. Junio C HamanoNov 21, 2016
  17. Junio C HamanoNov 21, 2016
  18. 1/3 rebase -i: highlight problems with core.commentcharJunio C Hamano, Nov 21, 2016
  19. 2/3 stripspace: respect repository configJunio C Hamano, Nov 21, 2016
  20. Junio C HamanoNov 21, 2016
  21. Johannes SchindelinNov 22, 2016
  22. 3/3 rebase -i: handle core.commentChar=autoJunio C Hamano, Nov 21, 2016
  23. Junio C HamanoNov 21, 2016
  24. Junio C HamanoNov 21, 2016
  25. Johannes SchindelinNov 22, 2016
  26. Junio C HamanoNov 22, 2016
  27. Johannes SchindelinNov 23, 2016
  28. Jeff KingNov 21, 2016
  29. Junio C HamanoNov 21, 2016
  30. Jeff KingNov 21, 2016
  31. Johannes SchindelinNov 22, 2016
  32. 3/3 rebase -i: handle core.commentChar=autoJohannes Schindelin, Nov 21, 2016
  33. Johannes SixtNov 21, 2016
  34. Junio C HamanoNov 21, 2016
  35. Johannes SixtNov 21, 2016
  36. Junio C HamanoNov 21, 2016
  37. Johannes SixtNov 21, 2016
  38. Johannes SchindelinNov 22, 2016
  39. Duy NguyenNov 22, 2016
  40. Jacob KellerNov 21, 2016

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.