mirror of
https://github.com/tummychow/git-absorb
synced 2024-11-13 23:57:07 +00:00
Update head_tree
when no commit happens.
This regression was introduced in
fb9e1b3950
.
Moreover, the tests didn't catch it because they didn't check that
there are no leftover changes.
This commit is contained in:
parent
48f2ab7c1f
commit
c35b4dfce6
1 changed files with 19 additions and 0 deletions
19
src/lib.rs
19
src/lib.rs
|
@ -301,6 +301,9 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> {
|
|||
"header" => format!("+{},-{}", diff.insertions(), diff.deletions()),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// we didn't commit anything, but we applied a hunk
|
||||
head_tree = new_head_tree;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,6 +503,18 @@ lines
|
|||
ctx
|
||||
}
|
||||
|
||||
fn nothing_left_in_index(ctx: Context) {
|
||||
let head = ctx.repo.head().unwrap().peel_to_tree().unwrap();
|
||||
let diff = ctx
|
||||
.repo
|
||||
.diff_tree_to_index(Some(&head), Some(&ctx.repo.index().unwrap()), None)
|
||||
.unwrap();
|
||||
let stats = diff.stats().unwrap();
|
||||
assert_eq!(stats.files_changed(), 0);
|
||||
assert_eq!(stats.insertions(), 0);
|
||||
assert_eq!(stats.deletions(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_fixups_per_commit() {
|
||||
let ctx = prepare_and_stage();
|
||||
|
@ -521,6 +536,8 @@ lines
|
|||
let mut revwalk = ctx.repo.revwalk().unwrap();
|
||||
revwalk.push_head().unwrap();
|
||||
assert_eq!(revwalk.count(), 3);
|
||||
|
||||
nothing_left_in_index(ctx);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -544,5 +561,7 @@ lines
|
|||
let mut revwalk = ctx.repo.revwalk().unwrap();
|
||||
revwalk.push_head().unwrap();
|
||||
assert_eq!(revwalk.count(), 2);
|
||||
|
||||
nothing_left_in_index(ctx);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue