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,
1859
1859
goto cleanup ;
1860
1860
1861
1861
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 ;
1863
1869
goto cleanup ;
1870
+ }
1864
1871
}
1865
1872
1866
1873
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' '
537
537
test_cmp expected atomic/.git/FETCH_HEAD
538
538
'
539
539
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
+
540
553
test_expect_success ' --refmap="" ignores configured refspec' '
541
554
cd "$TRASH_DIRECTORY" &&
542
555
git clone "$D" remote-refs &&
You can’t perform that action at this time.
0 commit comments