Skip to content

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

Closed

Description

@kdheepak

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

Activity

  1. lusingander commented on Jul 28, 2024

    @lusingander
    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.

  2. kdheepak commented on Jul 29, 2024

    @kdheepak
    ContributorAuthor

    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?

  3. lusingander commented on Jul 29, 2024

    @lusingander
    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.
  4. kdheepak commented on Jul 29, 2024

    @kdheepak
    ContributorAuthor

    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
  5. lusingander commented on Jul 29, 2024

    @lusingander
    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

  6. kdheepak commented on Jul 29, 2024

    @kdheepak
    ContributorAuthor

    What graphs are those btw? Those look quite nice.

  7. added
    enhancement
    on Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions