Skip to content

Commit 5a8e264

Browse files
committed
1.0.3
Require branch to exist to avoid chaos
1 parent c9fcc5d commit 5a8e264

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
## 1.0.3 - 2026-01-30
4+
- Require branches to exist; `terris <branch>` errors if missing.
5+
36
## 1.0.2 - 2026-01-30
47
- Add shell completions for bash, zsh, and fish.
5-

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "terris"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
edition = "2024"
55
description = "A simple git worktree manager."
66
license = "MIT"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cargo install --path .
2828
## Usage
2929

3030
```bash
31-
# Jump to a worktree. Create branch and worktree if missing.
31+
# Jump to a worktree. Branch must exist.
3232
cd "$(terris feature-a)"
3333

3434
# List worktrees
@@ -80,9 +80,9 @@ terris --completions fish > ~/.config/fish/completions/terris.fish
8080
```
8181

8282
## How it works
83-
- `terris <branch>` creates the worktree if missing and prints the path every time.
83+
- `terris <branch>` creates the worktree (branch must exist) and prints the path every time.
8484
- If the branch exists, it is used directly.
85-
- If the branch does not exist, it is created from the current HEAD.
85+
- If the branch does not exist, the command fails with an error.
8686
- Default path is `~/.terris-worktrees/<repo-name>/<branch>-<random-key>`.
8787

8888
## Notes

src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,13 @@ fn cmd_ensure_branch(branch: &str) -> Result<()> {
154154
}
155155

156156
let branch_exists = git_branch_exists(&root, branch)?;
157-
158-
let mut args: Vec<String> = vec!["worktree".into(), "add".into()];
159157
if !branch_exists {
160-
args.push("-b".into());
161-
args.push(branch.to_string());
158+
bail!("branch '{}' does not exist", branch);
162159
}
160+
161+
let mut args: Vec<String> = vec!["worktree".into(), "add".into()];
163162
args.push(target_path.to_string_lossy().to_string());
164-
if branch_exists {
165-
args.push(branch.to_string());
166-
}
163+
args.push(branch.to_string());
167164

168165
run_git(&args, &root).with_context(|| format!("create worktree '{}'", branch))?;
169166
println!("{}", target_path.display());

0 commit comments

Comments
 (0)