Skip to content

Conversation

@11happy
Copy link

@11happy 11happy commented Nov 4, 2025

Closes #28667

Release Notes:

  • I have implemented file mode detection using new_smol_command & if its empty defaulting to 100644 as previously, however I noticed in function load_committed_text
fn load_committed_text(&self, path: RepoPath) -> BoxFuture<'_, Option<String>> {
        let repo = self.repository.clone();
        self.executor
            .spawn(async move {
                let repo = repo.lock();
                let head = repo.head().ok()?.peel_to_tree().log_err()?;
                let entry = head.get_path(path.as_std_path()).ok()?;
                if entry.filemode() == i32::from(git2::FileMode::Link) {
                    return None;
                }
                let content = repo.find_blob(entry.id()).log_err()?.content().to_owned();
                String::from_utf8(content).ok()
            })
            .boxed()
    }

it accesses filemode with entry.filemode() should I use this approach ?

Signed-off-by: 11happy <[email protected]>
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 4, 2025
@maxdeviant maxdeviant changed the title fix: correct file mode when staging git: Use correct file mode when staging Nov 4, 2025
@cole-miller
Copy link
Member

@11happy Yeah, I think using the git2 API to load the filemode like in load_committed_text makes sense.

@11happy
Copy link
Author

11happy commented Nov 5, 2025

@cole-miller , I have refactored the approach keeping it similar to load_commited_text and flattened it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git: staging ranges in a file with special permissions is not handled properly

2 participants