Skip to content

Commit 79110ee

Browse files
committed
renaming
felt things weren't fully qualified
1 parent 290f81f commit 79110ee

10 files changed

Lines changed: 57 additions & 33 deletions

File tree

‎asyncgit/src/sync/branch/mod.rs‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub fn checkout_branch(
342342
repo.set_head(branch_ref_name?)?;
343343

344344
// Smudge LFS pointer files with real content from the local LFS store.
345-
if let Err(e) = super::lfs::large_file_storage_smudge_tree(
345+
if let Err(e) = super::lfs::smudge_tree(
346346
&repo,
347347
&target_tree,
348348
previous_tree.as_ref(),
@@ -390,11 +390,9 @@ pub fn checkout_commit(
390390
repo.set_head_detached(commit.id())?;
391391

392392
// Smudge Large File Storage pointer files with real content from the local Large File Storage store.
393-
if let Err(error) = super::lfs::large_file_storage_smudge_tree(
394-
&repo,
395-
&tree,
396-
previous_tree.as_ref(),
397-
) {
393+
if let Err(error) =
394+
super::lfs::smudge_tree(&repo, &tree, previous_tree.as_ref())
395+
{
398396
log::warn!("checkout_commit: Large File Storage smudge failed: {error}");
399397
}
400398

@@ -449,11 +447,9 @@ pub fn checkout_remote_branch(
449447
}
450448

451449
// Smudge LFS pointer files with real content from the local LFS store.
452-
if let Err(e) = super::lfs::large_file_storage_smudge_tree(
453-
&repo,
454-
&tree,
455-
previous_tree.as_ref(),
456-
) {
450+
if let Err(e) =
451+
super::lfs::smudge_tree(&repo, &tree, previous_tree.as_ref())
452+
{
457453
log::warn!("checkout_remote_branch: LFS smudge failed: {e}");
458454
}
459455

‎asyncgit/src/sync/commit_files.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn get_commit_files(
7676
.path()
7777
.map(|p| p.to_str().unwrap_or("").to_string())
7878
.unwrap_or_default();
79-
let is_lfs = super::lfs::lfs_filter_for(
79+
let is_lfs = super::lfs::filter_for(
8080
&repo,
8181
std::path::Path::new(&path),
8282
)

‎asyncgit/src/sync/commit_revert.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub fn revert_commit(
2020

2121
repo.revert(&commit, None)?;
2222

23+
crate::sync::lfs::record_smudge(&repo, "revert_commit");
24+
2325
Ok(())
2426
}
2527

‎asyncgit/src/sync/lfs.rs‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn lfs_skip_smudge() -> bool {
5151
/// This delegates to libgit2's attribute lookup and returns an [`LfsFilter`]
5252
/// variant so downstream code can pattern-match instead of inspecting strings
5353
/// or booleans.
54-
pub fn lfs_filter_for(repo: &Repository, path: &Path) -> LfsFilter {
54+
pub fn filter_for(repo: &Repository, path: &Path) -> LfsFilter {
5555
match repo.get_attr(path, "filter", git2::AttrCheckFlags::empty())
5656
{
5757
Ok(Some("lfs")) => LfsFilter::Lfs,
@@ -63,7 +63,7 @@ pub fn lfs_filter_for(repo: &Repository, path: &Path) -> LfsFilter {
6363
///
6464
/// The real bytes are written to `.git/lfs/objects/`; keeping the index entry holding
6565
/// just the small pointer text.
66-
pub fn large_file_storage_clean_and_stage(
66+
pub fn clean_and_stage(
6767
repository: &Repository,
6868
index: &mut git2::Index,
6969
file_path: &Path,
@@ -147,7 +147,7 @@ fn file_mode_for(path: &Path) -> git2::FileMode {
147147
/// Walk `tree` and smudge every LFS pointer file in the working tree.
148148
///
149149
/// Returns `Ok(())` even when individual files cannot be smudged, so a partial LFS store only warns.
150-
pub fn large_file_storage_smudge_tree(
150+
pub fn smudge_tree(
151151
repository: &Repository,
152152
target_tree: &git2::Tree,
153153
previous_tree: Option<&git2::Tree>,
@@ -198,7 +198,7 @@ pub fn large_file_storage_smudge_tree(
198198
for file_path in changed_file_paths {
199199
// Staging will clean content into the local LFS store
200200
// Checkout will smudge pointer files into their OG content
201-
if lfs_filter_for(repository, file_path).is_lfs() {
201+
if filter_for(repository, file_path).is_lfs() {
202202
let full_path = working_directory.join(file_path);
203203
let outcome =
204204
smudge_file(&store, full_path.as_path(), file_path);
@@ -210,6 +210,25 @@ pub fn large_file_storage_smudge_tree(
210210
Ok(())
211211
}
212212

213+
/// Smudge LFS pointer files in the working tree against `HEAD`, logging a
214+
/// warning tagged with `operation` on failure instead of propagating it.
215+
pub fn record_smudge(repository: &Repository, operation: &str) {
216+
// Operations that rewrite the working tree from git history (reset, stash
217+
// apply/pop, rebase, revert) leave LFS files as pointer text, so cover that here.
218+
let head_tree =
219+
match repository.head().and_then(|h| h.peel_to_tree()) {
220+
Ok(tree) => tree,
221+
Err(e) => {
222+
log::warn!("{operation}: LFS smudge failed to resolve HEAD: {e}");
223+
return;
224+
}
225+
};
226+
227+
if let Err(e) = smudge_tree(repository, &head_tree, None) {
228+
log::warn!("{operation}: LFS smudge failed: {e}");
229+
}
230+
}
231+
213232
fn log_smudge_outcome(
214233
entry_path: &Path,
215234
outcome: Result<SmudgeOutcome>,
@@ -259,11 +278,8 @@ fn smudge_tree_entries(
259278
}
260279
// Use a match guard to gracefully filter out non-LFS blobs immediately
261280
Some(git2::ObjectType::Blob)
262-
if lfs_filter_for(
263-
repository,
264-
entry_path.as_path(),
265-
)
266-
.is_lfs() =>
281+
if filter_for(repository, entry_path.as_path())
282+
.is_lfs() =>
267283
{
268284
let full_path = working_directory.join(&entry_path);
269285
let outcome = smudge_file(

‎asyncgit/src/sync/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub use tags::{
107107
pub use tree::{tree_file_content, tree_files, TreeFile};
108108
pub use utils::{
109109
get_head, get_head_tuple, repo_dir, repo_open_error,
110-
stage_add_all, stage_add_file, stage_addremoved, Head,
110+
stage_add_all_files, stage_add_file, stage_addremoved, Head,
111111
};
112112

113113
pub use git2::ResetType;

‎asyncgit/src/sync/rebase.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ pub fn conflict_free_rebase(
6363

6464
rebase.finish(Some(&signature))?;
6565

66+
crate::sync::lfs::record_smudge(repo, "rebase");
67+
6668
last_commit.ok_or_else(|| {
6769
Error::Generic(String::from("no commit rebased"))
6870
})
@@ -103,6 +105,8 @@ pub fn rebase(
103105

104106
rebase.finish(Some(&signature))?;
105107

108+
crate::sync::lfs::record_smudge(repo, "rebase");
109+
106110
Ok(RebaseState::Finished)
107111
}
108112

@@ -140,6 +144,8 @@ pub fn continue_rebase(
140144

141145
rebase.finish(Some(&signature))?;
142146

147+
crate::sync::lfs::record_smudge(repo, "continue_rebase");
148+
143149
Ok(RebaseState::Finished)
144150
}
145151

‎asyncgit/src/sync/reset.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pub fn reset_workdir(repo_path: &RepoPath, path: &str) -> Result<()> {
3535
.path(path);
3636

3737
repo.checkout_index(None, Some(&mut checkout_opts))?;
38+
39+
super::lfs::record_smudge(&repo, "reset_workdir");
40+
3841
Ok(())
3942
}
4043

@@ -55,10 +58,7 @@ pub fn reset_repo(
5558
// Only a hard reset rewrites the working tree from the target commit and
5659
// leaves LFS files as pointer text; soft/mixed resets leave it untouched.
5760
if matches!(kind, ResetType::Hard) {
58-
super::lfs::large_file_storage_smudge_head_logged(
59-
&repo,
60-
"reset_repo",
61-
);
61+
super::lfs::record_smudge(&repo, "reset_repo");
6262
}
6363

6464
Ok(())
@@ -74,7 +74,7 @@ mod tests {
7474
tests::{
7575
debug_cmd_print, get_statuses, repo_init, repo_init_empty,
7676
},
77-
utils::{stage_add_all, stage_add_file},
77+
utils::{stage_add_all_files, stage_add_file},
7878
RepoPath,
7979
};
8080
use std::{
@@ -197,7 +197,7 @@ mod tests {
197197
.write_all(b"file3")?;
198198
}
199199

200-
stage_add_all(repo_path, "*", None).unwrap();
200+
stage_add_all_files(repo_path, "*", None).unwrap();
201201
commit(repo_path, "msg").unwrap();
202202

203203
{

‎asyncgit/src/sync/stash.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ pub fn stash_pop(
5252

5353
repo.stash_pop(index, None)?;
5454

55+
super::lfs::record_smudge(&repo, "stash_pop");
56+
5557
Ok(())
5658
}
5759

@@ -74,6 +76,8 @@ pub fn stash_apply(
7476
opt.checkout_options(checkout);
7577
repo.stash_apply(index, Some(&mut opt))?;
7678

79+
super::lfs::record_smudge(&repo, "stash_apply");
80+
7781
Ok(())
7882
}
7983

‎asyncgit/src/sync/status.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ pub fn get_status(
215215

216216
if let Some(status) = status {
217217
let path = item.rela_path().to_string();
218-
let is_lfs = super::lfs::lfs_filter_for(
218+
let is_lfs = super::lfs::filter_for(
219219
&git2_repo,
220220
Path::new(&path),
221221
)
@@ -252,7 +252,7 @@ pub fn get_status(
252252
-> Result<gix::diff::index::Action> {
253253
let path = change_ref.fields().0.to_string();
254254
let status = change_ref.into();
255-
let is_lfs = super::lfs::lfs_filter_for(
255+
let is_lfs = super::lfs::filter_for(
256256
&git2_repo,
257257
Path::new(&path),
258258
)
@@ -293,7 +293,7 @@ pub fn get_status(
293293
};
294294

295295
if let Some(status) = status {
296-
let is_lfs = super::lfs::lfs_filter_for(
296+
let is_lfs = super::lfs::filter_for(
297297
&git2_repo,
298298
Path::new(&path),
299299
)

‎src/components/changes.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl ChangesComponent {
9898
self.options.borrow().status_show_untracked();
9999

100100
//TODO: check if we can handle the one file case with it as well
101-
sync::stage_add_all(
101+
sync::stage_add_all_files(
102102
&self.repo.borrow(),
103103
tree_item.info.full_path.as_str(),
104104
config,
@@ -131,7 +131,7 @@ impl ChangesComponent {
131131
fn index_add_all(&self) -> Result<()> {
132132
let config = self.options.borrow().status_show_untracked();
133133

134-
sync::stage_add_all(&self.repo.borrow(), "*", config)?;
134+
sync::stage_add_all_files(&self.repo.borrow(), "*", config)?;
135135

136136
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
137137

0 commit comments

Comments
 (0)