@@ -391,11 +391,14 @@ for Azure DevOps, Visual Studio, and other Azure-authenticated git services.
391391
392392When invoked as a git credential helper (with 'get' argument), it reads
393393credential request from stdin and outputs bearer token credentials.` ,
394- // Handle legacy 'get' command for git credential protocol
394+ // Silently ignore unknown commands per git credential helper spec:
395+ // "If it does not support the requested operation, it should silently ignore the request."
395396 Run : func (cmd * cobra.Command , args []string ) {
396- // If no subcommand, show help
397- cmd .Help ()
397+ // Silently exit with success for unknown operations
398398 },
399+ // Suppress errors for unknown commands to exit silently
400+ SilenceErrors : true ,
401+ SilenceUsage : true ,
399402 }
400403
401404 // Add persistent verbose flag
@@ -442,30 +445,6 @@ Usage:
442445 rootCmd .AddCommand (initCmd )
443446 rootCmd .AddCommand (exportsCmd )
444447
445- // Store command (no-op, git credential helper protocol)
446- var storeCmd = & cobra.Command {
447- Use : "store" ,
448- Short : "Store credentials (no-op)" ,
449- Long : "No-op command for git credential helper protocol compatibility. Credentials are managed by Azure CLI." ,
450- Hidden : true ,
451- Run : func (cmd * cobra.Command , args []string ) {
452- // No-op: we don't store credentials, Azure CLI manages them
453- debugf (1 , "Store command called (no-op)" )
454- },
455- }
456-
457- // Erase command (no-op, git credential helper protocol)
458- var eraseCmd = & cobra.Command {
459- Use : "erase" ,
460- Short : "Erase credentials (no-op)" ,
461- Long : "No-op command for git credential helper protocol compatibility. Credentials are managed by Azure CLI." ,
462- Hidden : true ,
463- Run : func (cmd * cobra.Command , args []string ) {
464- // No-op: we don't erase credentials, Azure CLI manages them
465- debugf (1 , "Erase command called (no-op)" )
466- },
467- }
468-
469448 // Version command
470449 var versionCmd = & cobra.Command {
471450 Use : "version" ,
@@ -475,11 +454,11 @@ Usage:
475454 },
476455 }
477456
478- rootCmd .AddCommand (storeCmd )
479- rootCmd .AddCommand (eraseCmd )
480457 rootCmd .AddCommand (versionCmd )
481458
482- if err := rootCmd .Execute (); err != nil {
483- os .Exit (1 )
484- }
459+ // Execute the command. Per git credential helper spec, unknown operations
460+ // should be silently ignored with a successful exit code.
461+ // Cobra returns an error for unknown subcommands, but we ignore it to
462+ // comply with the spec: "it should silently ignore the request"
463+ rootCmd .Execute ()
485464}
0 commit comments