Skip to content

Commit 166666a

Browse files
author
fossdd
committed
Update pijul
1 parent 0c90829 commit 166666a

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

libpijul/src/working_copy/filesystem.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct FileSystem {
1010
root: PathBuf,
1111
}
1212

13+
/// Returns whether `path` is a child of `root_` (or `root_` itself).
1314
pub fn filter_ignore(root_: &CanonicalPath, path: &CanonicalPath, is_dir: bool) -> bool {
1415
debug!("path = {:?} root = {:?}", path, root_);
1516
if let Ok(suffix) = path.as_path().strip_prefix(root_.as_path()) {
@@ -165,6 +166,7 @@ impl FileSystem {
165166
state: &mut crate::RecordBuilder,
166167
repo_path: CanonicalPathBuf,
167168
prefixes: &[P],
169+
force: bool,
168170
threads: usize,
169171
salt: u64,
170172
) -> Result<(), Error<C::Error, T>>
@@ -179,6 +181,7 @@ impl FileSystem {
179181
state,
180182
repo_path.clone(),
181183
prefix.as_ref(),
184+
force,
182185
threads,
183186
salt,
184187
)?
@@ -191,6 +194,7 @@ impl FileSystem {
191194
state,
192195
repo_path.clone(),
193196
Path::new(""),
197+
force,
194198
threads,
195199
salt,
196200
)?
@@ -203,11 +207,12 @@ impl FileSystem {
203207
txn: &ArcTxn<T>,
204208
repo_path: CanonicalPathBuf,
205209
full: CanonicalPathBuf,
210+
force: bool,
206211
threads: usize,
207212
salt: u64,
208213
) -> Result<(), AddError<T>> {
209214
let mut txn = txn.write();
210-
for p in self.iterate_prefix_rec(repo_path.clone(), full.clone(), threads)? {
215+
for p in self.iterate_prefix_rec(repo_path.clone(), full.clone(), force, threads)? {
211216
let (path, is_dir) = p?;
212217
info!("Adding {:?}", path);
213218
use path_slash::PathExt;
@@ -228,6 +233,7 @@ impl FileSystem {
228233
&self,
229234
repo_path: CanonicalPathBuf,
230235
full: CanonicalPathBuf,
236+
force: bool,
231237
threads: usize,
232238
) -> Result<Untracked, std::io::Error> {
233239
debug!("full = {:?}", full);
@@ -236,21 +242,24 @@ impl FileSystem {
236242
let (sender, receiver) = std::sync::mpsc::sync_channel(100);
237243

238244
debug!("{:?}", full.as_path().strip_prefix(repo_path.as_path()));
239-
if !filter_ignore(
240-
&repo_path.as_canonical_path(),
241-
&full.as_canonical_path(),
242-
meta.is_dir(),
243-
) {
244-
return Ok(Untracked {
245-
join: None,
246-
receiver,
247-
});
245+
debug!("force = {:?}", force);
246+
if !force {
247+
if !filter_ignore(
248+
&repo_path.as_canonical_path(),
249+
&full.as_canonical_path(),
250+
meta.is_dir(),
251+
) {
252+
return Ok(Untracked {
253+
join: None,
254+
receiver,
255+
});
256+
}
248257
}
249258
let t = std::thread::spawn(move || -> Result<(), std::io::Error> {
250259
if meta.is_dir() {
251260
let mut walk = WalkBuilder::new(&full);
252-
walk.ignore(true)
253-
.git_ignore(true)
261+
walk.ignore(!force)
262+
.git_ignore(!force)
254263
.hidden(false)
255264
.filter_entry(|p| {
256265
debug!("p.file_name = {:?}", p.file_name());
@@ -310,6 +319,7 @@ impl FileSystem {
310319
state: &mut crate::RecordBuilder,
311320
repo_path: CanonicalPathBuf,
312321
prefix: &Path,
322+
force: bool,
313323
threads: usize,
314324
salt: u64,
315325
) -> Result<(), Error<C::Error, T>>
@@ -322,7 +332,7 @@ impl FileSystem {
322332
use path_slash::PathExt;
323333
let path_str = path.to_slash_lossy();
324334
if !crate::fs::is_tracked(&*txn.read(), &path_str)? {
325-
self.add_prefix_rec(&txn, repo_path, full, threads, salt)?;
335+
self.add_prefix_rec(&txn, repo_path, full, force, threads, salt)?;
326336
}
327337
}
328338
}

pijul/src/commands/diff.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ impl Diff {
8484
&mut state,
8585
CanonicalPathBuf::canonicalize(&repo.path)?,
8686
&self.prefixes,
87+
false,
8788
num_cpus::get(),
8889
0,
8990
)?;
@@ -356,7 +357,7 @@ fn untracked<'a, T: TxnTExt>(
356357
let threads = num_cpus::get();
357358
Ok(repo
358359
.working_copy
359-
.iterate_prefix_rec(repo_path.clone(), repo_path.clone(), threads)?
360+
.iterate_prefix_rec(repo_path.clone(), repo_path.clone(), false, threads)?
360361
.filter_map(move |x| {
361362
let (path, _) = x.unwrap();
362363
use path_slash::PathExt;

pijul/src/commands/file_operations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ impl Add {
145145
&txn,
146146
repo_path.clone(),
147147
full.clone(),
148+
self.force,
148149
threads,
149150
self.salt.unwrap_or(0),
150151
)?

pijul/src/commands/git.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ fn record_apply<
743743
&mut state,
744744
repo_path.clone(),
745745
p,
746+
false,
746747
num_cpus,
747748
0,
748749
) {
@@ -764,6 +765,7 @@ fn record_apply<
764765
&mut state,
765766
repo_path.clone(),
766767
Path::new(""),
768+
false,
767769
num_cpus,
768770
0,
769771
) {

pijul/src/commands/record.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ impl Record {
338338
&mut state,
339339
repo_path,
340340
&self.prefixes,
341+
false,
341342
1, // num_cpus::get(),
342343
self.timestamp.unwrap_or(0) as u64,
343344
)?;

0 commit comments

Comments
 (0)