File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1844,8 +1844,15 @@ static int do_fetch(struct transport *transport,
18441844 goto cleanup ;
18451845
18461846 retcode = ref_transaction_commit (transaction , & err );
1847- if (retcode )
1847+ if (retcode ) {
1848+ /*
1849+ * Explicitly handle transaction cleanup to avoid
1850+ * aborting an already closed transaction.
1851+ */
1852+ ref_transaction_free (transaction );
1853+ transaction = NULL ;
18481854 goto cleanup ;
1855+ }
18491856 }
18501857
18511858 commit_fetch_head (& fetch_head );
Original file line number Diff line number Diff line change @@ -554,6 +554,19 @@ test_expect_success 'fetch --atomic --append appends to FETCH_HEAD' '
554554 test_cmp expected atomic/.git/FETCH_HEAD
555555'
556556
557+ test_expect_success REFFILES ' fetch --atomic fails transaction if reference locked' '
558+ test_when_finished "rm -rf upstream repo" &&
559+
560+ git init upstream &&
561+ git -C upstream commit --allow-empty -m 1 &&
562+ git -C upstream switch -c foobar &&
563+ git clone --mirror upstream repo &&
564+ git -C upstream commit --allow-empty -m 2 &&
565+ touch repo/refs/heads/foobar.lock &&
566+
567+ test_must_fail git -C repo fetch --atomic origin
568+ '
569+
557570test_expect_success ' --refmap="" ignores configured refspec' '
558571 cd "$TRASH_DIRECTORY" &&
559572 git clone "$D" remote-refs &&
You can’t perform that action at this time.
0 commit comments