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 @@ -560,6 +560,19 @@ test_expect_success 'fetch --atomic --append appends to FETCH_HEAD' '
560560 test_cmp expected atomic/.git/FETCH_HEAD
561561'
562562
563+ test_expect_success REFFILES ' fetch --atomic fails transaction if reference locked' '
564+ test_when_finished "rm -rf upstream repo" &&
565+
566+ git init upstream &&
567+ git -C upstream commit --allow-empty -m 1 &&
568+ git -C upstream switch -c foobar &&
569+ git clone --mirror upstream repo &&
570+ git -C upstream commit --allow-empty -m 2 &&
571+ touch repo/refs/heads/foobar.lock &&
572+
573+ test_must_fail git -C repo fetch --atomic origin
574+ '
575+
563576test_expect_success ' --refmap="" ignores configured refspec' '
564577 cd "$TRASH_DIRECTORY" &&
565578 git clone "$D" remote-refs &&
You can’t perform that action at this time.
0 commit comments