Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support options in git_status.fetch() #2287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/tabs/stashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use crate::{
};
use anyhow::Result;
use asyncgit::{
sync::{self, status::StatusType, RepoPathRef},
sync::{
self, status::StatusType, RepoPathRef,
ShowUntrackedFilesConfig,
},
AsyncGitNotification, AsyncStatus, StatusParams,
};
use crossterm::event::Event;
Expand Down Expand Up @@ -71,9 +74,20 @@ impl Stashing {
///
pub fn update(&mut self) -> Result<()> {
if self.is_visible() {
self.git_status
//TODO: support options
.fetch(&StatusParams::new(StatusType::Both, None))?;
let status_type = if self.options.keep_index {
StatusType::Both
} else {
StatusType::WorkingDir
Copy link
Contributor

@naseschwarz naseschwarz Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My expectation here would be, that this file list shows all those files, which would be included in a stash.

Here's --keep-index's description:

      -k, --keep-index, --no-keep-index
           This option is only valid for push and save commands.

           All changes already added to the index are left intact.

I.e. "keep index" has no effect on whether a change in the index is stashed or not. It just affects whether that change is removed from the index and work tree afterwards.

Thus, I would have expected that whether "keep index" is active or not has no effect on whether that file a file in the index is listed here.

};
let show_untracked = if self.options.stash_untracked {
Some(ShowUntrackedFilesConfig::All)
} else {
Some(ShowUntrackedFilesConfig::No)
};
self.git_status.fetch(&StatusParams::new(
status_type,
show_untracked,
))?;
}

Ok(())
Expand Down