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

Re: [PATCH v4 8/8] use smudgeToFile filter in recursive merge

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 22, 2016, 21:39 UTC
Message-ID
<xmqq7fdglx83.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1466629758-8035-9-git-send-email-joeyh@joeyh.name>
Joey Hess <joeyh@joeyh.name> writes:
Show 5 quoted lines
> @@ -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.

Show 11 quoted lines
>  			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"?

Show 7 quoted lines
> +			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 ...".
Show 10 quoted lines
> +					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) {
Show 12 quoted lines
> +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?

Show 7 quoted lines
> +'
> +
>  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.
Previous: Joey HessNext: Junio C Hamano
Message 8 of 12 in “extend smudge/clean filters with direct file access (for pu)”
  1. 0/8 extend smudge/clean filters with direct file access (for pu)Joey Hess, Jun 22, 2016
  2. 4/8 use smudgeToFile in git checkout etcJoey Hess, Jun 22, 2016
  3. 2/8 add smudgeToFile and cleanFromFile filter configsJoey Hess, Jun 22, 2016
  4. 1/8 clarify %f documentationJoey Hess, Jun 22, 2016
  5. 3/8 use cleanFromFile in git addJoey Hess, Jun 22, 2016
  6. 5/8 warn on unusable smudgeToFile/cleanFromFile configJoey Hess, Jun 22, 2016
  7. 8/8 use smudgeToFile filter in recursive mergeJoey Hess, Jun 22, 2016
  8. Junio C HamanoJun 22, 2016
  9. Junio C HamanoJun 22, 2016
  10. 6/8 better recovery from failure of smudgeToFile filterJoey Hess, Jun 22, 2016
  11. 7/8 use smudgeToFile filter in git amJoey Hess, Jun 22, 2016
  12. Junio C HamanoJun 22, 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.