Skip to content

Commit eb8933f

Browse files
committed
Fix the "hide-staged but nil reference" behavior and update the tests
1 parent 44b160a commit eb8933f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RM ?= rm -f
1515
all: compile test
1616

1717
test:
18-
$(EMACS) -batch -L . -l test/diff-hl-test.el -f ert-run-tests-batch-and-exit
18+
$(EMACS) -batch -L . -l test/diff-hl-test.el -l test/diff-hl-adjust-test.el -f ert-run-tests-batch-and-exit
1919

2020
compile:
2121
$(EMACS) -batch -L . -f batch-byte-compile $(SOURCES)

diff-hl.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ It can be a relative expression as well, such as \"HEAD^\" with Git, or
431431
diff-hl-reference-revision
432432
(diff-hl-modified-p state))
433433
(let* ((ref-changes
434-
(and diff-hl-reference-revision
434+
(and (or diff-hl-reference-revision
435+
hide-staged)
435436
(diff-hl-changes-from-buffer
436437
(diff-hl-changes-buffer file backend (if hide-staged
437438
'git-index

test/diff-hl-test.el

+10-6
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,16 @@
164164
(let ((diff-hl-show-staged-changes t))
165165
(should
166166
(equal (diff-hl-changes)
167-
'((1 1 insert)
168-
(12 1 insert)))))
167+
'((:reference . nil)
168+
(:working
169+
.
170+
((1 1 0 insert)
171+
(12 1 0 insert)))))))
169172
(let ((diff-hl-show-staged-changes nil))
170173
(should
171174
(equal (diff-hl-changes)
172-
'((12 1 insert)))))))
175+
'((:reference . ((1 1 0 insert)))
176+
(:working . ((12 1 0 insert)))))))))
173177

174178
(diff-hl-deftest diff-hl-flydiff-can-ignore-staged-changes ()
175179
(diff-hl-test-in-source
@@ -183,13 +187,13 @@
183187
(should
184188
(equal (diff-hl-changes-from-buffer
185189
(diff-hl-diff-buffer-with-reference buffer-file-name))
186-
'((1 1 insert)
187-
(12 1 insert)))))
190+
'((1 1 0 insert)
191+
(12 1 0 insert)))))
188192
(let ((diff-hl-show-staged-changes nil))
189193
(should
190194
(equal (diff-hl-changes-from-buffer
191195
(diff-hl-diff-buffer-with-reference buffer-file-name))
192-
'((12 1 insert)))))))
196+
'((12 1 0 insert)))))))
193197

194198
(diff-hl-deftest diff-hl-can-split-away-no-trailing-newline ()
195199
(diff-hl-test-in-source

0 commit comments

Comments
 (0)