Skip to content

Commit 156b144

Browse files
committed
fix: Resolve credential helper timeout syntax error
- Remove --timeout parameter from cache helper command - Git doesn't accept parameters in credential.helper when using -c flag - Properly handle credential helper commands in both Command.cs and GitProcessPool.cs - Add special handling for cache and store helpers - Update description to reflect default 15-minute timeout Fixes error: 'QueryRemotes failed: unknown option: --timeout=3600'
1 parent dabac4b commit 156b144

File tree

3 files changed

+58
-9
lines changed

3 files changed

+58
-9
lines changed

src/Commands/Command.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,30 @@ protected ProcessStartInfo CreateGitStartInfo(bool redirect)
193193
}
194194

195195
var builder = new StringBuilder();
196-
builder
197-
.Append("--no-pager -c core.quotepath=off -c credential.helper=")
198-
.Append(Native.OS.CredentialHelper)
199-
.Append(' ');
196+
builder.Append("--no-pager -c core.quotepath=off");
197+
198+
// Only add credential helper if it's configured
199+
if (!string.IsNullOrEmpty(Native.OS.CredentialHelper))
200+
{
201+
// For the cache helper with timeout, we need special handling
202+
if (Native.OS.CredentialHelper == "cache")
203+
{
204+
// Set cache with default timeout of 900 seconds (15 minutes)
205+
builder.Append(" -c credential.helper=cache -c credentialcache.ignoreSIGHUP=true");
206+
}
207+
else if (Native.OS.CredentialHelper.StartsWith("store"))
208+
{
209+
// Store helper might have --file parameter
210+
builder.Append($" -c credential.helper=\"{Native.OS.CredentialHelper}\"");
211+
}
212+
else
213+
{
214+
// Other helpers just use the name
215+
builder.Append($" -c credential.helper={Native.OS.CredentialHelper}");
216+
}
217+
}
218+
219+
builder.Append(' ');
200220

201221
switch (Editor)
202222
{

src/Commands/Optimization/GitProcessPool.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,28 @@ private GitProcessPool()
171171
private ProcessStartInfo GetOptimizedStartInfo(string workingDirectory, string args)
172172
{
173173
// Build the full git command
174-
var fullCommand = $"--no-pager -c core.quotepath=off -c credential.helper={Native.OS.CredentialHelper} {args}";
174+
var commandBuilder = new System.Text.StringBuilder();
175+
commandBuilder.Append("--no-pager -c core.quotepath=off");
176+
177+
// Only add credential helper if it's configured
178+
if (!string.IsNullOrEmpty(Native.OS.CredentialHelper))
179+
{
180+
if (Native.OS.CredentialHelper == "cache")
181+
{
182+
commandBuilder.Append(" -c credential.helper=cache");
183+
}
184+
else if (Native.OS.CredentialHelper.StartsWith("store"))
185+
{
186+
commandBuilder.Append($" -c credential.helper=\"{Native.OS.CredentialHelper}\"");
187+
}
188+
else
189+
{
190+
commandBuilder.Append($" -c credential.helper={Native.OS.CredentialHelper}");
191+
}
192+
}
193+
194+
commandBuilder.Append(' ').Append(args);
195+
var fullCommand = commandBuilder.ToString();
175196

176197
var psi = new ProcessStartInfo
177198
{

src/Models/CredentialManager.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ private static void InitializeHelpers()
110110
{
111111
Type = CredentialHelperType.Cache,
112112
Name = "Cache (Memory)",
113-
Command = "cache --timeout=3600",
114-
Description = "Temporary in-memory storage (expires after 1 hour)",
113+
Command = "cache",
114+
Description = "Temporary in-memory storage (expires after 15 minutes by default)",
115115
IsAvailable = true, // Always available
116116
RequiresConfiguration = false
117117
});
@@ -326,12 +326,20 @@ public static void ConfigureStoreHelper(string path = null)
326326
}
327327
}
328328

329-
public static void ConfigureCacheHelper(int timeoutSeconds = 3600)
329+
public static void ConfigureCacheHelper(int timeoutSeconds = 900)
330330
{
331331
var helper = GetHelper(CredentialHelperType.Cache);
332332
if (helper != null)
333333
{
334-
helper.Command = $"cache --timeout={timeoutSeconds}";
334+
// The cache helper doesn't take timeout as part of the command
335+
// It needs to be configured separately via git config credential.helper 'cache --timeout=X'
336+
// For now, we just use the basic 'cache' command
337+
helper.Command = "cache";
338+
339+
// Note: To properly set timeout, you would need to run:
340+
// git config --global credential.helper 'cache --timeout=900'
341+
// But since we're passing this via -c flag in each command,
342+
// we can't include the timeout parameter this way
335343
}
336344
}
337345

0 commit comments

Comments
 (0)