stgit.el no longer refreshes the Index/Work Tree section after state-changing commands such as stgit-toggle-index (i) when stgit-show-worktree-mode is center and the stack has unapplied patches.
Symptoms
In an stgit-mode buffer:
- Have at least one unapplied patch.
- Use the default/center worktree placement.
- Put a modified file in the Work Tree section.
- Press
i on the file to move it to the index.
Actual behavior:
- Git state changes correctly.
- The
*stgit* buffer still shows the file in Work Tree.
- Pressing
g performs a full reload and then the buffer shows the correct state.
Expected behavior:
- The Index and Work Tree sections should refresh immediately after
i, as they used to.
Cause
This appears to be a regression from commit 04559f0 (stgit.el: Enable lexical-binding).
When stgit-show-worktree-mode is center, stgit-run-series-insert-index may be called while parsing stg series output inside with-temp-buffer. Since stgit-index-node and stgit-worktree-node are buffer-local, the current implementation stores them in the temporary buffer, not the real stgit-mode buffer.
As a result, after reload in this layout:
stgit-index-node ;; nil in the stgit buffer
stgit-worktree-node ;; nil in the stgit buffer
Then commands like stgit-toggle-index call:
(stgit-refresh-worktree)
(stgit-refresh-index)
but both are no-ops because the node variables are nil. A full stgit-reload still works, which is why pressing g fixes the display.
Local workaround
This override fixes the issue locally:
;; local patch on upstream stgit regression that does not update the worktree view
;; after git commands (e.g., 'i') in the stgit-show-worktree-mode center.
;; 'bottom' mode is not affected by the bug.
(with-eval-after-load 'stgit
(defun stgit-run-series-insert-index (ewoc)
"Insert Index and Work Tree nodes and remember them in the stgit buffer."
(let ((index-node
(ewoc-enter-last ewoc
(make-stgit-patch
:status 'index
:name :index
:desc nil
:empty nil)))
(worktree-node
(ewoc-enter-last ewoc
(make-stgit-patch
:status 'work
:name :work
:desc nil
:empty nil))))
(with-current-buffer (ewoc--buffer ewoc)
(setq stgit-index-node (cons ewoc index-node)
stgit-worktree-node (cons ewoc worktree-node))))))
This preserves center mode and restores immediate refresh after i.
stgit.elno longer refreshes the Index/Work Tree section after state-changing commands such asstgit-toggle-index(i) whenstgit-show-worktree-modeiscenterand the stack has unapplied patches.Symptoms
In an
stgit-modebuffer:ion the file to move it to the index.Actual behavior:
*stgit*buffer still shows the file in Work Tree.gperforms a full reload and then the buffer shows the correct state.Expected behavior:
i, as they used to.Cause
This appears to be a regression from commit 04559f0 (
stgit.el: Enable lexical-binding).When
stgit-show-worktree-modeiscenter,stgit-run-series-insert-indexmay be called while parsingstg seriesoutput insidewith-temp-buffer. Sincestgit-index-nodeandstgit-worktree-nodeare buffer-local, the current implementation stores them in the temporary buffer, not the realstgit-modebuffer.As a result, after reload in this layout:
Then commands like stgit-toggle-index call:
but both are no-ops because the node variables are nil. A full stgit-reload still works, which is why pressing g fixes the display.
Local workaround
This override fixes the issue locally:
This preserves center mode and restores immediate refresh after i.