public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Joey Hess <joeyh@joeyh•name>
Cc: git@vger•kernel.org
Subject: Re: [PATCH v4 8/8] use smudgeToFile filter in recursive merge
Date: Wed, 22 Jun 2016 14:39:24 -0700	[thread overview]
Message-ID: <xmqq7fdglx83.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1466629758-8035-9-git-send-email-joeyh@joeyh.name> (Joey Hess's message of "Wed, 22 Jun 2016 17:09:18 -0400")

Joey Hess <joeyh@joeyh•name> writes:

> @@ -781,6 +773,7 @@ static void update_file_flags(struct merge_options *o,
>  		}
>  		if (S_ISREG(mode) || (!has_symlinks && S_ISLNK(mode))) {
>  			int fd;
> +			int isreg = S_ISREG(mode);

You probably want to move this isreg business up one scope
(i.e. inside "if (update_wd) {").  Then the if () condition
for this block can use it already.

>  			if (mode & 0100)
>  				mode = 0777;
>  			else
> @@ -788,8 +781,37 @@ static void update_file_flags(struct merge_options *o,
>  			fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
>  			if (fd < 0)
>  				die_errno(_("failed to open '%s'"), path);
> -			write_in_full(fd, buf, size);
> -			close(fd);
> +
> +			int smudge_to_file = can_smudge_to_file(path);

This does not compile with decl-after-statement.  I suspect other
patches in this series have the same issue but I did not check.  Do
you say "make DEVELOPER=1"?

> +			if (smudge_to_file) {
> +				close(fd);
> +				fd = convert_to_working_tree_filter_to_file(path, path, buf, size);
> +				if (fd < 0) {
> +					/* smudgeToFile filter failed;
> +					 * continue with regular file
> +					 * creation. */

/*
 * Style: We format our multi-line
 * comments like this.
 */

> +					smudge_to_file = 0;

Ahh, I was wondering why this is not "if (smudge_to_file) ... else ...".

> +					fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
> +					if (fd < 0)
> +						die_errno(_("failed to open '%s'"), path);
> +				}
> +				else {
> +					close(fd);
> +				}
> +			}
> +
> +			if (! smudge_to_file) {

Style: if (!smudge_to_file) {

> +test_expect_success 'smudgeToFile filter is used in merge' '
> +	test_config filter.rot13.smudgeToFile ./rot13-to-file.sh &&
> +
> +	git commit -m "added fstest.t" fstest.t &&
> +	git checkout -b old &&
> +	git reset --hard HEAD^ &&
> +	git merge master &&
> +
> +	test -e rot13-to-file.ran &&
> +	rm -f rot13-to-file.ran &&
> +
> +	cmp test fstest.t &&

"test_cmp test fstest.t"?  The difference matters when running the
test with -v option.

> +	git checkout master

What happens if any of the previous steps failed?  Does the next
test get confused because you would fail to go back to the master
branch?

> +'
> +
>  test_expect_success 'smudgeToFile filter is used by git am' '
>  	test_config filter.rot13.smudgeToFile ./rot13-to-file.sh &&
>  
> -	git commit fstest.t -m "added fstest.t" &&
>  	git format-patch HEAD^ --stdout > fstest.patch &&

Style: 

	git format-patch HEAD^ --stdout >fstest.patch &&

>  	git reset --hard HEAD^ &&
>  	git am < fstest.patch &&

Style: 

	git am <fstest.patch &&

but in this case you do not even need to redirect, i.e.

	git am fstest.patch &&

is enough.

Thanks.

  reply	other threads:[~2016-06-22 21:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-22 21:09 [PATCH v4 0/8] extend smudge/clean filters with direct file access (for pu) Joey Hess
2016-06-22 21:09 ` [PATCH v4 1/8] clarify %f documentation Joey Hess
2016-06-22 21:09 ` [PATCH v4 2/8] add smudgeToFile and cleanFromFile filter configs Joey Hess
2016-06-22 21:09 ` [PATCH v4 3/8] use cleanFromFile in git add Joey Hess
2016-06-22 21:09 ` [PATCH v4 4/8] use smudgeToFile in git checkout etc Joey Hess
2016-06-22 21:09 ` [PATCH v4 5/8] warn on unusable smudgeToFile/cleanFromFile config Joey Hess
2016-06-22 21:09 ` [PATCH v4 6/8] better recovery from failure of smudgeToFile filter Joey Hess
2016-06-22 21:09 ` [PATCH v4 7/8] use smudgeToFile filter in git am Joey Hess
2016-06-22 21:09 ` [PATCH v4 8/8] use smudgeToFile filter in recursive merge Joey Hess
2016-06-22 21:39   ` Junio C Hamano [this message]
2016-06-22 22:45     ` Junio C Hamano
2016-06-22 21:23 ` [PATCH v4 0/8] extend smudge/clean filters with direct file access (for pu) Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq7fdglx83.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=joeyh@joeyh$(echo .)name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox