From f507ad1c33771b7ef14634e636b77af61194847e Mon Sep 17 00:00:00 2001 From: Paul van der Meijs Date: Thu, 26 Sep 2024 02:15:52 +0200 Subject: [PATCH] Properly unstage file (fixes #9) --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 8 ++++---- src/handlers/request.rs | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1163775..5700bc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "gitls" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 08d4afd..3251b89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitls" -version = "0.3.0" +version = "0.3.1" edition = "2021" description = "A language server for Git." license = "MIT" diff --git a/README.md b/README.md index 108c432..c4bfa1d 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ to explore the usage of a language server for Git. ### Blame -| Feature | Status | -| -------------- | ----------------- | -| Blame on hover | Implemented | -| Stage file | Under development | +| Feature | Status | +| -------------- | ----------- | +| Blame on hover | Implemented | +| Stage file | Implemented | ### Index diff --git a/src/handlers/request.rs b/src/handlers/request.rs index bf460ad..be621c1 100644 --- a/src/handlers/request.rs +++ b/src/handlers/request.rs @@ -185,8 +185,9 @@ pub(crate) fn handle_execute_command( index.add_path(rel_path)?; } Command::UnstageFile => { - // TODO: Completely removes the file from the index but should unstage - index.remove_path(rel_path)? + let head = repository.head()?; + let target = head.peel_to_commit()?; + repository.reset_default(Some(&target.into_object()), vec![rel_path])?; } }