Skip to content

Commit

Permalink
Remove git-gutter+* packages as they are broken with latest magit
Browse files Browse the repository at this point in the history
this change removed git-gutter+ and git-gutter-fringe+ as
unmaintained packages from spacemacs. Those packages have produced
issues in conjunction with latest magit.

The prefered solution is now diff-hl.

To aovid breaking configs diff-hl will also be loaded when
git-gutter+ was explicitly requested this should give affected
users sometime to update their configs.

Fixes syl20bnr#16555
  • Loading branch information
smile13241324 committed Sep 6, 2024
1 parent e8c4612 commit f436be6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 111 deletions.
19 changes: 9 additions & 10 deletions layers/+source-control/version-control/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This layers adds general configuration for [[http://www.gnu.org/software/emacs/m
It should work with all VC backends such as Git, Mercurial, Bazaar, SVN, etc...

** Features:
- highlights uncommitted changes in the fringe or margin with [[https://github.com/dgutov/diff-hl][diff-hl]], [[https://github.com/syohex/emacs-git-gutter][git-gutter]], or [[https://github.com/nonsequitur/git-gutter-plus][git-gutter+]]
- highlights uncommitted changes in the fringe or margin with [[https://github.com/dgutov/diff-hl][diff-hl]] or [[https://github.com/syohex/emacs-git-gutter][git-gutter]]
- adds vcs transient-state ~SPC g.~ to allow quick navigation and modification of buffer hunks.

* Install
Expand All @@ -39,7 +39,6 @@ margins by setting the =version-control-diff-tool= variable to one of the
supported packages:
- [[https://github.com/dgutov/diff-hl][diff-hl]] (default)
- [[https://github.com/syohex/emacs-git-gutter][git-gutter]]
- [[https://github.com/nonsequitur/git-gutter-plus][git-gutter+]]

#+BEGIN_SRC emacs-lisp
'(version-control :variables
Expand All @@ -62,18 +61,18 @@ To automatically enable diff margins in all buffers, set
#+END_SRC

** Differences between margin packages
This layer contains generalized mappings for three diff margin packages:
=diff-hl=, =git-gutter=, and =git-gutter+=.
This layer contains generalized mappings for two different margin packages:
=diff-hl= and =git-gutter=.

There are some differences between packages that might have some people prefer
one over the other:

| Feature | diff-hl | git-gutter | git-gutter+ |
|-------------------------------------+---------+------------+-------------|
| Show in fringe | X | X | X |
| Extended VCS support (e.g. hg, svn) | X | X | |
| Stage hunks from buffer | | X | X |
| Dired support | X | | |
| Feature | diff-hl | git-gutter |
|-------------------------------------+---------+------------+
| Show in fringe | X | X |
| Extended VCS support (e.g. hg, svn) | X | X |
| Stage hunks from buffer | | X |
| Dired support | X | |

* Key bindings
VC commands:
Expand Down
36 changes: 1 addition & 35 deletions layers/+source-control/version-control/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,14 @@
"If non-nil, will show diff margins globally.")

(defvar version-control-diff-tool 'diff-hl
"Options are `git-gutter', `git-gutter+', and `diff-hl' to show
"Options are `diff-hl' (the prefered choice) or `git-gutter' to show
version-control markers.")

(defvar version-control-diff-side 'right
"Side on which to show version-control markers.
Options are `left' and `right'.")

;; unchanged face
(defface git-gutter+-unchanged
'((t (:background "yellow")))
"face for unchanged lines"
:group 'git-gutter+)
(defface git-gutter:unchanged
'((t (:background "yellow")))
"face for unchanged lines"
:group 'git-gutter+)

;; change face
(defface git-gutter+-modified
'((t (:foreground "magenta" :weight bold)))
"face for modified lines"
:group 'git-gutter+)
(defface git-gutter:modified
'((t (:foreground "magenta" :weight bold)))
"face for modified lines"
:group 'git-gutter+)
(defface diff-hl-change
'((default :foreground "blue3")
(((class color) (min-colors 88) (background light))
Expand All @@ -64,29 +46,13 @@ Options are `left' and `right'.")
:group 'diff-hl)

;; added face
(defface git-gutter+-added
'((t (:foreground "green" :weight bold)))
"face for added lines"
:group 'git-gutter+)
(defface git-gutter:added
'((t (:foreground "green" :weight bold)))
"face for added lines"
:group 'git-gutter+)
(defface diff-hl-insert
'((default :inherit diff-added)
(((class color)) :foreground "green4"))
"Face used to highlight inserted lines."
:group 'diff-hl)

;; deleted face
(defface git-gutter+-deleted
'((t (:foreground "red" :weight bold)))
"face for deleted lines"
:group 'git-gutter+)
(defface git-gutter:deleted
'((t (:foreground "red" :weight bold)))
"face for deleted lines"
:group 'git-gutter+)
(defface diff-hl-delete
'((default :inherit diff-removed)
(((class color)) :foreground "red3"))
Expand Down
79 changes: 13 additions & 66 deletions layers/+source-control/version-control/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
(defconst version-control-packages
'(
browse-at-remote
(diff-hl :toggle (eq 'diff-hl version-control-diff-tool))
;; Git-gutter+ is not longer maintained and will break with latest magit version
;; therefore we switch to diff-hl for users which have configered git-gutter+ to avoid
;; breaking there config.
(diff-hl :toggle (or (eq 'diff-hl version-control-diff-tool)
(eq 'git-gutter+ version-control-diff-tool)))
diff-mode
evil-unimpaired
(git-gutter :toggle (eq 'git-gutter version-control-diff-tool))
(git-gutter-fringe :toggle (eq 'git-gutter version-control-diff-tool))
(git-gutter+ :toggle (eq 'git-gutter+ version-control-diff-tool))
(git-gutter-fringe+ :toggle (eq 'git-gutter+ version-control-diff-tool))
(smerge-mode :location built-in)
(vc :location built-in)))

Expand Down Expand Up @@ -99,14 +101,14 @@
:eval-after-load vc-hg))
(with-eval-after-load 'vc-annotate
(evilified-state-evilify-map vc-annotate-mode-map
:mode vc-annotate-mode
:bindings
"J" 'vc-annotate-next-revision
"K" 'vc-annotate-prev-revision
"L" 'vc-annotate-show-log-revision-at-line
"H" 'vc-annotate-toggle-annotation-visibility
"a" 'vc-annotate-revision-at-line
"p" 'vc-annotate-revision-previous-to-line))))
:mode vc-annotate-mode
:bindings
"J" 'vc-annotate-next-revision
"K" 'vc-annotate-prev-revision
"L" 'vc-annotate-show-log-revision-at-line
"H" 'vc-annotate-toggle-annotation-visibility
"a" 'vc-annotate-revision-at-line
"p" 'vc-annotate-revision-previous-to-line))))

(defun version-control/init-diff-mode ()
(use-package diff-mode
Expand Down Expand Up @@ -193,61 +195,6 @@
(setq git-gutter-fr:side (if (eq version-control-diff-side 'left)
'left-fringe 'right-fringe))))

(defun version-control/init-git-gutter+ ()
(use-package git-gutter+
:if (eq version-control-diff-tool 'git-gutter+)
:defer t
:init
;; If you enable global minor mode
(when version-control-global-margin
(add-hook 'magit-pre-refresh-hook
#'spacemacs//git-gutter+-refresh-in-all-buffers)
(run-with-idle-timer 1 nil 'global-git-gutter+-mode))
(setq
git-gutter+-modified-sign " "
git-gutter+-added-sign "+"
git-gutter+-deleted-sign "-"
git-gutter+-diff-option "-w"
git-gutter+-hide-gutter t)
;; identify magit changes
:config
(spacemacs|hide-lighter git-gutter+-mode)
;; Do not activate git-gutter in pdf-view-mode, see #15106
(when (configuration-layer/layer-used-p 'pdf)
(add-to-list 'git-gutter+-disabled-modes 'pdf-view-mode))))

(defun version-control/init-git-gutter-fringe+ ()
(use-package git-gutter-fringe+
:defer t
:init
(spacemacs|do-after-display-system-init
(with-eval-after-load 'git-gutter+
(require 'git-gutter-fringe+)))
(setq git-gutter-fr+-side (if (eq version-control-diff-side 'left)
'left-fringe 'right-fringe))
:config
;; custom graphics that works nice with half-width fringes
(fringe-helper-define 'git-gutter-fr+-added nil
"..X...."
"..X...."
"XXXXX.."
"..X...."
"..X....")

(fringe-helper-define 'git-gutter-fr+-deleted nil
"......."
"......."
"XXXXX.."
"......."
".......")

(fringe-helper-define 'git-gutter-fr+-modified nil
"..X...."
".XXX..."
"XX.XX.."
".XXX..."
"..X....")))

(defun version-control/init-smerge-mode ()
(use-package smerge-mode
:defer t
Expand Down

0 comments on commit f436be6

Please sign in to comment.