Skip to content

Commit 0d061de

Browse files
1 parent de6e0f8 commit 0d061de

2 files changed

Lines changed: 46 additions & 17 deletions

File tree

Source/IPC/WindServiceHandlers/Git.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,7 @@ async fn RunGit(OperationId:&str, Args:&[String], Cwd:Option<&str>) -> Result<(i
7474
let WorkingDir = Cwd.map(ResolveCwd).unwrap_or_else(|| std::env::current_dir().unwrap_or_default());
7575

7676
let mut Spawn = Command::new("git");
77-
Spawn.args(Args).current_dir(&WorkingDir);
78-
#[cfg(unix)]
79-
{
80-
// Keep the child in its own process group so a single SIGTERM
81-
// targeted at the PID cleans up any pager the subprocess may have
82-
// spawned.
83-
use std::os::unix::process::CommandExt;
84-
unsafe {
85-
Spawn.pre_exec(|| {
86-
libc::setsid();
87-
Ok(())
88-
});
89-
}
90-
}
77+
Spawn.args(Args).current_dir(&WorkingDir).kill_on_drop(true);
9178

9279
let Child = Spawn.spawn().map_err(|Error| {
9380
dev_log!(
@@ -310,9 +297,9 @@ pub async fn HandleCancel(args:Vec<Value>) -> Result<Value, String> {
310297
dev_log!("git", "[Git] cancel op={} pid={}", OperationId, Pid);
311298
#[cfg(unix)]
312299
{
313-
unsafe {
314-
libc::kill(Pid as libc::pid_t, libc::SIGTERM);
315-
}
300+
let _ = std::process::Command::new("kill")
301+
.args(["-TERM", &Pid.to_string()])
302+
.output();
316303
}
317304
#[cfg(windows)]
318305
{

Source/IPC/WindServiceHandlers/mod.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub mod Commands;
77
pub mod Configuration;
88
pub mod Extensions;
99
pub mod FileSystem;
10+
pub mod Git;
1011
pub mod Model;
1112
pub mod NativeHost;
1213
pub mod Navigation;
@@ -1656,6 +1657,47 @@ pub async fn mountain_ipc_invoke(app_handle:AppHandle, command:String, args:Vec<
16561657
},
16571658
"workspaces:getDirtyWorkspaces" => Ok(json!([])),
16581659

1660+
// Git (localGit channel) - implements stock VS Code's
1661+
// ILocalGitService surface plus `exec` / `isAvailable` for
1662+
// the built-in Git extension. Handlers spawn native `git`
1663+
// via tokio::process. See Batch 4 in HANDOFF §-10.
1664+
"git:exec" => {
1665+
dev_log!("git", "git:exec");
1666+
Git::HandleExec(args).await
1667+
},
1668+
"git:clone" => {
1669+
dev_log!("git", "git:clone");
1670+
Git::HandleClone(args).await
1671+
},
1672+
"git:pull" => {
1673+
dev_log!("git", "git:pull");
1674+
Git::HandlePull(args).await
1675+
},
1676+
"git:checkout" => {
1677+
dev_log!("git", "git:checkout");
1678+
Git::HandleCheckout(args).await
1679+
},
1680+
"git:revParse" => {
1681+
dev_log!("git", "git:revParse");
1682+
Git::HandleRevParse(args).await
1683+
},
1684+
"git:fetch" => {
1685+
dev_log!("git", "git:fetch");
1686+
Git::HandleFetch(args).await
1687+
},
1688+
"git:revListCount" => {
1689+
dev_log!("git", "git:revListCount");
1690+
Git::HandleRevListCount(args).await
1691+
},
1692+
"git:cancel" => {
1693+
dev_log!("git", "git:cancel");
1694+
Git::HandleCancel(args).await
1695+
},
1696+
"git:isAvailable" => {
1697+
dev_log!("git", "git:isAvailable");
1698+
Git::HandleIsAvailable(args).await
1699+
},
1700+
16591701
// Atom L2: unknown-command fallback consults the Channel registry so
16601702
// the log distinguishes three states:
16611703
// 1. typo / never-registered wire string (registry::from_str Err)

0 commit comments

Comments
 (0)