-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unstable layout and occasional segfault #2
Comments
Thank you for your report. The resolution of the commit date handled by git is 1 second, and the list of commits is sorted by Lines 61 to 62 in 779bd6e
Also, although there was no crash, there is something a bit strange at 19 seconds in the graph (commit 2-b) and 22 seconds (commit 2-a). |
fwiw, I tried modifying your code to not sort manually and rely on the order returned by git ( I added a |
Thanks for checking. The process determines the y-position of the commit in the following steps: Lines 61 to 67 in 779bd6e
And if the commits are not topologically ordered, further calculations will fail. In the case of
Have you also modified the git command you run? If you don't specify the order like #3, the output of |
Yes, I changed the code to what I pasted in #3, and commented out the code for calculating stashes.
|
Here's specifically the segfault fault issue. These are the 3 arguments to
I made some changes that appear to resolve it now. I'll submit a PR. |
Would the changes be as follows? diff --git forkSrcPrefix/src/git.rs forkDstPrefix/src/git.rs
index bf6222345f2d43cf0a4ae91f46da1d32e0167b3a..fea0cf862b25fab97100777e9c59f580dbf0c66c 100644
--- /src/git.rs
+++ /src/git.rs
@@ -122,6 +122,7 @@ type RefMap = HashMap<CommitHash, Vec<Ref>>;
#[derive(Debug)]
pub struct Repository {
path: PathBuf,
+ commits: Vec<Commit>,
commit_map: CommitMap,
parents_map: CommitsMap,
@@ -135,10 +136,8 @@ impl Repository {
pub fn load(path: &Path) -> Self {
check_git_repository(path);
- let mut commits = load_all_commits(path);
- let stashes = load_all_stashes(path, to_commit_ref_map(&commits));
-
- commits.extend(stashes);
+ let commits = load_all_commits(path);
+ let commits_cloned = commits.clone();
let (parents_map, children_map) = build_commits_maps(&commits);
let commit_map = to_commit_map(commits);
@@ -149,6 +148,7 @@ impl Repository {
Self::new(
path.to_path_buf(),
+ commits_cloned,
commit_map,
parents_map,
children_map,
@@ -159,6 +159,7 @@ impl Repository {
pub fn new(
path: PathBuf,
+ commits: Vec<Commit>,
commit_map: CommitMap,
parents_map: CommitsMap,
children_map: CommitsMap,
@@ -167,6 +168,7 @@ impl Repository {
) -> Self {
Self {
path,
+ commits,
commit_map,
parents_map,
children_map,
@@ -180,7 +182,7 @@ impl Repository {
}
pub fn all_commits(&self) -> Vec<&Commit> {
- self.commit_map.values().collect()
+ self.commits.iter().collect()
}
pub fn parents_hash(&self, commit_hash: &CommitHash) -> Vec<&CommitHash> {
@@ -244,6 +246,7 @@ fn load_all_commits(path: &Path) -> Vec<Commit> {
.arg("--tags")
.arg(format!("--pretty={}", load_commits_format()))
.arg("--date=iso-strict")
+ .arg("--date-order")
.arg("-z") // use NUL as a delimiter
.current_dir(path)
.stdout(Stdio::piped()) It seems to work in my environment 🤔 serie.mp4 |
I think when I tested it previously I forgot to make this change: pub fn all_commits(&self) -> Vec<&Commit> {
- self.commit_map.values().collect()
+ self.commits.iter().collect()
} Or I made it but forgot to save and build again? With your patch (identical to my PR) it seems to be working fine. |
I tested this on the following graph:
and was getting an unstable layout and an occasional segfault.
Here's a video where I ran it multiple times:
serie-unstable.mov
Here's a python script to generate a number of git repos:
This script is adapted from the test cases in this repo: https://github.com/rbong/vim-flog/tree/master/t
If I had to guess, there might be an issue because commits in these test cases are created in quick succession.
I also noticed in other repos the graph didn't quite match what I was seeing with
tig
,lazygit log
andgit log --oneline --all --graph
. But I figured I'd report this first, since it seemed more pertinent.The text was updated successfully, but these errors were encountered: