Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* crash when opening submodule ([#2895](https://github.com/gitui-org/gitui/issues/2895))
* when staging the last file in a directory, the first item after the directory is no longer skipped [[@Tillerino](https://github.com/Tillerino)] ([#2748](https://github.com/gitui-org/gitui/issues/2748))
* index-out-of-bounds panic when unstaging lines near the end of a diff ([#2953](https://github.com/gitui-org/gitui/issues/2953))
* `--watcher` panic when a watched repo contains a directory owned by another user; live-refresh is now disabled instead of crashing ([#2900](https://github.com/gitui-org/gitui/issues/2900))

## [0.28.1] - 2026-03-21

Expand Down
34 changes: 31 additions & 3 deletions src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,38 @@ fn create_watcher(

let mut bouncer =
new_debouncer(timeout, tx).expect("Watch create error");
bouncer

match bouncer
.watcher()
.watch(Path::new(&workdir), RecursiveMode::Recursive)
.expect("Watch error");
{
Ok(()) => std::mem::forget(bouncer),
Err(e) => {
// e.g. a subdirectory owned by another user can make the
// recursive watch fail with `PermissionDenied`. Live
// updates are disabled in that case, but gitui should
// still start up normally instead of crashing (#2900).
log::error!(
"failed to watch '{workdir}' for changes, live-refresh disabled: {e}"
);
}
}
}

std::mem::forget(bouncer);
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_create_watcher_does_not_panic_on_watch_error() {
// a path that cannot be watched (e.g. because it does not
// exist, or - as in #2900 - because a subdirectory is owned
// by another user) must not crash gitui.
let (tx, _rx) = std::sync::mpsc::channel();
create_watcher(
Duration::from_millis(100),
tx,
"/nonexistent/gitui-watcher-test-path",
);
}
}