Skip to content
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

Use git's --date-order or --topo-order #3

Closed
kdheepak opened this issue Jul 28, 2024 · 7 comments · Fixed by #5
Closed

Use git's --date-order or --topo-order #3

kdheepak opened this issue Jul 28, 2024 · 7 comments · Fixed by #5
Labels
enhancement New feature or request

Comments

@kdheepak
Copy link
Contributor

I'm sure you are already aware of this, but thought I'd mention it just to check:

serie/src/git.rs

Lines 239 to 251 in 779bd6e

let mut cmd = Command::new("git")
.arg("log")
// exclude stashes and other refs
.arg("--branches")
.arg("--remotes")
.arg("--tags")
.arg(format!("--pretty={}", load_commits_format()))
.arg("--date=iso-strict")
.arg("-z") // use NUL as a delimiter
.current_dir(path)
.stdout(Stdio::piped())
.spawn()
.unwrap();

You can use --date-order or --topo-order here directly, e.g.:

    let mut cmd = Command::new("git")
        .arg("log")
        // exclude stashes and other refs
        .arg("--branches")
        .arg("--remotes")
        .arg("--tags")
        .arg(format!("--pretty={}", load_commits_format()))
        .arg(match order {
            CommitOrderType::Chrono => "--date-order",
            CommitOrderType::Topo => "--topo-order",
        })
        .arg("--date=iso-strict")
        .arg("-z") // use NUL as a delimiter
        .current_dir(path)
        .stdout(Stdio::piped())
        .spawn()
        .unwrap();

That way you can skip a bunch of calculation you do internally and rely on the order in git. If you do that, your graph will match closely with the output from git log --oneline --graph

@lusingander
Copy link
Owner

I hadn't thought about this because it was based on code I had implemented as a trial in the past 😀

That may be enough.
We may need to think about how to handle stashes, but that doesn't seem like a big problem.

@kdheepak
Copy link
Contributor Author

I used --all in the PR #5 and it seems to work fine for me:

image

Is there a reason you opted to not do that?

@lusingander
Copy link
Owner

  • The working directory change and the index change (and untracked files) are shown as separate commits, but many clients (not git log) combine them as one commit.
    • This is a matter of preference, but I prefer it combined.
  • I don't think it would be possible to get it if there are multiple stashes.
    • It would be more useful to have all stashes shown as commits.
  • Also, I think these stashes should appear just one commit above the original commit.
    • If we want to merge a stash without sorting the commits, we need to insert it in the right position.

@kdheepak
Copy link
Contributor Author

kdheepak commented Jul 29, 2024

Great points!

I don't view the graph with stashes all that much, but it does seem to match what git does at the moment. I made a stash to test:

image

@lusingander
Copy link
Owner

Yes, git log, tig, etc. will show it that way.

image image

For me, these client-like graphs are easier to use:

image image

@kdheepak
Copy link
Contributor Author

What graphs are those btw? Those look quite nice.

@lusingander lusingander added the enhancement New feature or request label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants