diff --git a/src/git.rs b/src/git.rs index 29c1d32..e2c6ec6 100644 --- a/src/git.rs +++ b/src/git.rs @@ -382,13 +382,17 @@ fn merge_stashes_to_commits(commits: Vec, stashes: Vec) -> Vec = stashes - .into_iter() - .map(|commit| (commit.parent_commit_hashes[0].clone(), commit)) - .collect(); + let mut statsh_map: HashMap> = + stashes.into_iter().fold(HashMap::new(), |mut acc, commit| { + let parent = commit.parent_commit_hashes[0].clone(); + acc.entry(parent).or_default().push(commit); + acc + }); for commit in commits { - if let Some(stash) = statsh_map.remove(&commit.commit_hash) { - ret.push(stash); + if let Some(stashes) = statsh_map.remove(&commit.commit_hash) { + for stash in stashes { + ret.push(stash); + } } ret.push(commit); } diff --git a/tests/graph/stash_004_chrono.png b/tests/graph/stash_004_chrono.png index eefb250..e8018e2 100644 Binary files a/tests/graph/stash_004_chrono.png and b/tests/graph/stash_004_chrono.png differ diff --git a/tests/graph/stash_004_topo.png b/tests/graph/stash_004_topo.png index eefb250..e8018e2 100644 Binary files a/tests/graph/stash_004_topo.png and b/tests/graph/stash_004_topo.png differ