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

git: show fetch progress with git.subprocess = true #5519

Merged
merged 3 commits into from
Feb 1, 2025

Conversation

bsdinis
Copy link
Contributor

@bsdinis bsdinis commented Jan 30, 2025

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

lib/src/git_subprocess.rs Outdated Show resolved Hide resolved
lib/src/git_subprocess.rs Outdated Show resolved Hide resolved
@bsdinis bsdinis force-pushed the bsdinis/rowomzsmyxok branch 3 times, most recently from a597be4 to 229553d Compare January 30, 2025 18:24
yuja added a commit to yuja/jj that referenced this pull request Jan 31, 2025
…out tty

With this and "git --progress" PR jj-vcs#5519, remote git progress will be displayed.

The sideband callback is disabled in git2 code path if progress is not enabled.
If this were enabled, most "git fetch" tests would fail with git2 due to remote
progress messages. Since there's no git2 API to turn the remote progress off,
and the git2 code path is supposed to be phased out, I just inserted ad-hoc
workaround.
github-merge-queue bot pushed a commit that referenced this pull request Jan 31, 2025
…out tty

With this and "git --progress" PR #5519, remote git progress will be displayed.

The sideband callback is disabled in git2 code path if progress is not enabled.
If this were enabled, most "git fetch" tests would fail with git2 due to remote
progress messages. Since there's no git2 API to turn the remote progress off,
and the git2 code path is supposed to be phased out, I just inserted ad-hoc
workaround.
@bsdinis
Copy link
Contributor Author

bsdinis commented Jan 31, 2025

@yuja there is some weird interplay here with #5521

Basically, in the case that the remote sends a message while the progress bar is updating, the progress bar will be split and not disappear, as it should.

In particular, there is one message, like this:

remote: Total 72578 (delta 173), reused 124 (delta 79), pack-reused 72267 (from 2)

I'm going to work on a fix in front of this. It will be hacky, but we can iterate over it

@bsdinis
Copy link
Contributor Author

bsdinis commented Jan 31, 2025

How it looked before:

Fetching into new repo in "/tmp/tmp.usqsXuL1dA/jj"
remote: Enumerating objects: 56033, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
 98% [████████████████████████████████████████████████████████████████████████████████████████████████████████████▊  ]remote: Total 56033 (delta 5), reused 3 (delta 3), pack-reused 56026 (from 1)

How it looks now (bar disappears when it's complete, as it should):

remote: Enumerating objects: 56034, done.
remote: Total 56034 (delta 6), reused 3 (delta 3), pack-reused 56026 (from 1)

@bsdinis bsdinis force-pushed the bsdinis/rowomzsmyxok branch from 229553d to 3f758a9 Compare January 31, 2025 03:05
@yuja
Copy link
Contributor

yuja commented Jan 31, 2025

Basically, in the case that the remote sends a message while the progress bar is updating, the progress bar will be split and not disappear, as it should.

Doesn't it an issue of the frontend? I think the UI will have to hide progress bar when sideband message is received, or something like that.

@bsdinis
Copy link
Contributor Author

bsdinis commented Jan 31, 2025

Basically, in the case that the remote sends a message while the progress bar is updating, the progress bar will be split and not disappear, as it should.

Doesn't it an issue of the frontend? I think the UI will have to hide progress bar when sideband message is received, or something like that.

I mean, it would require a more involved frontend here. The progress bar is hidden in the end by issuing a \r.
I tried looking for a clean solution there but couldn't find one. To be fair, there is a single message here.
Happy to leave a comment about it, but unless I'm missing something really obvious we could use, it seems like that should be its own PR

@yuja
Copy link
Contributor

yuja commented Jan 31, 2025

Doesn't it an issue of the frontend? I think the UI will have to hide progress bar when sideband message is received, or something like that.

I mean, it would require a more involved frontend here. The progress bar is hidden in the end by issuing a \r. I tried looking for a clean solution there but couldn't find one.

Yeah, the frontend will have to do something based on both prgoress and sideband messages, but I think that's the correct way to fix the problem. It's weird that two separate machinery is writing to the same output stream.

EDIT: fwiw, I think these callbacks can be merged into one once we drop support for git2.

it seems like that should be its own PR

Yes. If the current state is annoying, I would revert my patch.

@bsdinis
Copy link
Contributor Author

bsdinis commented Jan 31, 2025

What do you think of the solution here of holding the sideband messages while progress is going on? It seems to be the best compromise (send sideband immediately when available, hold them for later when not).

Agree that it's not the cleanest, but sounds like it wouldn't be to bad.

@yuja
Copy link
Contributor

yuja commented Jan 31, 2025

What do you think of the solution here of holding the sideband messages while progress is going on? It seems to be the best compromise (send sideband immediately when available, hold them for later when not).

I suspect that the git2 impl would be already broken (if progress and sideband messages are processed in the same way as git command.) I haven't test that.

@bsdinis
Copy link
Contributor Author

bsdinis commented Jan 31, 2025

% ~/dev/jj/target/debug/jj --config 'git.subprocess=false' git clone https://github.com/jj-vcs/jj
Fetching into new repo in "/tmp/tmp.xjeT5o8aH9/jj"
remote: Enumerating objects: 72578, done.
remote: Counting objects: 100% (315/315), done.
remote: Compressing objects: 100% (227/227), done.
 22%  35.3 MiB at  11.9 MiB/s [████████████████████████████████████████████▉                                                                                                                                                                 ]remote: Total 72578 (delta 176), reused 135 (delta 86), pack-reused 72263 (from 2)
 31% [████████████████████████████████████████████████████████████████████████▏                                                                                                                                                              ]

It is

@yuja
Copy link
Contributor

yuja commented Jan 31, 2025

I suspect that the git2 impl would be already broken (if progress and sideband messages are processed in the same way as git command.) I haven't test that.

It is. I'll take a look later.

@bsdinis
Copy link
Contributor Author

bsdinis commented Jan 31, 2025

Now that I remember, the sideband callback for git fetch operations were always set to none.

yuja added 2 commits January 31, 2025 16:10
This helps sideband writer overwrite the progress bar. Suppose progress
information is less important than sideband messages, it should be okay to
always overwrite the progress bar. The sideband writer will erase the trailing
characters and move the cursor back to the first column, and/or put "\n"
accordingly.
I think this is copy-paste error from C implementation.
@yuja
Copy link
Contributor

yuja commented Jan 31, 2025

I suspect that the git2 impl would be already broken

#5530

@bsdinis
Copy link
Contributor Author

bsdinis commented Jan 31, 2025

Tested both this PR and git2 on top of #5530 .
Works like a charm.
Thanks

@bsdinis bsdinis force-pushed the bsdinis/rowomzsmyxok branch from 3f758a9 to e2ddeb1 Compare January 31, 2025 18:27
lib/src/git_subprocess.rs Outdated Show resolved Hide resolved
@bsdinis bsdinis force-pushed the bsdinis/rowomzsmyxok branch from e2ddeb1 to 54955c3 Compare February 1, 2025 00:45
Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

lib/src/git_subprocess.rs Show resolved Hide resolved
lib/src/git_subprocess.rs Outdated Show resolved Hide resolved
lib/src/git_subprocess.rs Outdated Show resolved Hide resolved
lib/src/git_subprocess.rs Outdated Show resolved Hide resolved
lib/src/git_subprocess.rs Show resolved Hide resolved
@bsdinis bsdinis force-pushed the bsdinis/rowomzsmyxok branch from 54955c3 to 3fbef62 Compare February 1, 2025 01:33
@bsdinis bsdinis enabled auto-merge February 1, 2025 01:35
@bsdinis bsdinis added this pull request to the merge queue Feb 1, 2025
Merged via the queue into main with commit b35d503 Feb 1, 2025
36 checks passed
@bsdinis bsdinis deleted the bsdinis/rowomzsmyxok branch February 1, 2025 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants