refactor: use '\0' instead of '$' to split fields

This commit is contained in:
leo 2024-10-15 16:26:44 +08:00
parent 2aa6383f41
commit 5bad969bb7
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -14,7 +14,7 @@ namespace SourceGit.Commands
{ {
WorkingDirectory = repo; WorkingDirectory = repo;
Context = repo; Context = repo;
Args = "branch -l --all -v --format=\"%(refname)$%(objectname)$%(HEAD)$%(upstream)$%(upstream:trackshort)\""; Args = "branch -l --all -v --format=\"%(refname)%00%(objectname)%00%(HEAD)%00%(upstream)%00%(upstream:trackshort)\"";
} }
public List<Models.Branch> Result() public List<Models.Branch> Result()
@ -37,7 +37,7 @@ namespace SourceGit.Commands
private Models.Branch ParseLine(string line) private Models.Branch ParseLine(string line)
{ {
var parts = line.Split('$'); var parts = line.Split('\0');
if (parts.Length != 5) if (parts.Length != 5)
return null; return null;

View file

@ -9,7 +9,7 @@ namespace SourceGit.Commands
{ {
Context = repo; Context = repo;
WorkingDirectory = repo; WorkingDirectory = repo;
Args = "tag -l --sort=-creatordate --format=\"$%(refname)$%(objectname)$%(*objectname)\""; Args = "tag -l --sort=-creatordate --format=\"%(refname)%00%(objectname)%00%(*objectname)\"";
} }
public List<Models.Tag> Result() public List<Models.Tag> Result()
@ -32,7 +32,7 @@ namespace SourceGit.Commands
private Models.Tag ParseLine(string line) private Models.Tag ParseLine(string line)
{ {
var subs = line.Split('$', StringSplitOptions.RemoveEmptyEntries); var subs = line.Split('\0', StringSplitOptions.RemoveEmptyEntries);
if (subs.Length == 2) if (subs.Length == 2)
{ {
return new Models.Tag() return new Models.Tag()