remove lock files, as intended, when reintegrate gets aborted
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/lib/worktree.c b/lib/worktree.c
index c4df32a..3c6178d 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -5831,10 +5831,23 @@ got_worktree_integrate_abort(struct got_worktree *worktree,
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 {
diff --git a/regress/cmdline/integrate.sh b/regress/cmdline/integrate.sh
index 35a98a4..5c925e2 100755
--- a/regress/cmdline/integrate.sh
+++ b/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