Skip to content

Commit 1839d73

Browse files
authored
fix: Correctly find repos in parents of CWD (#32)
I guess I only ever work in the roots of repos
1 parent 3373eee commit 1839d73

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22

3+
* Correctly find git repos in parent dirs of CWD
4+
35
# Version 0.2.4
46

57
* Retarget multiple branches pointing at the same commit, eg:

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct Config {
3333
}
3434

3535
pub fn instafix(c: Config) -> Result<(), anyhow::Error> {
36-
let repo = Repository::open(".").context("opening repo")?;
36+
let repo = Repository::open_from_env().context("opening repo")?;
3737
let diff = create_diff(&repo, &c.theme, c.require_newline).context("creating diff")?;
3838
let head = repo.head().context("finding head commit")?;
3939
let head_branch = Branch::wrap(head);
@@ -52,7 +52,7 @@ pub fn instafix(c: Config) -> Result<(), anyhow::Error> {
5252
let needs_stash = worktree_is_dirty(&repo)?;
5353
if needs_stash {
5454
// TODO: is it reasonable to create a new repo to work around lifetime issues?
55-
let mut repo = Repository::open(".")?;
55+
let mut repo = Repository::open_from_env()?;
5656
let sig = repo.signature()?.clone();
5757
repo.stash_save(&sig, "git-instafix stashing changes", None)?;
5858
}

0 commit comments

Comments
 (0)