File tree 3 files changed +17
-21
lines changed
3 files changed +17
-21
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,6 @@ impl PrepareFetch {
41
41
/// it was newly initialized.
42
42
///
43
43
/// Note that all data we created will be removed once this instance drops if the operation wasn't successful.
44
- ///
45
- /// # Deviation
46
- ///
47
- /// When the remote side is freshly initialized without commits, we pick up their reference name _and_ create a reflog entry like
48
- /// before, with old and new hash being the `null-hex-sha`. That way the branch still remembers where it was created from.
49
44
#[ cfg( feature = "blocking-network-client" ) ]
50
45
pub fn fetch_only < P > (
51
46
& mut self ,
Original file line number Diff line number Diff line change @@ -117,20 +117,19 @@ pub fn update_head(
117
117
. commit ( repo. committer_or_default ( ) )
118
118
. map_err ( crate :: reference:: edit:: Error :: from) ?;
119
119
120
- let mut log = reflog_message ( ) ;
121
- log. mode = RefLog :: Only ;
122
- repo. edit_reference ( RefEdit {
123
- change : git_ref:: transaction:: Change :: Update {
124
- log,
125
- expected : PreviousValue :: Any ,
126
- new : Target :: Peeled ( match head_peeled_id {
127
- Some ( id) => id. to_owned ( ) ,
128
- None => git_hash:: ObjectId :: null ( repo. object_hash ( ) ) ,
129
- } ) ,
130
- } ,
131
- name : head,
132
- deref : false ,
133
- } ) ?;
120
+ if let Some ( head_peeled_id) = head_peeled_id {
121
+ let mut log = reflog_message ( ) ;
122
+ log. mode = RefLog :: Only ;
123
+ repo. edit_reference ( RefEdit {
124
+ change : git_ref:: transaction:: Change :: Update {
125
+ log,
126
+ expected : PreviousValue :: Any ,
127
+ new : Target :: Peeled ( * head_peeled_id) ,
128
+ } ,
129
+ name : head,
130
+ deref : false ,
131
+ } ) ?;
132
+ }
134
133
}
135
134
None => {
136
135
repo. edit_reference ( RefEdit {
Original file line number Diff line number Diff line change @@ -208,8 +208,10 @@ mod blocking_io {
208
208
let head = repo. head ( ) ?;
209
209
assert ! ( head. is_unborn( ) ) ;
210
210
211
- let mut logs = head. log_iter ( ) ;
212
- assert_reflog ( logs. all ( ) ) ;
211
+ assert ! (
212
+ head. log_iter( ) . all( ) ?. is_none( ) ,
213
+ "no reflog for unborn heads (as it needs non-null destination hash)"
214
+ ) ;
213
215
214
216
if out
215
217
. ref_map
You can’t perform that action at this time.
0 commit comments