Tell agents about stored git credentials; give Claude Code the user's git config

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-15 10:52:07 +01:00
1 parent ec95f9b8ad
commit f0cd404f59
5 files changed
+71 -3

No files matched your search

+14 -3
View File
@@ -97,7 +97,14 @@ fn command(app: &App, owner: Option<&str>, cwd: &Path, args: &[String]) -> Resul
c.env(k, v);
}
}
c.env("TERM", "xterm-256color").env("CODECRAFT", "1").args(args);
c.env("TERM", "xterm-256color").env("CODECRAFT", "1").env("GIT_TERMINAL_PROMPT", "0").args(args);
// The user's git credentials and identity (the CLI runs git for the agent).
if let Some(user) = owner.and_then(|id| app.store.user(id).ok().flatten()) {
if let Some(cfg) = crate::gitcreds::global_config(app, &user) {
c.env("GIT_CONFIG_GLOBAL", cfg);
}
c.envs(crate::gitcreds::identity_env(app, &user.id));
}
Ok(c)
}
@@ -357,8 +364,12 @@ pub async fn run(app: Arc<App>, session_id: &str, cancel: CancellationToken) ->
if let Some(r) = &resume {
args.extend(["--resume".into(), r.clone()]);
}
if !session.instructions.trim().is_empty() {
args.extend(["--append-system-prompt".into(), session.instructions.trim().to_string()]);
let mut appended = session.instructions.trim().to_string();
if let Some(git) = owner.as_deref().and_then(|u| crate::gitcreds::prompt_section(&app, u)) {
appended = format!("{appended}\n{git}").trim().to_string();
}
if !appended.is_empty() {
args.extend(["--append-system-prompt".into(), appended]);
}
let mut cmd = command(&app, owner.as_deref(), Path::new(&session.cwd), &args)?;