Skip to content

Conversation

gerhardol
Copy link
Member

Fixes #11869

Proposed changes

Some methods intend to check the Git output, but the command always throws at exit.
throwOnErrorExit need to be configurable for these methods.
Quotes were additionally quouted too (done in QuoteNE())

This occurs for instance when checking the characters in a branch name and staging files.
Note that the command still echoes the branchname to the console.

While Git allows quotes in branch names, Windows does not (this is a file) allow quotes in the name.

Note: There are a few calls of RunCommand() that could be supressed in addition to those thatactually check the output, but I left it at the checked calls.
This cannot be be too commonly occurring as the throwOnErrorExit checks were added in 4.1 or 4.0.

Screenshots

Before

NBug

After

image

Test methodology

Manual

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.

Some methods intend to check the Git output, but the
command always throws at exit.
throwOnErrorExit need to be configurable for these methods.

This occurs for instance when checking the characters in a
branch name and staging files.
GitArgumentBuilder args = new("check-ref-format")
{
"--branch",
branchName.QuoteNE()
};
return _gitExecutable.RunCommand(args);
return _gitExecutable.RunCommand(args, throwOnErrorExit: false);
Copy link
Member Author

Choose a reason for hiding this comment

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

Will change this call to the standard execute that return result to get rid of the printout too.

@mstv mstv self-requested a review September 3, 2024 10:22
@@ -1779,7 +1779,8 @@ public bool StageFile(string file)
{
"--add",
file.ToPosixPath().Quote()
});
},
throwOnErrorExit: false);
Copy link
Member

Choose a reason for hiding this comment

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

As the result of StageFile is never evaluated, rather remove the return value and throw.
If there are known uncritical exit codes, please handle them explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, changes requires changes of the plugin interface though.

Some methods intend to check the Git output, but the
command always throws at exit.
throwOnErrorExit need to be configurable for these methods.

This occurs for instance when checking the characters in a
branch name and staging files.

Avoid echoing the branchname when creating a branch
(as output in RunCommand() is written to the console).
@mstv mstv changed the title fix: RunCommand() shoul not throw when exit is checked fix: RunCommand() should not throw when exit is checked Sep 4, 2024
@gerhardol gerhardol merged commit dc0bf19 into gitextensions:master Sep 4, 2024
3 of 4 checks passed
@gerhardol gerhardol deleted the feature/i11869-create-branch branch September 4, 2024 19:46
@RussKie RussKie added this to the 5.1 milestone Nov 6, 2024
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.

Error when clicked "View details" in error dialog
3 participants