blacknon / hwatch

A modern alternative to the watch command, records the differences in execution results and can check this differences at after.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Long files confuse `hwatch`

ilyagr opened this issue · comments

To reproduce: with hwatch 0.3.9 on Linux:

  1. Download qq.tar.gz and unpack it. Update: I reuploaded the file, the previous one had an insane path inside the tar file

  2. Run hwatch cat qq or HWATCH= hwatch cat qq

On my machine, this causes hwatch freeze and no part of the file is ever printed. The file has color sequences in it; hwatch --color cat qq also freezes. less -R qq and watch --color cat qq work with no problems.

For illustration, here's the end of the file in less -R:
image

The file is obtained with jj log which is equivalent to git log. I usually use hwatch with jj log with no problems, but for this particular state of the repo something went wrong.

I may or may not try to investigate this myself in the near future.

I think I figured out the cause. The file is simply too long.

$ hwatch "head -n 500 qq"   # Works
$ hwatch "head -n 700 qq"   # Does not work

I think this should still be tracked as a bug. hwatch should handle large file, at least by failing gracefully or cutting them off when a file is too long.

Thanks!

I think this should still be tracked as a bug. hwatch should handle large file, at least by failing gracefully or cutting them off when a file is too long.

That's certainly true.
I'll try to figure out how to fix it.

It certainly doesn't move...
In version 0.3.11, I tried to cat the output of git log --color=always and git log (3000 lines), but it doesn't seem to be working.

It stopped outputting after about 2487 lines, so there may be a problem with writing to memory.
I'm suspecting the size of Buffer.

I think this process is probably the cause.

hwatch/src/exec.rs

Lines 99 to 115 in 6695b35

let (stdout_bytes, stderr_bytes) = match (stdout.fill_buf(), stderr.fill_buf())
{
(Ok(stdout), Ok(stderr)) => {
// merge stdout/stderr
vec_output.write_all(stdout).expect("");
vec_output.write_all(stderr).expect("");
// stdout
vec_stdout.write_all(stdout).expect("");
// stderr
vec_stderr.write_all(stderr).expect("");
(stdout.len(), stderr.len())
}
other => panic!("Some better error handling here, {other:?}"),
};

Closed because it was applied in version 0.3.12.
Thank you for issue!

It works beautifully now. No more need to add | head -n 300 to every command. Thank you!