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
Cleanup handling of AllOutput for processes #10262
Cleanup handling of AllOutput for processes #10262
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though I haven't run this.
GitCommands/Git/GitModule.cs
Outdated
/// <summary> | ||
/// Set/unset assumeUnchanged | ||
/// </summary> | ||
/// <param name="files">Files to change</param> | ||
/// <param name="assumeUnchanged">Set/unset assumeUnchanged</param> | ||
/// <param name="alloutput">stdout and stderr output</param> | ||
/// <returns>true if no errors occurred</returns> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs should be in sentence case and end with a full stop. We should also strive to use xml-doc tags, where appropriate.
/// <summary> | |
/// Set/unset assumeUnchanged | |
/// </summary> | |
/// <param name="files">Files to change</param> | |
/// <param name="assumeUnchanged">Set/unset assumeUnchanged</param> | |
/// <param name="alloutput">stdout and stderr output</param> | |
/// <returns>true if no errors occurred</returns> | |
/// <summary> | |
/// Set/unset whether given items are assumed unchanged. | |
/// </summary> | |
/// <param name="files">The files to set the status for.</param> | |
/// <param name="assumeUnchanged">The status value.</param> | |
/// <param name="allOutput">stdout and stderr output.</param> | |
/// <returns><see langword="true"/> if no errors occurred; otherwise, <see langword="false"/>.</returns> |
Ditto below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
(Not too happy with the xml-doc, the primary intention is to mark that AllOutput is deliberate, not being parsed.)
I presume we'd want this in v4, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking comments but things I noticed.
GitCommands/Git/GitGpgController.cs
Outdated
@@ -232,13 +232,13 @@ public string GetCommitVerificationMessage(GitRevision revision) | |||
return null; | |||
} | |||
|
|||
var module = GetModule(); | |||
// '--raw' returns info in stderr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather it say verify-tag. It's not just raw that uses the error stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'git verify-tag --raw' returns the info in stderr, but the command itself is redundant here.
--raw returning in stderr is just an unexpected behavior that I want to document, commands should normally only use stderr for displaying errors.
I moved the comment to the return that accesses stderr instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/git/git/blob/d420dda0576340909c3faff364cfbd1485f70376/gpg-interface.c#L656-L666
See how they output to both streams? It is not an error if error stream has output. That is what the error code provides. I have seen a few programs do this where they output a your summary or details in standard output and verbose logging in error or a different result sent in error. As seen above they have the potential to output a different verify output if the flag is set in standard output. The error is the output we expect. I certainly see the issue of they should have done it the other way around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is intended to describe why stderr is parsed instead of stdout.
In general commands should only use stderr to display error messages to the user. I tried to document why stderr was explicitly used with this commit.
Can you make a suggestion on how to describe this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/git/git/blob/d420dda0576340909c3faff364cfbd1485f70376/gpg-interface.c#L661-662
if (flags & GPG_VERIFY_VERBOSE && sigc->payload)
fwrite(sigc->payload, 1, sigc->payload_len, stdout);
Typically that is the case but it is not always the case. Looks like it outputs the raw payload to stdoutput if GPG_VERIFY_VERBOSE
is set.
foreach (var file in nonNewFiles) | ||
{ | ||
sb.Append($" \"{file.Name.ToPosixPath()}\""); | ||
sb.Add($"\"{file.Name.ToPosixPath()}\""); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote or QuoteNe extension method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure removing the space still works as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind. I get it. The add adds the space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to QuoteNE
This makes no functional change, it was a cleanup to ensure that there are no "unexpected" use of stderr as for git-verify-tag. But I find it safe to include. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'll run and verify changes later on today for #10242 |
So testing of this pull and the other together are confirmed that #10242 is resolved if both #10261 and #10262 are merged. See gerhardol#5 for how I tested. |
AllOutput is combined use of stderr and stdout and should only be used to display messages for users. * Change a few commands to explicitly read stderr where required. Some tests had to be adapted (including MockExecutable). * Clarify usage that AllOutput is used for user popups. Most of these occurrences are related to FormCommit. The structure of these command was changed to return a bool for result and the output as a string, also if result/output were unused. * Set TODO on a few occurrences that were not investigated. Co-authored-by: Jay Asbury <vbjay.net@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -98,10 +98,10 @@ public IProcess Start(ArgumentString arguments, bool createWindow, bool redirect | |||
|
|||
private sealed class MockProcess : IProcess | |||
{ | |||
public MockProcess([CanBeNull] string output, int? exitCode = 0) | |||
public MockProcess([CanBeNull] string output, int? exitCode = 0, [CanBeNull] string error = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔
public MockProcess([CanBeNull] string output, int? exitCode = 0, [CanBeNull] string error = null) | |
public MockProcess(string? output, int? exitCode = 0, string? error = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the JetBrains annotation. There are a few other uses remaining, mostly in test files
10b59aa
to
9c4a355
Compare
AllOutput is combined use of stderr and stdout and should only be used to display messages for users. * Change a few commands to explicitly read stderr where required. Some tests had to be adapted (including MockExecutable). * Clarify usage that AllOutput is used for user popups. Most of these occurrences are related to FormCommit. The structure of these command was changed to return a bool for result and the output as a string, also if result/output were unused. * Set TODO on a few occurrences that were not investigated. (cherry picked from commit 2e2d79f)
Initiated from #10242
Some parts were initially in #10261 , separated to this PR
Proposed changes
AllOutput is combined use of stderr and stdout and should only be used to display messages for users.
Change a few commands to explicitly read stderr where required. Some tests had to be adapted (including MockExecutable).
Clarify usage that AllOutput is used for user popups. Most of these occurrences are related to FormCommit. The structure of these command was changed to return a bool for result and the output as a string, also if result/output were unused.
Set TODO on a few occurrences that were not investigated.
Test methodology
Tests updated
Merge strategy
I agree that the maintainer squash merge this PR (if the commit message is clear).
✒️ I contribute this code under The Developer Certificate of Origin.