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

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: stop got diff from lying in mixed-commit work trees
To:
Mark Jamsek <mark@jamsek.com>
Cc:
gameoftrees@openbsd.org
Date:
Sun, 24 Nov 2024 16:55:01 +1100

Download raw body.

Thread
Mark Jamsek <mark@jamsek.com> wrote:
> stsp pointed out on IRC that got diff can lie in mixed-commit work trees
> as only the work tree base commit is emitted at the top of the diff; as
> such, users could reasonably infer that the same base commit id applies
> to all files in the diff. This is not true in mixed-commit work trees.
> 
> After discussing this with op and stsp, we decided to emit each file's
> base commit in its diff header, rather than just emit the work tree's
> base commit once. This requires some regress churn but not nearly as
> much as anticipated. The bonus is got patch already does the right
> thing by parsing the new commit header so it requires no changes :)
> 
> Apart from the mechanical relocation and addition of the commit header
> in the changes to the test harness, only one patch test needed changing
> as we now show the file's true base commit in conflict markers. I've
> also added a new test to got diff regress to cover this change.
> 
> This is what mixed-commit work tree diffs look like (observe the new
> commit - $basecommit line above each blob - line in all file headers):
> 
> [[
> 	diff /tmp/got-test-diff_mixed_worktree-xQKZURYe9K/wt
> 	path + /tmp/got-test-diff_mixed_worktree-xQKZURYe9K/wt
> 	commit - 400880623c67bcd21fc38e5ce5a39382f7249634
> 	blob - 459809db67d164c738cac58282b2e3426b6aaa33
> 	file + alpha
> 	--- alpha
> 	+++ alpha
> 	@@ -1 +1 @@
> 	-'alpha
> 	+alpha
> 	commit - b1efe2d25322d0c819fe57ec7b244feb4fd90569
> 	blob - 65b2df87f7df3aeedef04be96703e55ac19c2cfb
> 	file + beta
> 	--- beta
> 	+++ beta
> 	@@ -1 +1 @@
> 	-beta
> 	+'beta
> 	commit - 852030ab7b6d55b358767cd71b4be3cdb6ad6154
> 	blob - /dev/null
> 	file + new (mode 644)
> 	--- /dev/null
> 	+++ new
> 	@@ -0,0 +1 @@
> 	+new
> ]]

Diff rebased on top of HEAD :)

If we're going ahead with this change, I'd like it to land before the
gotwebd test harness to save some churn as this will likely change the
diff output there too.


commit 94f61d680a7a5cc30356f80dcdca6c4c657cfdd9 (diffheader)
from: Mark Jamsek <mark@jamsek.dev>
date: Sun Nov 24 05:15:47 2024 UTC

discern mixed-commit worktree diffs with commit header

Instead of emitting the work tree's base commit in the diff's topmost
header, which is misleading in mixed-commit work trees, emit each file's
base commit in its diff header. Suggested by stsp and discussed with op
and stsp on IRC.

M  got/got.c                   |   32+   4-
M  regress/cmdline/diff.sh     |  137+  15-
M  regress/cmdline/patch.sh    |    3+   1-
M  regress/cmdline/revert.sh   |    3+   3-
M  regress/cmdline/stage.sh    |   24+  11-
M  regress/cmdline/unstage.sh  |   10+   9-
M  regress/cmdline/update.sh   |    1+   1-

7 files changed, 210 insertions(+), 44 deletions(-)

commit - b68e64b1d55c9b06ac807e265083267f655ad65c
commit + 94f61d680a7a5cc30356f80dcdca6c4c657cfdd9
blob - f890b946e6565aa7acf7271c37921844fa902230
blob + 0f45835af753a3a6807444c2dc3b9b7127d0dda6
--- got/got.c
+++ got/got.c
@@ -5061,6 +5061,34 @@ done:
 }
 
 static const struct got_error *
+emit_base_commit_header(FILE *f, struct got_object_id *commit_id,
+    struct got_worktree *worktree)
+{
+	const struct got_error	*err;
+	struct got_object_id	*base_commit_id;
+	char			*base_commit_idstr;
+
+	if (worktree == NULL)	/* shouldn't happen */
+		return got_error(GOT_ERR_NOT_WORKTREE);
+
+	base_commit_id = got_worktree_get_base_commit_id(worktree);
+
+	if (commit_id != NULL) {
+		if (got_object_id_cmp(commit_id, base_commit_id) != 0)
+			base_commit_id = commit_id;
+	}
+
+	err = got_object_id_str(&base_commit_idstr, base_commit_id);
+	if (err != NULL)
+		return err;
+
+	if (fprintf(f, "commit - %s\n", base_commit_idstr) < 0)
+		err = got_error_from_errno("fprintf");
+	free(base_commit_idstr);
+	return err;
+}
+
+static const struct got_error *
 print_diff(void *arg, unsigned char status, unsigned char staged_status,
     const char *path, struct got_object_id *blob_id,
     struct got_object_id *staged_blob_id, struct got_object_id *commit_id,
@@ -5109,10 +5137,6 @@ print_diff(void *arg, unsigned char status, unsigned c
 			err = got_error_from_errno("fprintf");
 			goto done;
 		}
-		if (fprintf(a->outfile, "commit - %s\n", a->id_str) < 0) {
-			err = got_error_from_errno("fprintf");
-			goto done;
-		}
 		if (fprintf(a->outfile, "path + %s%s\n",
 		    got_worktree_get_root_path(a->worktree),
 		    a->diff_staged ? " (staged changes)" : "") < 0) {
@@ -5122,6 +5146,10 @@ print_diff(void *arg, unsigned char status, unsigned c
 		a->header_shown = 1;
 	}
 
+	err = emit_base_commit_header(a->outfile, commit_id, a->worktree);
+	if (err != NULL)
+		goto done;
+
 	if (a->diff_staged) {
 		const char *label1 = NULL, *label2 = NULL;
 		switch (staged_status) {
blob - 79d34d5be8de2f8a77dd949ec12828120cf67461
blob + 1c2391cef1211e8f745596a22c4944873f497779
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
@@ -34,8 +34,8 @@ test_diff_basic() {
 	(cd $testroot/wt && got add new >/dev/null)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -45,6 +45,7 @@ test_diff_basic() {
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-alpha' >> $testroot/stdout.expected
 	echo '+modified alpha' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -53,6 +54,7 @@ test_diff_basic() {
 	echo '+++ /dev/null' >> $testroot/stdout.expected
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-beta' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -119,8 +121,8 @@ test_diff_basic() {
 
 	# diff several paths in a work tree
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -130,6 +132,7 @@ test_diff_basic() {
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-alpha' >> $testroot/stdout.expected
 	echo '+modified alpha' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -138,6 +141,7 @@ test_diff_basic() {
 	echo '+++ /dev/null' >> $testroot/stdout.expected
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-beta' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i epsilon | grep 'zeta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -147,6 +151,7 @@ test_diff_basic() {
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-zeta' >> $testroot/stdout.expected
 	echo '+modified zeta' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -266,14 +271,15 @@ test_diff_basic() {
 		return 1
 	fi
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + master (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
 	echo '+++ master' >> $testroot/stdout.expected
 	echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
 	echo '+master' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -308,8 +314,8 @@ test_diff_basic() {
 
 	# a single argument which can be resolved to a path is not ambiguous
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -362,8 +368,8 @@ test_diff_basic() {
 	fi
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -475,8 +481,8 @@ test_diff_shows_conflict() {
 	fi
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'numbers$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -665,8 +671,8 @@ test_diff_ignore_whitespace() {
 	(cd $testroot/wt && got diff -w > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id0" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id0" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -744,8 +750,8 @@ test_diff_symlinks_in_work_tree() {
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id1" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id1" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -c $commit_id1 -i | \
 		grep 'alpha.link@ -> alpha$' | \
@@ -758,6 +764,7 @@ test_diff_symlinks_in_work_tree() {
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+beta' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $commit_id1" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -c $commit_id1 -i | \
 		grep 'dotgotfoo.link@ -> .got/foo$' | \
@@ -770,6 +777,7 @@ test_diff_symlinks_in_work_tree() {
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+.got/bar' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $commit_id1" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
 		grep 'beta.link@ -> ../beta$' | \
@@ -782,6 +790,7 @@ test_diff_symlinks_in_work_tree() {
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+../gamma/delta' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $commit_id1" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -c $commit_id1 -i | \
 		grep 'epsilon.link@ -> epsilon$' | \
@@ -794,6 +803,7 @@ test_diff_symlinks_in_work_tree() {
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+gamma' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $commit_id1" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -c $commit_id1 -i | \
 		grep 'nonexistent.link@ -> nonexistent$' | \
@@ -804,6 +814,7 @@ test_diff_symlinks_in_work_tree() {
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-nonexistent' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $commit_id1" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + zeta.link (mode 120000)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -954,8 +965,8 @@ test_diff_binary_files() {
 	(cd $testroot/wt && got add foo >/dev/null)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + foo (mode 644)' >> $testroot/stdout.expected
 	echo "Binary files /dev/null and foo differ" \
@@ -971,8 +982,8 @@ test_diff_binary_files() {
 	fi
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + foo (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -996,8 +1007,8 @@ test_diff_binary_files() {
 	printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -1364,8 +1375,8 @@ test_diff_worktree_newfile_xbit() {
 	local commit_id=`git_show_head $testroot/repo`
 	cat <<EOF > $testroot/stdout.expected
 diff $testroot/wt
-commit - $commit_id
 path + $testroot/wt
+commit - $commit_id
 blob - /dev/null
 file + xfile (mode 755)
 --- /dev/null
@@ -1604,8 +1615,8 @@ diffstat $testroot/wt
 EOF
 
 	echo "diff $testroot/wt" >> $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -1615,6 +1626,7 @@ EOF
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-alpha' >> $testroot/stdout.expected
 	echo '+modified alpha' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -1623,6 +1635,7 @@ EOF
 	echo '+++ /dev/null' >> $testroot/stdout.expected
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-beta' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -1654,8 +1667,8 @@ EOF
 
 	# specify paths to diffstat
 	echo "diff $testroot/wt" >> $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -1665,6 +1678,7 @@ EOF
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-alpha' >> $testroot/stdout.expected
 	echo '+modified alpha' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -1673,6 +1687,7 @@ EOF
 	echo '+++ /dev/null' >> $testroot/stdout.expected
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-beta' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i epsilon | grep 'zeta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -1682,6 +1697,7 @@ EOF
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-zeta' >> $testroot/stdout.expected
 	echo '+modified zeta' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -1736,14 +1752,15 @@ diffstat $testroot/wt
 EOF
 
 	echo "diff $testroot/wt" >> $testroot/stdout.expected
-	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + master (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
 	echo '+++ master' >> $testroot/stdout.expected
 	echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
 	echo '+master' >> $testroot/stdout.expected
+	echo "commit - $head_rev" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + new (mode 644)' >> $testroot/stdout.expected
 	echo '--- /dev/null' >> $testroot/stdout.expected
@@ -2267,6 +2284,110 @@ test_diff_commit_keywords() {
 	test_done "$testroot" "$ret"
 }
 
+test_diff_mixed_worktree() {
+	local testroot=$(test_init diff_mixed_worktree)
+	local baseid_beta=$(git_show_head $testroot/repo)
+
+	got checkout $testroot/repo $testroot/wt > /dev/null
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "'alpha" > $testroot/wt/alpha
+	(cd $testroot/wt && got commit -m "'alpha" > /dev/null)
+
+	local baseid_alpha=$(git_show_head $testroot/repo)
+
+	echo "'delta" > $testroot/wt/gamma/delta
+	(cd $testroot/wt && got commit -m "'delta" > /dev/null)
+
+	local baseid_new=$(git_show_head $testroot/repo)
+	local blobid_alpha=$(get_blob_id $testroot/repo "" alpha)
+	local blobid_beta=$(get_blob_id $testroot/repo "" beta)
+
+	echo "alpha" > $testroot/wt/alpha
+	echo "'beta" > $testroot/wt/beta
+	echo "new" > $testroot/wt/new
+
+	(cd $testroot/wt && got add new > /dev/null)
+
+	cat <<-EOF >$testroot/stdout.expected
+	diff $testroot/wt
+	path + $testroot/wt
+	commit - $baseid_alpha
+	blob - $blobid_alpha
+	file + alpha
+	--- alpha
+	+++ alpha
+	@@ -1 +1 @@
+	-'alpha
+	+alpha
+	commit - $baseid_beta
+	blob - $blobid_beta
+	file + beta
+	--- beta
+	+++ beta
+	@@ -1 +1 @@
+	-beta
+	+'beta
+	commit - $baseid_new
+	blob - /dev/null
+	file + new (mode 644)
+	--- /dev/null
+	+++ new
+	@@ -0,0 +1 @@
+	+new
+	EOF
+
+	(cd $testroot/wt && got diff > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	(cd $testroot/wt && got stage alpha beta > $testroot/stdout)
+
+	stageid_alpha=$(cd $testroot/wt && got stage -l alpha | cut -d' ' -f 1)
+	stageid_beta=$(cd $testroot/wt && got stage -l beta | cut -d' ' -f 1)
+
+	cat <<-EOF >$testroot/stdout.expected
+	diff -s $testroot/wt
+	path + $testroot/wt (staged changes)
+	commit - $baseid_alpha
+	blob - $blobid_alpha
+	blob + $stageid_alpha
+	--- alpha
+	+++ alpha
+	@@ -1 +1 @@
+	-'alpha
+	+alpha
+	commit - $baseid_beta
+	blob - $blobid_beta
+	blob + $stageid_beta
+	--- beta
+	+++ beta
+	@@ -1 +1 @@
+	-beta
+	+'beta
+	EOF
+
+	(cd $testroot/wt && got diff -s > $testroot/stdout)
+	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	test_done "$testroot" 0
+}
+
 test_parseargs "$@"
 run_test test_diff_basic
 run_test test_diff_shows_conflict
@@ -2287,3 +2408,4 @@ run_test test_diff_file_to_dir
 run_test test_diff_dir_to_file
 run_test test_diff_path_in_root_commit
 run_test test_diff_commit_keywords
+run_test test_diff_mixed_worktree
blob - 884ba874302b4e95327b6a03d633122a2757442a
blob + 66b8ac0292d449f916eeb70817e844ea1710dd4b
--- regress/cmdline/patch.sh
+++ regress/cmdline/patch.sh
@@ -1577,6 +1577,8 @@ test_patch_merge_conflict() {
 		return 1
 	fi
 
+	local alpha_basecommit_id=`git_show_head $testroot/repo`
+
 	seq 10 > $testroot/wt/numbers
 	(cd $testroot/wt && got add numbers && got commit -m +numbers) \
 		> /dev/null
@@ -1634,7 +1636,7 @@ test_patch_merge_conflict() {
 	cat <<-EOF > $testroot/wt/alpha.expected
 	<<<<<<< --- alpha
 	ALPHA
-	||||||| commit $commit_id
+	||||||| commit $alpha_basecommit_id
 	alpha
 	=======
 	a
blob - 011e20bae0544b37165ccaf2b12d702d4869e2f0
blob + cc12859f70df97800a252ad662cc906397252208
--- regress/cmdline/revert.sh
+++ regress/cmdline/revert.sh
@@ -566,8 +566,8 @@ EOF
 	fi
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -669,8 +669,8 @@ EOF
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -739,8 +739,8 @@ EOF
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
blob - 001262301f5016d81a6b4944240cc53a7e8a0144
blob + 1ad08eac94cab7500e0e8b85dc6c499f05700a6b
--- regress/cmdline/stage.sh
+++ regress/cmdline/stage.sh
@@ -934,8 +934,8 @@ test_stage_diff() {
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
 		>> $testroot/stdout.expected
@@ -946,6 +946,7 @@ test_stage_diff() {
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-modified file' >> $testroot/stdout.expected
 	echo '+modified file again' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
 		>> $testroot/stdout.expected
@@ -968,8 +969,8 @@ test_stage_diff() {
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -981,6 +982,7 @@ test_stage_diff() {
 	echo '@@ -1 +1 @@' >> $testroot/stdout.expected
 	echo '-alpha' >> $testroot/stdout.expected
 	echo '+modified file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -989,6 +991,7 @@ test_stage_diff() {
 	echo '+++ /dev/null' >> $testroot/stdout.expected
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-beta' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo -n 'blob + ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
@@ -1595,8 +1598,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -1702,8 +1705,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -1857,8 +1860,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -1896,8 +1899,8 @@ EOF
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
 		tr -d '\n' >> $testroot/stdout.expected
@@ -1963,8 +1966,8 @@ test_stage_patch_added() {
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo -n 'blob + ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
@@ -2088,8 +2091,8 @@ test_stage_patch_removed() {
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -2310,8 +2313,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -2507,8 +2510,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -2522,6 +2525,7 @@ EOF
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+beta' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo -n 'blob + ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l dotgotbar.link) | cut -d' ' -f 1 \
@@ -2531,6 +2535,7 @@ EOF
 	echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
 	echo '+.got/bar' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo -n 'blob + ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
@@ -2539,6 +2544,7 @@ EOF
 	echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
 	echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
 	echo '+this is regular file foo' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i epsilon | grep 'beta.link@ -> ../beta$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -2552,6 +2558,7 @@ EOF
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+../gamma/delta' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -2565,6 +2572,7 @@ EOF
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+gamma' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -2574,6 +2582,7 @@ EOF
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-nonexistent' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo -n 'blob + ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
@@ -2832,8 +2841,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -2847,6 +2856,7 @@ EOF
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+beta' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo -n 'blob + ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
@@ -2855,6 +2865,7 @@ EOF
 	echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
 	echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
 	echo '+this is regular file foo' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -2868,6 +2879,7 @@ EOF
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
 	echo '+gamma' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
 		cut -d' ' -f 1 >> $testroot/stdout.expected
@@ -2877,6 +2889,7 @@ EOF
 	echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
 	echo '-nonexistent' >> $testroot/stdout.expected
 	echo '\ No newline at end of file' >> $testroot/stdout.expected
+	echo "commit - $head_commit" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo -n 'blob + ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
blob - 6bb970784b5cf067c17b918409a825a1287df1e1
blob + 1f9c74b96419ec6eda2b937ea04a8b7cae1c8e5f
--- regress/cmdline/unstage.sh
+++ regress/cmdline/unstage.sh
@@ -409,8 +409,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -445,8 +445,8 @@ EOF
 
 	(cd $testroot/wt && got diff > $testroot/stdout)
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1  | \
 		tr -d '\n' >> $testroot/stdout.expected
@@ -554,8 +554,8 @@ EOF
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -590,8 +590,8 @@ EOF
 
 	(cd $testroot/wt && got diff > $testroot/stdout)
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
 		tr -d '\n' >> $testroot/stdout.expected
@@ -706,8 +706,8 @@ EOF
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -799,8 +799,8 @@ test_unstage_patch_added() {
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo 'blob - /dev/null' >> $testroot/stdout.expected
 	echo 'file + epsilon/new (mode 644)' >> $testroot/stdout.expected
 	echo "--- /dev/null" >> $testroot/stdout.expected
@@ -867,8 +867,8 @@ test_unstage_patch_removed() {
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
@@ -972,8 +972,8 @@ EOF
 	(cd $testroot/wt && got diff > $testroot/stdout)
 
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	(cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
 		tr -d '\n' >> $testroot/stdout.expected
@@ -998,8 +998,8 @@ EOF
 
 	(cd $testroot/wt && got diff -s > $testroot/stdout)
 	echo "diff -s $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i -c $commit_id \
 		| grep 'numbers$' | cut -d' ' -f 1 \
@@ -1026,6 +1026,7 @@ EOF
 -16
 +c
 EOF
+	echo "commit - $commit_id" >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'zzz$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected
blob - 013d85e1d4cf6d156380290afdb9ab2e51598e63
blob + cd31d1db006846950774ef96be6c8beec4cc3f4e
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
@@ -1178,8 +1178,8 @@ test_update_conflict_wt_rm_vs_repo_edit() {
 	# 'got diff' should show post-update contents of beta being deleted
 	local head_rev=`git_show_head $testroot/repo`
 	echo "diff $testroot/wt" > $testroot/stdout.expected
-	echo "commit - $head_rev"  >> $testroot/stdout.expected
 	echo "path + $testroot/wt" >> $testroot/stdout.expected
+	echo "commit - $head_rev"  >> $testroot/stdout.expected
 	echo -n 'blob - ' >> $testroot/stdout.expected
 	got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
 		>> $testroot/stdout.expected



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