Skip to content

Commit eb04c87

Browse files
committed
fix: crash when stash message is null
Signed-off-by: leo <longshuang@msn.cn>
1 parent 6d298be commit eb04c87

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Commands/Stash.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public async Task<bool> PushAsync(string message, bool includeUntracked = true,
2020
builder.Append("--include-untracked ");
2121
if (keepIndex)
2222
builder.Append("--keep-index ");
23-
builder.Append("-m ").Append(message.Quoted());
23+
if (!string.IsNullOrEmpty(message))
24+
builder.Append("-m ").Append(message.Quoted());
2425

2526
Args = builder.ToString();
2627
return await ExecAsync().ConfigureAwait(false);
@@ -32,8 +33,10 @@ public async Task<bool> PushAsync(string message, List<Models.Change> changes, b
3233
builder.Append("stash push --include-untracked ");
3334
if (keepIndex)
3435
builder.Append("--keep-index ");
35-
builder.Append("-m ").Append(message.Quoted()).Append(" -- ");
36+
if (!string.IsNullOrEmpty(message))
37+
builder.Append("-m ").Append(message.Quoted()).Append(' ');
3638

39+
builder.Append("-- ");
3740
foreach (var c in changes)
3841
builder.Append(c.Path.Quoted()).Append(' ');
3942

@@ -47,7 +50,8 @@ public async Task<bool> PushAsync(string message, string pathspecFromFile, bool
4750
builder.Append("stash push --include-untracked --pathspec-from-file=").Append(pathspecFromFile.Quoted()).Append(" ");
4851
if (keepIndex)
4952
builder.Append("--keep-index ");
50-
builder.Append("-m ").Append(message.Quoted());
53+
if (!string.IsNullOrEmpty(message))
54+
builder.Append("-m ").Append(message.Quoted());
5155

5256
Args = builder.ToString();
5357
return await ExecAsync().ConfigureAwait(false);
@@ -59,7 +63,8 @@ public async Task<bool> PushOnlyStagedAsync(string message, bool keepIndex)
5963
builder.Append("stash push --staged ");
6064
if (keepIndex)
6165
builder.Append("--keep-index ");
62-
builder.Append("-m ").Append(message.Quoted());
66+
if (!string.IsNullOrEmpty(message))
67+
builder.Append("-m ").Append(message.Quoted());
6368
Args = builder.ToString();
6469
return await ExecAsync().ConfigureAwait(false);
6570
}

0 commit comments

Comments
 (0)