Skip to content

Commit a38c3b8

Browse files
committed
Support for 'sdir' extension (#293)
It's really only a marker and it doesn't seem to matter much as not reading it won't matter for the entire git test suite. Nor does it matter when it's not written, and I wonder if a sparse checkout without a directory is even possible. In the latter case one would have to remember sparseness differently as there is no entry that could carry the 'sparse' file mode.
1 parent d8925f5 commit a38c3b8

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

git-bitmap/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ pub mod ewah {
5050
}
5151

5252
let (rlw, data) = decode::u32(data).ok_or(decode::Error::Corrupt("eof while reading run length width"))?;
53-
dbg!(rlw);
5453

5554
Ok((
5655
Vec {

git-index/src/decode/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,14 @@ impl State {
198198
let EntriesOutcome {
199199
entries,
200200
path_backing,
201-
is_sparse,
201+
mut is_sparse,
202202
} = entries;
203-
let extension::decode::Outcome { tree, link } = ext;
203+
let extension::decode::Outcome {
204+
tree,
205+
link,
206+
is_sparse: is_sparse_from_ext, // a marker is needed in case there are no directories
207+
} = ext;
208+
is_sparse |= is_sparse_from_ext;
204209

205210
Ok((
206211
State {

git-index/src/extension/decode.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ pub fn all(maybe_beginning_of_extensions: &[u8], object_hash: git_hash::Kind) ->
4141
extension::index_entry_offset_table::SIGNATURE => {} // not relevant/obtained already
4242
mandatory if mandatory[0].is_ascii_lowercase() => match mandatory {
4343
extension::link::SIGNATURE => ext.link = extension::link::decode(ext_data, object_hash)?.into(),
44+
extension::sparse::SIGNATURE => {
45+
if !ext_data.is_empty() {
46+
// only used as a marker, if this changes we need this implementation.
47+
return Err(Error::MandatoryUnimplemented(mandatory));
48+
}
49+
ext.is_sparse = true
50+
}
4451
unknown => return Err(Error::MandatoryUnimplemented(unknown)),
4552
},
4653
_unknown => {} // skip unknown extensions, too
@@ -53,4 +60,5 @@ pub fn all(maybe_beginning_of_extensions: &[u8], object_hash: git_hash::Kind) ->
5360
pub struct Outcome {
5461
pub tree: Option<extension::Tree>,
5562
pub link: Option<extension::Link>,
63+
pub is_sparse: bool,
5664
}

git-index/src/extension/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ pub(crate) mod end_of_index_entry;
3535

3636
pub(crate) mod index_entry_offset_table;
3737

38+
pub mod sparse {
39+
use crate::extension::Signature;
40+
41+
/// Only used as an indicator
42+
pub const SIGNATURE: Signature = *b"sdir";
43+
}
44+
3845
pub mod link {
3946
use crate::extension::{Link, Signature};
4047
use crate::util::split_at_pos;

0 commit comments

Comments
 (0)