Compare commits

..
Author SHA1 Message Date
Patrick szymkowiak 6cee6c60b8 fix(git): inherit stdin for commit and push to preserve SSH signing (#733)
Command::output() sets stdin to Stdio::piped() by default, creating an
empty pipe instead of inheriting the terminal. SSH signing tools
(1Password, YubiKey, gpg-agent with pinentry) need TTY access on stdin
for passphrase prompts or agent communication. This caused signatures
to be silently dropped — commits succeeded but without gpgsig headers.

Fix: add .stdin(Stdio::inherit()) to git commit and git push commands
so they inherit the parent's stdin (terminal or hook pipe). Output
capture via stdout/stderr pipes is preserved.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
2026-04-02 21:04:46 +02:00
2 changed files with 4 additions and 6 deletions

No files matched your search

+3 -1
View File
@@ -3,6 +3,7 @@
use crate::core::config;
use crate::core::tracking;
use crate::core::utils::{exit_code_from_output, exit_code_from_status, resolved_command};
use std::process::Stdio;
use anyhow::{Context, Result};
use std::ffi::OsString;
use std::process::Command;
@@ -908,6 +909,7 @@ fn run_commit(args: &[String], verbose: u8, global_args: &[String]) -> Result<i3
}
let output = build_commit_command(args, global_args)
.stdin(Stdio::inherit())
.output()
.context("Failed to run git commit")?;
@@ -972,7 +974,7 @@ fn run_push(args: &[String], verbose: u8, global_args: &[String]) -> Result<i32>
cmd.arg(arg);
}
let output = cmd.output().context("Failed to run git push")?;
let output = cmd.stdin(Stdio::inherit()).output().context("Failed to run git push")?;
let stderr = String::from_utf8_lossy(&output.stderr);
let stdout = String::from_utf8_lossy(&output.stdout);
+1 -5
View File
@@ -6,7 +6,6 @@ use crate::core::utils::{exit_code_from_output, resolved_command};
use anyhow::{Context, Result};
use regex::Regex;
use std::collections::HashMap;
use std::process::Stdio;
#[allow(clippy::too_many_arguments)]
pub fn run(
@@ -29,9 +28,7 @@ pub fn run(
let rg_pattern = pattern.replace(r"\|", "|");
let mut rg_cmd = resolved_command("rg");
rg_cmd
.args(["-n", "--no-heading", &rg_pattern, path])
.stdin(Stdio::null());
rg_cmd.args(["-n", "--no-heading", &rg_pattern, path]);
if let Some(ft) = file_type {
rg_cmd.arg("--type").arg(ft);
@@ -50,7 +47,6 @@ pub fn run(
.or_else(|_| {
resolved_command("grep")
.args(["-rn", pattern, path])
.stdin(Stdio::null())
.output()
})
.context("grep/rg failed")?;