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 @@ -1859,8 +1859,15 @@ static int do_fetch(struct transport *transport,
18591859 goto cleanup ;
18601860
18611861 retcode = ref_transaction_commit (transaction , & err );
1862- if (retcode )
1862+ if (retcode ) {
1863+ /*
1864+ * Explicitly handle transaction cleanup to avoid
1865+ * aborting an already closed transaction.
1866+ */
1867+ ref_transaction_free (transaction );
1868+ transaction = NULL ;
18631869 goto cleanup ;
1870+ }
18641871 }
18651872
18661873 commit_fetch_head (& fetch_head );
Original file line number Diff line number Diff line change @@ -537,6 +537,19 @@ test_expect_success 'fetch --atomic --append appends to FETCH_HEAD' '
537537 test_cmp expected atomic/.git/FETCH_HEAD
538538'
539539
540+ test_expect_success REFFILES ' fetch --atomic fails transaction if reference locked' '
541+ test_when_finished "rm -rf upstream repo" &&
542+
543+ git init upstream &&
544+ git -C upstream commit --allow-empty -m 1 &&
545+ git -C upstream switch -c foobar &&
546+ git clone --mirror upstream repo &&
547+ git -C upstream commit --allow-empty -m 2 &&
548+ touch repo/refs/heads/foobar.lock &&
549+
550+ test_must_fail git -C repo fetch --atomic origin
551+ '
552+
540553test_expect_success ' --refmap="" ignores configured refspec' '
541554 cd "$TRASH_DIRECTORY" &&
542555 git clone "$D" remote-refs &&
You can’t perform that action at this time.
0 commit comments