Skip to content

Commit 7381f93

Browse files
committed
Format code, ci was failing
1 parent 96c6508 commit 7381f93

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed

src/index.rs

+50-43
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ fn try_raw_entries(
9393
entries: &[Option<&IndexEntry>],
9494
cb: impl FnOnce(&[*const raw::git_index_entry]) -> Result<(), Error>,
9595
) -> Result<(), Error> {
96-
let paths = entries.iter()
96+
let paths = entries
97+
.iter()
9798
.map(|entry| {
9899
if let Some(entry) = entry {
99100
CString::new(&entry.path[..]).map(|ok| Some(ok))
@@ -103,46 +104,51 @@ fn try_raw_entries(
103104
})
104105
.collect::<Result<Vec<Option<CString>>, std::ffi::NulError>>()?;
105106

106-
let raw_entries = entries.iter().zip(&paths).map(|(entry, path)| {
107-
if let Some(entry) = entry {
108-
// libgit2 encodes the length of the path in the lower bits of the
109-
// `flags` entry, so mask those out and recalculate here to ensure we
110-
// don't corrupt anything.
111-
let mut flags = entry.flags & !raw::GIT_INDEX_ENTRY_NAMEMASK;
112-
113-
if entry.path.len() < raw::GIT_INDEX_ENTRY_NAMEMASK as usize {
114-
flags |= entry.path.len() as u16;
107+
let raw_entries = entries
108+
.iter()
109+
.zip(&paths)
110+
.map(|(entry, path)| {
111+
if let Some(entry) = entry {
112+
// libgit2 encodes the length of the path in the lower bits of the
113+
// `flags` entry, so mask those out and recalculate here to ensure we
114+
// don't corrupt anything.
115+
let mut flags = entry.flags & !raw::GIT_INDEX_ENTRY_NAMEMASK;
116+
117+
if entry.path.len() < raw::GIT_INDEX_ENTRY_NAMEMASK as usize {
118+
flags |= entry.path.len() as u16;
119+
} else {
120+
flags |= raw::GIT_INDEX_ENTRY_NAMEMASK;
121+
}
122+
123+
unsafe {
124+
Some(raw::git_index_entry {
125+
dev: entry.dev,
126+
ino: entry.ino,
127+
mode: entry.mode,
128+
uid: entry.uid,
129+
gid: entry.gid,
130+
file_size: entry.file_size,
131+
id: *entry.id.raw(),
132+
flags,
133+
flags_extended: entry.flags_extended,
134+
path: path.as_ref().unwrap().as_ptr(),
135+
mtime: raw::git_index_time {
136+
seconds: entry.mtime.seconds(),
137+
nanoseconds: entry.mtime.nanoseconds(),
138+
},
139+
ctime: raw::git_index_time {
140+
seconds: entry.ctime.seconds(),
141+
nanoseconds: entry.ctime.nanoseconds(),
142+
},
143+
})
144+
}
115145
} else {
116-
flags |= raw::GIT_INDEX_ENTRY_NAMEMASK;
117-
}
118-
119-
unsafe {
120-
Some(raw::git_index_entry {
121-
dev: entry.dev,
122-
ino: entry.ino,
123-
mode: entry.mode,
124-
uid: entry.uid,
125-
gid: entry.gid,
126-
file_size: entry.file_size,
127-
id: *entry.id.raw(),
128-
flags,
129-
flags_extended: entry.flags_extended,
130-
path: path.as_ref().unwrap().as_ptr(),
131-
mtime: raw::git_index_time {
132-
seconds: entry.mtime.seconds(),
133-
nanoseconds: entry.mtime.nanoseconds(),
134-
},
135-
ctime: raw::git_index_time {
136-
seconds: entry.ctime.seconds(),
137-
nanoseconds: entry.ctime.nanoseconds(),
138-
},
139-
})
146+
None
140147
}
141-
} else {
142-
None
143-
}
144-
}).collect::<Vec<_>>();
145-
let raw_entry_ptrs = raw_entries.iter()
148+
})
149+
.collect::<Vec<_>>();
150+
let raw_entry_ptrs = raw_entries
151+
.iter()
146152
.map(|opt| opt.as_ref().map_or_else(std::ptr::null, |ptr| ptr))
147153
.collect::<Vec<_>>();
148154

@@ -426,17 +432,18 @@ impl Index {
426432
our_entry: Option<&IndexEntry>,
427433
their_entry: Option<&IndexEntry>,
428434
) -> Result<(), Error> {
429-
try_raw_entries(&[ancestor_entry, our_entry, their_entry], |raw_entries| {
430-
unsafe {
435+
try_raw_entries(
436+
&[ancestor_entry, our_entry, their_entry],
437+
|raw_entries| unsafe {
431438
try_call!(raw::git_index_conflict_add(
432439
self.raw,
433440
raw_entries[0],
434441
raw_entries[1],
435442
raw_entries[2]
436443
));
437444
Ok(())
438-
}
439-
})
445+
},
446+
)
440447
}
441448

442449
/// Remove all conflicts in the index (entries with a stage greater than 0).

0 commit comments

Comments
 (0)