Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use ArgumentList for commands instead of manual escaping #473

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

Closed

Conversation

Copy link
Contributor

@aikawayataro aikawayataro commented Sep 14, 2024

This will refactor command arguments from a single string to an argument array

Argument arrays are easier to work with, and you don't have to worry about escaping arguments. They are also easier to work with because you can split them into multiple lines

I've tested all the features I use, but an extra pair of eyes is really needed 😁

Copy link
Collaborator

BTW, I don't think using 'ArgumentList' is better than 'Arguments' since we have manually escaped the path strings and when creating a specified process, the parameter list is always concated into a single string.

Copy link
Contributor Author

Manual escaping is bug-prone and may fail if path contains " with the current implementation.
But the main reason in ArgumentList is to provide a more robust and secure way to provide arguments. It is simply easier to work with array than string.

when creating a specified process, the parameter list is always concated into a single string

https://source.dot.net/#System.Diagnostics.Process/System/Diagnostics/Process.Unix.cs,2cbba2bbbfb82be9

Maybe on Windows. Before this dotnet will parse command to argv anyway, later passed to execve inside native interop

In the end, the main goal of this PR is to make commands more readable and easier to maintain

@@ -47,7 +48,7 @@ public string Local
set => SetProperty(ref _local, value);
}

public string ExtraArgs
public IEnumerable<string> ExtraArgs
Copy link
Collaborator

@love-linger love-linger Sep 14, 2024

Choose a reason for hiding this comment

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

The ExtraArgs is binded to a TextBox that allows user to provide extra arguments while clone repositories

Copy link
Collaborator

@love-linger love-linger Sep 14, 2024

Choose a reason for hiding this comment

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

See:
image

@@ -799,7 +799,7 @@ public void RefreshCommits()
}
else
{
limits += "--exclude=refs/stash --all";
limits.AddRange(["--exclude=refs/stash", "-all"]);
Copy link
Collaborator

@love-linger love-linger Sep 14, 2024

Choose a reason for hiding this comment

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

should be --all instead of -all

Copy link
Contributor Author

I can address the issues, but how do you feel about the change in general? No worries if you don't need this

Copy link
Collaborator

I can address the issues, but how do you feel about the change in general? No worries if you don't need this

Both ways are fine for me. I don't have any preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@love-linger love-linger love-linger left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /