aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2025-09-22 16:47:37 +0200
committerJonas Bernoulli <jonas@bernoul.li>2025-09-22 16:47:37 +0200
commit2d1c55295bb0f94ce68ff42eef78def9be96d484 (patch)
tree05c8e356bc483a9780aeeffc11b5d79afbecf4dc /lisp
parentfb5988d9d65de00a95542b772f36600b9f8e5b85 (diff)
magit-read-shelved-branch: New function
Diffstat (limited to 'lisp')
-rw-r--r--lisp/magit-branch.el7
-rw-r--r--lisp/magit-git.el9
2 files changed, 10 insertions, 6 deletions
diff --git a/lisp/magit-branch.el b/lisp/magit-branch.el
index 71d930d..7e252d3 100644
--- a/lisp/magit-branch.el
+++ b/lisp/magit-branch.el
@@ -827,12 +827,7 @@ and also rename the respective reflog file."
Rename \"refs/shelved/BRANCH\" to \"refs/heads/BRANCH\". If BRANCH
is prefixed with \"YYYY-MM-DD\", then drop that part of the name.
Also rename the respective reflog file."
- (interactive
- (list (magit-completing-read
- "Unshelve branch"
- (mapcar (##substring % 8)
- (nreverse (magit-list-refnames "refs/shelved")))
- nil t)))
+ (interactive (list (magit-read-shelved-branch "Unshelve branch")))
(let ((old (concat "refs/shelved/" branch))
(new (concat "refs/heads/"
(if (string-match-p
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 7e62da8..b1679c5 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2851,6 +2851,15 @@ out. Only existing branches can be selected."
(string-match "^\\([^ ]+\\) \\(.+\\)" choice)
(substring-no-properties (match-str 1 choice)))))
+(defun magit-read-shelved-branch (prompt)
+ (magit-completing-read
+ prompt
+ (mapcar (##substring % 8)
+ (nreverse (magit-list-refnames "refs/shelved")))
+ nil t nil nil
+ (and$ (magit-section-value-if 'shelved-branch)
+ (substring $ 13))))
+
(defun magit-read-remote (prompt &optional default use-only)
(let ((remotes (magit-list-remotes)))
(if (and use-only (length= remotes 1))