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

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: three bugs related to merge commits
To:
James Cook <falsifian@falsifian.org>, gameoftrees@openbsd.org
Date:
Mon, 17 Apr 2023 00:38:41 +1000

Download raw body.

Thread
On 23-04-17 12:02AM, Mark Jamsek wrote:
> On 23-04-16 10:43PM, Mark Jamsek wrote:
> > On 23-04-16 10:40PM, Mark Jamsek wrote:
> > > On 23-04-14 03:52PM, Stefan Sperling wrote:
> > > > On Mon, Mar 13, 2023 at 12:01:42AM +0000, James Cook wrote:
> > > > > I recently noticed the following bugs. I just verified that they still
> > > > > happen with the lastest got, commit 264c43dd.
> > > > > 
> > > > > Two of them have scripts to reproduce; the other's pretty simple.
> > > >  
> > > > I would like to fix these issues but haven't found time to take
> > > > a closer look yet, sorry.
> > > 
> 
> In regards to the first two bugs, the second branch and merge commit
> appear to be a red herring: simply committing to main in another work
> tree has the same effect:

No luck debugging this yet, but here's a quick regress test:

diff /home/mark/src/got
commit - e1dd38749cb5548ac21464ee05e4a3a492c7add1
path + /home/mark/src/got
blob - 26a31c050dfc034e8c024f4e945dafbc2d72cf28
file + regress/cmdline/commit.sh
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
@@ -2077,6 +2077,40 @@ test_parseargs "$@"
 	test_done "$testroot" "$ret"
 }
 
+test_commit_from_different_worktrees() {
+	local testroot=$(test_init commit_from_different_worktrees)
+
+	got checkout $testroot/repo $testroot/wt > /dev/null
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	got checkout $testroot/repo $testroot/wt2 > /dev/null
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "new file" > $testroot/wt2/new
+	(cd $testroot/wt2 && got add new >/dev/null)
+	(cd $testroot/wt2 && got commit -m 'add new file from wt2' > \
+	    $testroot/stdout)
+	local wt2_head_id=$(git_show_head $testroot/repo)
+
+	echo "modified alpha" > $testroot/wt/alpha
+	(cd $testroot/wt && got commit -m 'mod alpha in wt' > $testroot/stdout)
+	local wt1_parent_id=$(git_show_parent_commit $testroot/repo)
+
+	if [ $wt2_head_id != $wt1_parent_id ]; then
+		ret="xfail: commit lost from different work tree"
+	fi
+
+	test_done "$testroot" "$ret"
+}
+
 test_parseargs "$@"
 run_test test_commit_basic
 run_test test_commit_new_subdir
@@ -2108,3 +2142,4 @@ run_test test_commit_logmsg_ref
 run_test test_commit_gitignore
 run_test test_commit_bad_author
 run_test test_commit_logmsg_ref
+run_test test_commit_from_different_worktrees

-- 
Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68