Skip to content
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Then run:
lazygitrs
```

Use `lazygitrs --commits` to start at the checked-out HEAD commit. Press
`Ctrl+G` to toggle between working-tree changes and HEAD (including from a
focused diff). If filters or pagination hide HEAD, it opens a separate HEAD
history view without clearing your filters. Remap or disable the shortcut with
`keybinding.universal.toggleWorkingTreeAndHead` (`"<c-g>"` by default; `""` disables it).

### Upgrade

Detects how you installed (brew / npm / bun / cargo / install.sh) and upgrades in place:
Expand Down
15 changes: 11 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ pub struct App {
pub config: AppConfig,
pub repo_path: PathBuf,
pub filter_path: Option<PathBuf>,
pub start_in_commits: bool,
}

impl App {
pub fn new(repo_path: PathBuf, debug: bool, filter_path: Option<PathBuf>) -> Result<Self> {
pub fn new(
repo_path: PathBuf,
debug: bool,
filter_path: Option<PathBuf>,
start_in_commits: bool,
) -> Result<Self> {
let config = AppConfig::load(debug)?;

// Validate git repo
Expand All @@ -25,6 +31,7 @@ impl App {
config,
repo_path,
filter_path,
start_in_commits,
})
}

Expand All @@ -36,9 +43,9 @@ impl App {
self.config.app_state.add_recent_repo(&repo_str);
let _ = self.config.save_state();

// Pass `-f` into Gui::new so the initial model stream loads filtered
// commits immediately (no wait for full refresh + second git log).
let mut gui = Gui::new(self.config, git, self.filter_path)?;
// Pass `-f` and start_in_commits into Gui::new so the initial model stream loads
// filtered commits or commits tab immediately.
let mut gui = Gui::new(self.config, git, self.filter_path, self.start_in_commits)?;
gui.run()?;

Ok(())
Expand Down
3 changes: 3 additions & 0 deletions src/config/keybindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ pub struct UniversalKeybinding {
pub reset_side_panel: String,
#[serde(rename = "toggleDiffViewLayout")]
pub toggle_diff_view_layout: String,
#[serde(rename = "toggleWorkingTreeAndHead")]
pub toggle_working_tree_and_head: String,
}

impl Default for UniversalKeybinding {
Expand Down Expand Up @@ -181,6 +183,7 @@ impl Default for UniversalKeybinding {
main_panel_full: "<a-j>".into(),
reset_side_panel: "<a-r>".into(),
toggle_diff_view_layout: "\\".into(),
toggle_working_tree_and_head: "<c-g>".into(),
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ pub struct AppConfig {
pub state_path: PathBuf,
}

impl Default for AppConfig {
fn default() -> Self {
Self {
debug: false,
version: env!("CARGO_PKG_VERSION").to_string(),
user_config: UserConfig::default(),
app_state: AppState::default(),
config_dir: PathBuf::from("."),
state_dir: PathBuf::from("."),
state_path: PathBuf::from("state.yml"),
}
}
}

impl AppConfig {
pub fn load(debug: bool) -> Result<Self> {
let home_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
Expand Down
2 changes: 1 addition & 1 deletion src/gui/controller/diff_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ mod tests {
state_dir: repo.0.clone(),
state_path: repo.0.join("state.yml"),
};
let mut gui = Gui::new(config, GitCommands::new(&repo.0).unwrap(), None).unwrap();
let mut gui = Gui::new(config, GitCommands::new(&repo.0).unwrap(), None, false).unwrap();
gui.diff_mode.enter(false);
gui.diff_mode.ref_a = "main".into();
gui.diff_mode.ref_b = "feature".into();
Expand Down
Loading
Loading