diff options
| author | Craig Jennings <c@cjennings.net> | 2025-09-03 01:07:16 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-09-03 01:07:16 -0500 |
| commit | b8a70190b9d46d75e7c7afb07d7cd6f0fd45bdbf (patch) | |
| tree | 1fc2ddd7aed7b0b841c29591f1f110096619df80 /modules/vc-config.el | |
| parent | 5e2ecb3ca80861e50ffd26b52e6fd25731ca9666 (diff) | |
| download | dotemacs-b8a70190b9d46d75e7c7afb07d7cd6f0fd45bdbf.tar.gz dotemacs-b8a70190b9d46d75e7c7afb07d7cd6f0fd45bdbf.zip | |
fix(git-timemachine): Display date information in commit selection
Add date information to the git-timemachine commit selection view
and disable sorting to maintain chronological order of commits. The
function now includes proper debugging and handles missing date
information gracefully.
Diffstat (limited to 'modules/vc-config.el')
| -rw-r--r-- | modules/vc-config.el | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/modules/vc-config.el b/modules/vc-config.el index ac51f8f1..e9f6fd90 100644 --- a/modules/vc-config.el +++ b/modules/vc-config.el @@ -50,13 +50,24 @@ ;; ------------------------------ Git Timemachine ------------------------------ ;; walk through revisions of the current file in your buffer ;; also: https://blog.binchen.org/posts/new-git-timemachine-ui-based-on-ivy-mode/ + (defun cj/git-timemachine-show-selected-revision () "Show last (current) revision of file." (interactive) (let* ((collection (mapcar (lambda (rev) + ;; First, let's debug the structure of a revision + (message "Revision structure: %S" rev) ;; re-shape list for the ivy-read - (cons (concat (substring-no-properties (nth 0 rev) 0 7) " | " (nth 5 rev) " | " (nth 6 rev)) rev)) + (cons (concat (substring-no-properties (nth 0 rev) 0 7) + " | " + ;; Use the date-time string directly if available + (or (nth 3 rev) "No date") + " | " + (nth 5 rev) + " | " + (nth 6 rev)) + rev)) (git-timemachine--revisions)))) (ivy-read "commits:" collection @@ -64,7 +75,28 @@ ;; compatible with ivy 9+ and ivy 8 (unless (string-match-p "^[a-z0-9]*$" (car rev)) (setq rev (cdr rev))) - (git-timemachine-show-revision rev))))) + (git-timemachine-show-revision rev)) + :sort nil + :preselect 0))) + +;; (defun cj/git-timemachine-show-selected-revision () +;; "Show last (current) revision of file." +;; (interactive) +;; (let* ((collection +;; (mapcar (lambda (rev) +;; ;; re-shape list for the ivy-read +;; (cons (concat (substring-no-properties (nth 0 rev) 0 7) " | " (nth 5 rev) " | " (nth 6 rev)) rev)) +;; (git-timemachine--revisions)))) +;; (ivy-read "commits:" +;; collection +;; :action (lambda (rev) +;; ;; compatible with ivy 9+ and ivy 8 +;; (unless (string-match-p "^[a-z0-9]*$" (car rev)) +;; (setq rev (cdr rev))) +;; (git-timemachine-show-revision rev)) +;; :sort nil ;; Disable sorting +;; :preselect 0))) ;; Preselect the most recent commit + (defun cj/git-timemachine () "Open git snapshot with the selected version. Based on ivy-mode." |
