"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: got-build-regress.sh regress failure
To:
stsp@stsp.name
Cc:
gameoftrees@openbsd.org
Date:
Tue, 08 Mar 2022 09:18:27 +0100

Download raw body.

Thread
stsp@stsp.name wrote:
> got-build-regress.sh for branch 'main' on Tue Mar  8 05:00:01 UTC 2022
> [...]
> ==== patch ====
> ./patch.sh -q -r "/ramdisk/got-test"
> got: mkstemp: /ramdisk/got-test/got-test-patch_simple_add_file-EEJ81dLp/wt-83gN3j: No such file or directory
> test failed; leaving test data in /ramdisk/got-test/got-test-patch_simple_add_file-EEJ81dLp
> got: mkstemp: /ramdisk/got-test/got-test-patch_simple_edit_file-1AH3CFsz/wt-7mXSFY: No such file or directory
> test failed; leaving test data in /ramdisk/got-test/got-test-patch_simple_edit_file-1AH3CFsz
> got: mkstemp: /ramdisk/got-test/got-test-patch_prepend_line-drlmpqti/wt-oIclWP: No such file or directory
> test failed; leaving test data in /ramdisk/got-test/got-test-patch_prepend_line-drlmpqti
> got: mkstemp: /ramdisk/got-test/got-test-patch_replace_line-GwmSoOJr/wt-yMh65G: No such file or directory
> test failed; leaving test data in /ramdisk/got-test/got-test-patch_replace_line-GwmSoOJr
> got: mkstemp: /ramdisk/got-test/got-test-patch_replace_multiple_lines-5ccWAUPP/wt-KC4AvM: No such file or directory
> test failed; leaving test data in /ramdisk/got-test/got-test-patch_replace_multiple_lines-5ccWAUPP
> got: mkstemp: /ramdisk/got-test/got-test-patch_multiple_files-FLVTu9p4/wt-AEYvYk: No such file or directory
> test failed; leaving test data in 1
> --- /ramdisk/got-test/got-test-patch_dont_apply-j0GwTNKr/stderr.expected	Tue Mar  8 06:16:50 2022
> +++ /ramdisk/got-test/got-test-patch_dont_apply-j0GwTNKr/stderr	Tue Mar  8 06:16:50 2022
> @@ -1 +1 @@
> -got: patch doesn't apply
> +got: mkstemp: /ramdisk/got-test/got-test-patch_dont_apply-j0GwTNKr/wt-veJJZC: No such file or directory
> test failed; leaving test data in /ramdisk/got-test/got-test-patch_dont_apply-j0GwTNKr
> got: mkstemp: /ramdisk/got-test/got-test-patch_prepend_line-ZEZVQRt2/wt-xkEFDq: No such file or directory
> test failed; leaving test data in /ramdisk/got-test/got-test-patch_prepend_line-ZEZVQRt2
> *** Error 1 in regress/cmdline (Makefile:91 'patch')
> FAILED

woops, i've been a bit sloppy in the way I'm generating the temporary
file while applying the patch.  (but i couldn't replicate locally)

I need to open a new temporary file during the patch operation to
accumulate the changes/additions to the target file before rename(2) it
to the destination file.

It's fine to just use "./"?  it's the only instance in the codebase, but
I can't use /tmp because I need both files (temp and destination) to be
on the same filesystem for rename(2) to work.  got_opentemp guarantees
us that it's a new file, so no chance to corrupt existing files in the
worktree.

I could have used GOT_WORKTREE_GOT_DIR (concatenated to the worktree
root path) but that would require to build a string and "./" saves us an
allocation :)

OK?

(while here I'm also fixing two typos in the regression suite spotted
thanks to the failure, i'll commit them separately from the patch.c
hunk)

diff e9ce266e31923cc339954b331d273d9bba543f6f /home/op/w/got
blob - 84226a57dca7da7a69187a76d804e8ceda7558ba
file + lib/patch.c
--- lib/patch.c
+++ lib/patch.c
@@ -419,8 +419,7 @@ apply_patch(struct got_worktree *worktree, struct got_
 		goto done;
 	}
 
-	err = got_opentemp_named(&tmppath, &tmp,
-	    got_worktree_get_root_path(worktree));
+	err = got_opentemp_named(&tmppath, &tmp, "./");
 	if (err)
 		goto done;
 
blob - cb9ff81d665f65b182c6a4ecb6bd3b4185b0ad6d
file + regress/cmdline/patch.sh
--- regress/cmdline/patch.sh
+++ regress/cmdline/patch.sh
@@ -248,7 +248,7 @@ EOF
 }
 
 test_patch_multiple_hunks() {
-	local testroot=`test_init patch_replace_multiple_lines`
+	local testroot=`test_init patch_replace_multiple_hunks`
 
 	got checkout $testroot/repo $testroot/wt > /dev/null
 	ret=$?
@@ -364,7 +364,7 @@ EOF
 	(cd $testroot/wt && got patch patch) > $testroot/stdout
 	ret=$?
 	if [ $ret != 0 ]; then
-		test_done $testrot $ret
+		test_done $testroot $ret
 		return 1
 	fi