git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "René Scharfe" <l.s.r@web.de>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Duy Nguyen" <pclouds@gmail.com>,
	"Git Mailing List" <git@vger.kernel.org>,
	"Ralf Thielow" <ralf.thielow@gmail.com>,
	"Taufiq Hoven" <taufiq.hoven@gmail.com>
Subject: Re: [PATCH 2/3] stripspace: respect repository config
Date: Tue, 22 Nov 2016 16:43:06 -0500	[thread overview]
Message-ID: <20161122214305.yrn4uqh4dzzafkd2@sigill.intra.peff.net> (raw)
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.

> +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.

>  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.

> +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

  reply	other threads:[~2016-11-22 21:43 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21 14:18 [PATCH 0/3] Fix problems with rebase -i when core.commentchar is defined Johannes Schindelin
2016-11-21 14:18 ` [PATCH 1/3] rebase -i: identify problems with core.commentchar Johannes Schindelin
2016-11-21 18:15   ` Junio C Hamano
2016-11-21 18:24     ` Junio C Hamano
2016-11-21 19:05       ` [PATCH 1/3] rebase -i: highlight " Junio C Hamano
2016-11-21 19:05         ` [PATCH 2/3] stripspace: respect repository config Junio C Hamano
2016-11-21 20:28           ` Junio C Hamano
2016-11-22 16:11           ` Johannes Schindelin
2016-11-21 19:05         ` [PATCH 3/3] rebase -i: handle core.commentChar=auto Junio C Hamano
2016-11-21 20:29           ` Junio C Hamano
2016-11-21 20:25         ` [PATCH 1/3] rebase -i: highlight problems with core.commentchar Junio C Hamano
2016-11-22 16:09         ` Johannes Schindelin
2016-11-22 17:05           ` Junio C Hamano
2016-11-23 11:05             ` Johannes Schindelin
2016-11-21 18:49     ` [PATCH 1/3] rebase -i: identify " Jeff King
2016-11-21 19:12       ` Junio C Hamano
2016-11-21 23:38         ` Jeff King
2016-11-22 16:09     ` Johannes Schindelin
2016-11-21 14:18 ` [PATCH 2/3] stripspace: respect repository config Johannes Schindelin
2016-11-22 10:10   ` Duy Nguyen
2016-11-22 16:13     ` Johannes Schindelin
2016-11-22 17:10       ` Junio C Hamano
2016-11-22 19:10         ` Junio C Hamano
2016-11-22 19:50           ` Jeff King
2016-11-22 20:24             ` Junio C Hamano
2016-11-22 21:19               ` Jeff King
2016-11-22 21:22                 ` Junio C Hamano
2016-11-22 21:43                   ` Jeff King [this message]
2016-11-22 21:55                     ` Junio C Hamano
2016-11-23  0:12                       ` Jeff King
2016-11-22 21:24                 ` Jeff King
2016-11-21 14:18 ` [PATCH 3/3] rebase -i: handle core.commentChar=auto Johannes Schindelin
2016-11-21 18:26   ` Johannes Sixt
2016-11-21 18:40     ` Junio C Hamano
2016-11-21 18:58       ` Johannes Sixt
2016-11-21 19:07         ` Junio C Hamano
2016-11-21 19:14           ` Johannes Sixt
2016-11-22 16:04     ` Johannes Schindelin
2016-11-22 10:31   ` Duy Nguyen
2016-11-21 16:58 ` [PATCH 0/3] Fix problems with rebase -i when core.commentchar is defined Jacob Keller

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=20161122214305.yrn4uqh4dzzafkd2@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=pclouds@gmail.com \
    --cc=ralf.thielow@gmail.com \
    --cc=taufiq.hoven@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).