File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ impl Repository {
158
158
repo. remote_with_fetch (
159
159
name,
160
160
url,
161
- & format ! ( "refs/heads/master:refs/remotes/{}/master" , name) ,
161
+ & format ! ( "+ refs/heads/master:refs/remotes/{}/master" , name) ,
162
162
)
163
163
} )
164
164
. clone (
@@ -261,7 +261,11 @@ impl Repository {
261
261
let mut origin = self . repository . find_remote ( "origin" ) ?;
262
262
let original_head = self . head_oid ( ) ?;
263
263
origin. fetch (
264
- & [ "refs/heads/*:refs/heads/*" ] ,
264
+ // Force overwrite (`+` prefix) local master branch with the server's master branch.
265
+ // The git CLI will refuse to fetch into the current branch of a non-bare repo
266
+ // but libgit2 doesn't seem to prevent this potential footgun.
267
+ // The entire point is to do a hard reset, so this footgun is not a concern.
268
+ & [ "+refs/heads/master:refs/heads/master" ] ,
265
269
Some ( & mut Self :: fetch_options ( & self . credentials ) ) ,
266
270
None ,
267
271
) ?;
You can’t perform that action at this time.
0 commit comments