File tree 5 files changed +30
-7
lines changed
5 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ pub fn update_head(
59
59
None => return Ok ( ( ) ) ,
60
60
} ;
61
61
62
- let name : git_ref:: FullName = "HEAD" . try_into ( ) . expect ( "valid" ) ;
62
+ let head : git_ref:: FullName = "HEAD" . try_into ( ) . expect ( "valid" ) ;
63
63
let reflog_message = || LogChange {
64
64
mode : RefLog :: AndReference ,
65
65
force_create_reflog : false ,
@@ -98,7 +98,7 @@ pub fn update_head(
98
98
expected : PreviousValue :: Any ,
99
99
new : Target :: Symbolic ( referent) ,
100
100
} ,
101
- name : name . clone ( ) ,
101
+ name : head . clone ( ) ,
102
102
deref : false ,
103
103
} ,
104
104
] ,
@@ -116,7 +116,7 @@ pub fn update_head(
116
116
expected : PreviousValue :: Any ,
117
117
new : Target :: Peeled ( head_peeled_id. to_owned ( ) ) ,
118
118
} ,
119
- name,
119
+ name : head ,
120
120
deref : false ,
121
121
} ) ?;
122
122
}
@@ -127,7 +127,7 @@ pub fn update_head(
127
127
expected : PreviousValue :: Any ,
128
128
new : Target :: Peeled ( head_peeled_id. to_owned ( ) ) ,
129
129
} ,
130
- name,
130
+ name : head ,
131
131
deref : false ,
132
132
} ) ?;
133
133
}
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ impl Source {
53
53
match self {
54
54
Source :: ObjectId ( _) => None ,
55
55
Source :: Ref ( r) => match r {
56
+ git_protocol:: fetch:: Ref :: Unborn { target : _ } => Some ( "HEAD" . into ( ) ) ,
56
57
git_protocol:: fetch:: Ref :: Symbolic { full_ref_name, .. }
57
58
| git_protocol:: fetch:: Ref :: Direct { full_ref_name, .. }
58
59
| git_protocol:: fetch:: Ref :: Peeled { full_ref_name, .. } => Some ( full_ref_name. as_ref ( ) ) ,
Original file line number Diff line number Diff line change @@ -193,19 +193,41 @@ mod blocking_io {
193
193
}
194
194
195
195
#[ test]
196
+ #[ ignore]
196
197
fn fetch_and_checkout_empty_remote_repo ( ) -> crate :: Result {
197
198
let tmp = git_testtools:: tempfile:: TempDir :: new ( ) ?;
198
199
let mut prepare = git:: prepare_clone (
199
200
git_testtools:: scripted_fixture_repo_read_only ( "make_empty_repo.sh" ) ?,
200
201
tmp. path ( ) ,
201
202
) ?;
202
- let ( mut checkout, _out ) = prepare
203
+ let ( mut checkout, out ) = prepare
203
204
. fetch_then_checkout ( git:: progress:: Discard , & std:: sync:: atomic:: AtomicBool :: default ( ) )
204
205
. unwrap ( ) ;
205
206
let ( repo, _) = checkout. main_worktree ( git:: progress:: Discard , & std:: sync:: atomic:: AtomicBool :: default ( ) ) ?;
206
207
207
208
assert ! ( !repo. index_path( ) . is_file( ) , "newly initialized repos have no index" ) ;
208
209
assert ! ( repo. head( ) ?. is_unborn( ) ) ;
210
+ if out
211
+ . ref_map
212
+ . handshake
213
+ . capabilities
214
+ . capability ( "ls-refs" )
215
+ . expect ( "has ls-refs" )
216
+ . supports ( "unborn" )
217
+ == Some ( true )
218
+ {
219
+ assert_eq ! (
220
+ repo. head( ) ?. referent_name( ) . expect( "present" ) . as_bstr( ) ,
221
+ "refs/heads/special" ,
222
+ "we pick up the name as present on the server, not the one we default to"
223
+ ) ;
224
+ } else {
225
+ assert_eq ! (
226
+ repo. head( ) ?. referent_name( ) . expect( "present" ) . as_bstr( ) ,
227
+ "refs/heads/main" ,
228
+ "we simply keep our own post-init HEAD which defaults to the branch name we configured locally"
229
+ ) ;
230
+ }
209
231
210
232
Ok ( ( ) )
211
233
}
Original file line number Diff line number Diff line change 1
1
version https://git-lfs.github.com/spec/v1
2
- oid sha256:8c88c509ad1df376844b8a80b003a01c78de79284c4b0cf72fe661ca41f6d303
2
+ oid sha256:875f0aa4a343935bc881d6c595efffeb34063a460239178cf2264e5e44163c2d
3
3
size 9068
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -eu -o pipefail
3
3
4
- git init -q
4
+ git -c init.defaultBranch=special init -q
You can’t perform that action at this time.
0 commit comments