emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/diff-hl ce16c13 1/3: New command: diff-hl-unstage-file


From: ELPA Syncer
Subject: [elpa] externals/diff-hl ce16c13 1/3: New command: diff-hl-unstage-file
Date: Mon, 1 Nov 2021 20:57:19 -0400 (EDT)

branch: externals/diff-hl
commit ce16c13d0d0956136384c9c7d06fbc1680caa34d
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    New command: diff-hl-unstage-file
    
    #71
---
 diff-hl.el | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/diff-hl.el b/diff-hl.el
index 13ec147..b345332 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -664,11 +664,17 @@ its end position."
 
 (defvar diff-hl-diff-buffer-with-reference-no-context t)
 
-(defun diff-hl-stage-current-hunk ()
-  (interactive)
+(defun diff-hl--ensure-staging-supported ()
   (let ((backend (vc-backend buffer-file-name)))
     (unless (eq backend 'Git)
-      (user-error "Only Git supports staging; this file is controlled by %s" 
backend)))
+      (user-error "Only Git supports staging; this file is controlled by %s" 
backend))))
+
+(defun diff-hl-stage-current-hunk ()
+  "Stage the hunk at or near point.
+
+Only supported with Git."
+  (interactive)
+  (diff-hl--ensure-staging-supported)
   (diff-hl-find-current-hunk)
   (let* ((line (line-number-at-pos))
          (file buffer-file-name)
@@ -715,6 +721,17 @@ its end position."
       (unless diff-hl-show-staged-changes
         (diff-hl-update)))))
 
+(defun diff-hl-unstage-file ()
+  (interactive)
+  "Unstage all changes in the current file.
+
+Only supported with Git."
+  (unless buffer-file-name
+    (user-error "No current file"))
+  (diff-hl--ensure-staging-supported)
+  (vc-git-command nil 0 buffer-file-name "reset")
+  (message "Unstaged all"))
+
 (defvar diff-hl-command-map
   (let ((map (make-sparse-keymap)))
     (define-key map "n" 'diff-hl-revert-hunk)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]