Commit Diff


commit - f69721c3fc6f5a7b7a11a49a1fd7a99182ef01f0
commit + 8b692cd00bf22ee0c1455a6d17590b0e2f207a87
blob - c4df32a19603acd84d6a098d33892f92581f2f71
blob + 3c6178de57a898b1c3c7be0e3585e0a5c40bb6bb
--- lib/worktree.c
+++ lib/worktree.c
@@ -5831,10 +5831,23 @@ got_worktree_integrate_abort(struct got_worktree *work
     struct got_fileindex *fileindex, struct got_repository *repo,
     struct got_reference *branch_ref, struct got_reference *base_branch_ref)
 {
+	const struct got_error *err = NULL, *unlockerr = NULL;
+
+	got_fileindex_free(fileindex);
+
+	err = lock_worktree(worktree, LOCK_SH);
+
+	unlockerr = got_ref_unlock(branch_ref);
+	if (unlockerr && err == NULL)
+		err = unlockerr;
 	got_ref_close(branch_ref);
+
+	unlockerr = got_ref_unlock(base_branch_ref);
+	if (unlockerr && err == NULL)
+		err = unlockerr;
 	got_ref_close(base_branch_ref);
-	got_fileindex_free(fileindex);
-	return lock_worktree(worktree, LOCK_SH);
+
+	return err;
 }
 
 struct check_stage_ok_arg {
blob - 35a98a41a609ebbd3f4945600522a843e17529f2
blob + 5c925e2030f9d146a0442dce5449d33e751b11f6
--- regress/cmdline/integrate.sh
+++ regress/cmdline/integrate.sh
@@ -220,6 +220,23 @@ function test_integrate_requires_rebase_first {
 	echo "commit $new_commit1" >> $testroot/stdout.expected
 	echo "commit $init_commit" >> $testroot/stdout.expected
 	cmp -s $testroot/stdout.expected $testroot/stdout
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		diff -u $testroot/stdout.expected $testroot/stdout
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	(cd $testroot/repo && got branch -l > $testroot/stdout)
+	ret="$?"
+	if [ "$ret" != "0" ]; then
+		echo "got rebase failed unexpectedly"
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	echo "  master: $master_commit" > $testroot/stdout.expected
+	echo "  newbranch: $new_commit2" >> $testroot/stdout.expected
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret="$?"
 	if [ "$ret" != "0" ]; then