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

Stashing tab shows not staged/ not tracked files in view #2263

Open
ondrej-ivanko opened this issue Jun 10, 2024 · 3 comments · May be fixed by #2287
Open

Stashing tab shows not staged/ not tracked files in view #2263

ondrej-ivanko opened this issue Jun 10, 2024 · 3 comments · May be fixed by #2287
Labels
bug Something isn't working

Comments

@ondrej-ivanko
Copy link

Hi,

I'm not sure it's even a bug.

When I was doing stashing in Stash[4] tab, you can switch what to stash by toggling staged/untracked files with keys i/u respectively.

At first I thought it's noop, since there was no visual indication or cue that anything changed. It works as it should by omitting untracked or staged files when toggling with respective keys.

I figured out that it behaves correctly without any obvious clue only by accident.
I had a single untracked directory with different user. The directory had root user and I couldn't stash it cause of permissions. Than the window popped up showing when I was attempting to stash with stashing configuration {StashUntracked: true, ...}. When pressing u, the config changed and I could stash only tracked files as expected.

To Reproduce
Create staged or untracked files with elevated permission like root in project folder. Notice error, than press u or i and see it stashes as expected.

Expected behavior
I expect to have visual cue for what will be stashed. It should be reflected in the file tree view upon pressing i/u keys.

Screenshots
Screenshot from 2024-06-10 11-21-16
The below screenshot actually show correct behavious, as there's nothing to stash, but files are still listed in file tree view
Screenshot from 2024-06-10 11-21-30

Context (please complete the following information):

  • OS/Distro + Version: Fedora Linux 39 (Workstation Edition) x86_64
  • GitUI Version nightly 2024-06-09 ()
  • Rust version: 1.74.0-x86_64-unknown-linux-gnu
@ondrej-ivanko ondrej-ivanko added the bug Something isn't working label Jun 10, 2024
@ondrej-ivanko ondrej-ivanko changed the title Stashing tab shows not stage/ not tracked files in view Stashing tab shows not staged/ not tracked files in view Jun 10, 2024
@extrawurst
Copy link
Owner

i am confused. could you define an example case with some bash setting the files up in a way that the problem can be reproduced?

@ondrej-ivanko
Copy link
Author

Hi, I am truly sorry. I only recently noticed that small box Options in the top right corner on tab 4 indicating which files I have selected for stashing. I just couldn't notice it :)) Therefore I thought there is no indication what is actually being stashed.

What I was hoping to see in the future is visual cue in form of filenames, that will be stashed. For example
Screenshot from 2024-06-29 20-06-36

The file1.txt is being tracked, the other two files are not. I would think the screen would show only file1.txt, since the options is set to not stash untracked files.

Screenshot from 2024-06-29 20-06-45

In this case no files are currently staged. And the options is set to not stash staged files (keep index). Therefore I would expect not to see any filenames.

So it's actually not a bug as I found out, but maybe a possible feature! :))

@kanielrkirby kanielrkirby linked a pull request Jul 6, 2024 that will close this issue
4 tasks
@kanielrkirby
Copy link

kanielrkirby commented Jul 6, 2024

So currently, as I understand it, it seems that these options aren't used yet for a visual representation, but are used for a functional purpose. e.g., if you toggle untracked off (u), and write a stash (w), untracked files aren't added to the stash.

///
pub fn update(&mut self) -> Result<()> {
if self.is_visible() {
self.git_status
//TODO: support options
.fetch(&StatusParams::new(StatusType::Both, None))?;
}
Ok(())
}

///
pub fn stash_save(
repo_path: &RepoPath,
message: Option<&str>,
include_untracked: bool,
keep_index: bool,
) -> Result<CommitId> {
scope_time!("stash_save");
let mut repo = repo(repo_path)?;
let sig = repo.signature()?;
let mut options = StashFlags::DEFAULT;
if include_untracked {
options.insert(StashFlags::INCLUDE_UNTRACKED);
}
if keep_index {
options.insert(StashFlags::KEEP_INDEX);
}
let id = repo.stash_save2(&sig, message, Some(options))?;
Ok(CommitId::new(id))
}

A couple ideas from me would be 1, we could add an identifier (?) to files that aren't tracked, and 2, we implement options for the the visual side (which looks straightforward as far as I can tell). I think it'd look something like this:

///
pub fn update(&mut self) -> Result<()> {
if self.is_visible() {
    let status_type = if self.options.keep_index { StatusType::Both } else { StatusType::WorkingDir };
    let show_untracked = if self.options.stash_untracked { Some(ShowUntrackedFilesConfig::All) } else { Some(ShowUntrackedFilesConfig::No) };
    self.git_status
    //TODO: support options
        .fetch(&StatusParams::new(status_type, show_untracked))?;
    }

    Ok(())
}

I've made a PR with that second change at the least (without the identifier idea).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants