summaryrefslogtreecommitdiff
path: root/tissue
diff options
context:
space:
mode:
Diffstat (limited to 'tissue')
-rw-r--r--tissue/git.scm51
1 files changed, 26 insertions, 25 deletions
diff --git a/tissue/git.scm b/tissue/git.scm
index c837da7..562e715 100644
--- a/tissue/git.scm
+++ b/tissue/git.scm
@@ -1,5 +1,5 @@
;;; tissue --- Text based issue tracker
-;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2022, 2023 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of tissue.
;;;
@@ -152,9 +152,10 @@ to a file on the filesystem or in REPOSITORY."
(call-with-port (open-bytevector-input-port (blob-content blob))
proc)))))
-(define (commit-deltas repository commit)
- "Return the list of <diff-delta> objects created by COMMIT with
-respect to its first parent in REPOSITORY."
+(define (commit-file-changes repository commit)
+ "Return a list of pairs describing files modified by COMMIT with
+respect to its first parent in REPOSITORY. Each pair maps the old
+filename before COMMIT to the new filename after COMMIT."
(match (commit-parents commit)
((parent _ ...)
(let ((diff (diff-tree-to-tree repository
@@ -162,7 +163,9 @@ respect to its first parent in REPOSITORY."
(commit-tree commit))))
(diff-find-similar! diff)
(diff-fold (lambda (delta progress result)
- (cons delta result))
+ (cons (cons (diff-file-path (diff-delta-old-file delta))
+ (diff-file-path (diff-delta-new-file delta)))
+ result))
(lambda (delta binary result)
result)
(lambda (delta hunk result)
@@ -171,7 +174,9 @@ respect to its first parent in REPOSITORY."
result)
(list)
diff)))
- (() (list))))
+ (() (map (lambda (file)
+ (cons file file))
+ (tree-list (commit-tree commit))))))
(define (file-modification-table repository)
"Return a hashtable mapping files to the list of commits in REPOSITORY
@@ -180,25 +185,21 @@ that modified them."
(renames (make-hashtable string-hash string=?)))
(fold-commits
(lambda (commit _)
- (map (lambda (delta)
- ;; Map old filename to current filename if they are
- ;; different. Note that this manner of following renames
- ;; requires a linear git history and will not work with
- ;; branch merges.
- (unless (string=? (diff-file-path (diff-delta-old-file delta))
- (diff-file-path (diff-delta-new-file delta)))
- (hashtable-set! renames
- (diff-file-path (diff-delta-old-file delta))
- (diff-file-path (diff-delta-new-file delta))))
- (hashtable-update! result
- ;; If necessary, translate old
- ;; filename to current filename.
- (hashtable-ref renames
- (diff-file-path (diff-delta-old-file delta))
- (diff-file-path (diff-delta-old-file delta)))
- (cut cons commit <>)
- (list)))
- (commit-deltas repository commit)))
+ (map (match-lambda
+ ((old-file . new-file)
+ ;; Map old filename to current filename if they are
+ ;; different. Note that this manner of following renames
+ ;; requires a linear git history and will not work with
+ ;; branch merges.
+ (unless (string=? old-file new-file)
+ (hashtable-set! renames old-file new-file))
+ (hashtable-update! result
+ ;; If necessary, translate old
+ ;; filename to current filename.
+ (hashtable-ref renames old-file old-file)
+ (cut cons commit <>)
+ (list))))
+ (commit-file-changes repository commit)))
#f
repository)
result))