Merge branch 't/upstream/extensions' into t/int/extensions
- fix dep to topgit in core - remove 'cl runtime dependency
This commit is contained in:
commit
71f76c9053
3 changed files with 157 additions and 82 deletions
|
@ -151,33 +151,32 @@ If USE-CACHE is non nil, use the cached information."
|
|||
(cdr (assoc 'revision svn-info))))))
|
||||
|
||||
(defun magit-svn-remote-update ()
|
||||
(interactive)
|
||||
(when (magit-svn-enabled)
|
||||
(magit-run-git-async "svn" "fetch")))
|
||||
|
||||
(defvar magit-svn-extension-keys
|
||||
`((,(kbd "N r") . magit-svn-rebase)
|
||||
(,(kbd "N c") . magit-svn-dcommit)
|
||||
(,(kbd "N f") . magit-svn-find-rev)))
|
||||
(,(kbd "N f") . magit-svn-remote-update)
|
||||
(,(kbd "N s") . magit-svn-find-rev)))
|
||||
|
||||
(easy-menu-define magit-svn-extension-menu
|
||||
nil
|
||||
"Git SVN extension menu"
|
||||
'("Git SVN"
|
||||
["Rebase" magit-svn-rebase (magit-svn-enabled)]
|
||||
["Fetch" magit-svn-remote-update (magit-svn-enabled)]
|
||||
["Commit" magit-svn-dcommit (magit-svn-enabled)]))
|
||||
|
||||
(defvar magit-svn-extension-inserters
|
||||
'((:after unpulled-commits (lambda () (magit-insert-svn-unpulled t)))
|
||||
(:after unpushed-commits (lambda () (magit-insert-svn-unpushed t)))))
|
||||
|
||||
(defvar magit-svn-extension-commands
|
||||
'((remote-update . magit-svn-remote-update)))
|
||||
|
||||
(defvar magit-svn-extension
|
||||
(make-magit-extension :keys magit-svn-extension-keys
|
||||
:menu magit-svn-extension-menu
|
||||
:insert magit-svn-extension-inserters
|
||||
:commands magit-svn-extension-commands
|
||||
:remote-string 'magit-svn-remote-string))
|
||||
|
||||
(magit-install-extension magit-svn-extension)
|
||||
|
|
143
magit.el
143
magit.el
|
@ -151,6 +151,22 @@ after a confirmation."
|
|||
:group 'magit
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom magit-remote-ref-format 'branch-then-remote
|
||||
"What format to use for autocompleting refs, in pariticular for remotes.
|
||||
|
||||
Autocompletion is used by functions like `magit-checkout',
|
||||
`magit-interactive-rebase' and others which offer branch name
|
||||
completion.
|
||||
|
||||
The value 'name-then-remote means remotes will be of the
|
||||
form \"name (remote)\", while the value 'remote-slash-name
|
||||
means that they'll be of the form \"remote/name\". I.e. something that's
|
||||
listed as \"remotes/upstream/next\" by \"git branch -l -a\"
|
||||
will be \"upstream/next\"."
|
||||
:group 'magit
|
||||
:type '(choice (const :tag "name (remote)" branch-then-remote)
|
||||
(const :tag "remote/name" remote-slash-branch)))
|
||||
|
||||
(defcustom magit-process-connection-type (not (eq system-type 'cygwin))
|
||||
"Connection type used for the git process.
|
||||
|
||||
|
@ -512,12 +528,42 @@ return nil."
|
|||
(or (magit-get-top-dir default-directory)
|
||||
default-directory)))))
|
||||
|
||||
(defun magit-rev-parse (ref)
|
||||
"Return the SHA hash for REF."
|
||||
(magit-git-string "rev-parse" ref))
|
||||
|
||||
(defun magit-ref-ambiguous-p (ref)
|
||||
"Return whether or not REF is ambiguous."
|
||||
;; If REF is ambiguous, rev-parse just prints errors,
|
||||
;; so magit-git-string returns nil.
|
||||
(not (magit-git-string "rev-parse" "--abbrev-ref" ref)))
|
||||
|
||||
(defun magit-name-rev (rev)
|
||||
(and rev
|
||||
(let ((name (magit-git-string "name-rev" "--name-only" rev)))
|
||||
(if (or (not name) (string= name "undefined"))
|
||||
rev
|
||||
name))))
|
||||
"Return a human-readable name for REV.
|
||||
Unlike git name-rev, this will remove tags/ and remotes/ prefixes
|
||||
if that can be done unambiguously. In addition, it will filter
|
||||
out revs involving HEAD."
|
||||
(when rev
|
||||
(let ((name (magit-git-string "name-rev" "--no-undefined" "--name-only" rev)))
|
||||
;; There doesn't seem to be a way of filtering HEAD out from name-rev,
|
||||
;; so we have to do it manually.
|
||||
;; HEAD-based names are too transient to allow.
|
||||
(when (string-match "^\\(.*\\<HEAD\\)\\([~^].*\\|$\\)" name)
|
||||
(let ((head-ref (match-string 1 name))
|
||||
(modifier (match-string 2 name)))
|
||||
;; Sometimes when name-rev gives a HEAD-based name,
|
||||
;; rev-parse will give an actual branch or remote name.
|
||||
(setq name (concat (magit-git-string "rev-parse" "--abbrev-ref" head-ref)
|
||||
modifier))
|
||||
;; If rev-parse doesn't give us what we want, just use the SHA.
|
||||
(when (or (null name) (string-match-p "\\<HEAD\\>" name))
|
||||
(setq name (magit-rev-parse rev)))))
|
||||
(setq rev (or name rev))
|
||||
(when (string-match "^\\(?:tags\\|remotes\\)/\\(.*\\)" rev)
|
||||
(let ((plain-name (match-string 1 rev)))
|
||||
(unless (magit-ref-ambiguous-p plain-name)
|
||||
(setq rev plain-name))))
|
||||
rev)))
|
||||
|
||||
(defun magit-put-line-property (prop val)
|
||||
(put-text-property (line-beginning-position) (line-beginning-position 2)
|
||||
|
@ -575,12 +621,20 @@ return nil."
|
|||
(let ((branch (match-string 1 ref)))
|
||||
(push (cons branch branch) refs)))
|
||||
((string-match "refs/tags/\\(.*\\)" ref)
|
||||
(push (cons (format "%s (tag)" (match-string 1 ref)) ref)
|
||||
(push (cons (format
|
||||
(if (eq magit-remote-ref-format 'branch-then-remote)
|
||||
"%s (tag)" "%s")
|
||||
(match-string 1 ref))
|
||||
ref)
|
||||
refs))
|
||||
((string-match "refs/remotes/\\([^/]+\\)/\\(.+\\)" ref)
|
||||
(push (cons (format "%s (%s)"
|
||||
(push (cons (if (eq magit-remote-ref-format 'branch-then-remote)
|
||||
(format "%s (%s)"
|
||||
(match-string 2 ref)
|
||||
(match-string 1 ref))
|
||||
(format "%s/%s"
|
||||
(match-string 1 ref)
|
||||
(match-string 2 ref)))
|
||||
ref)
|
||||
refs))))))
|
||||
refs))
|
||||
|
@ -1302,8 +1356,7 @@ FUNC should leave point at the end of the modified region"
|
|||
,doc
|
||||
,inter
|
||||
(or (run-hook-with-args-until-success
|
||||
',hook ,@(remove-if (lambda (x) (member x '(&optional &rest)))
|
||||
arglist))
|
||||
',hook ,@(remq '&optional (remq '&rest arglist)))
|
||||
,@instr))))
|
||||
|
||||
;;; Running commands
|
||||
|
@ -2464,19 +2517,27 @@ insert a line to tell how to insert more of them"
|
|||
(or magit-marked-commit
|
||||
(error "No commit marked")))
|
||||
|
||||
(defun magit-remote-branch-name (remote branch)
|
||||
"Get the name of the branch BRANCH on remote REMOTE"
|
||||
(if (string= remote ".")
|
||||
branch
|
||||
(concat remote "/" branch)))
|
||||
|
||||
(magit-define-inserter unpulled-commits (remote branch)
|
||||
(when remote
|
||||
(magit-git-section 'unpulled
|
||||
"Unpulled commits:" 'magit-wash-log
|
||||
"log" "--pretty=format:* %H %s"
|
||||
(format "HEAD..%s/%s" remote branch))))
|
||||
(format "HEAD..%s"
|
||||
(magit-remote-branch-name remote branch)))))
|
||||
|
||||
(magit-define-inserter unpushed-commits (remote branch)
|
||||
(when remote
|
||||
(magit-git-section 'unpushed
|
||||
"Unpushed commits:" 'magit-wash-log
|
||||
"log" "--pretty=format:* %H %s"
|
||||
(format "%s/%s..HEAD" remote branch))))
|
||||
(format "%s..HEAD"
|
||||
(magit-remote-branch-name remote branch)))))
|
||||
|
||||
(defun magit-remote-branch-for (local-branch)
|
||||
"Guess the remote branch name that LOCAL-BRANCH is tracking."
|
||||
|
@ -2489,19 +2550,29 @@ insert a line to tell how to insert more of them"
|
|||
|
||||
(defvar magit-remote-string-hook nil)
|
||||
|
||||
(defun magit-remote-string (remote)
|
||||
(if remote
|
||||
(concat remote " " (magit-get "remote" remote "url"))
|
||||
(run-hook-with-args-until-success 'magit-remote-string-hook)))
|
||||
|
||||
(defvar magit-refresh-status-hook nil)
|
||||
(defun magit-remote-string (remote remote-branch)
|
||||
(cond
|
||||
((string= "." remote)
|
||||
(format "branch %s"
|
||||
(propertize remote-branch 'face 'magit-branch)))
|
||||
(remote
|
||||
(concat
|
||||
(propertize remote-branch 'face 'magit-branch)
|
||||
" @ "
|
||||
remote
|
||||
" ("
|
||||
(magit-get "remote" remote "url")
|
||||
")"))
|
||||
(t
|
||||
(run-hook-with-args-until-success 'magit-remote-string-hook))))
|
||||
|
||||
(defun magit-refresh-status ()
|
||||
(magit-create-buffer-sections
|
||||
(magit-with-section 'status nil
|
||||
(let* ((branch (magit-get-current-branch))
|
||||
(remote (and branch (magit-get "branch" branch "remote")))
|
||||
(remote-string (magit-remote-string remote))
|
||||
(remote-branch (or (and branch (magit-remote-branch-for branch)) branch))
|
||||
(remote-string (magit-remote-string remote remote-branch))
|
||||
(head (magit-git-string
|
||||
"log" "--max-count=1" "--abbrev-commit" "--pretty=oneline"))
|
||||
(no-commit (not head)))
|
||||
|
@ -2528,12 +2599,12 @@ insert a line to tell how to insert more of them"
|
|||
(magit-insert-stashes)
|
||||
(magit-insert-pending-changes)
|
||||
(magit-insert-pending-commits)
|
||||
(magit-insert-unpulled-commits remote branch)
|
||||
(magit-insert-unpulled-commits remote remote-branch)
|
||||
(let ((staged (or no-commit (magit-anything-staged-p))))
|
||||
(magit-insert-unstaged-changes
|
||||
(if staged "Unstaged changes:" "Changes:"))
|
||||
(magit-insert-staged-changes staged no-commit))
|
||||
(magit-insert-unpushed-commits remote branch)
|
||||
(magit-insert-unpushed-commits remote remote-branch)
|
||||
(run-hooks 'magit-refresh-status-hook)))))
|
||||
|
||||
(defun magit-init (dir)
|
||||
|
@ -2648,7 +2719,9 @@ With prefix argument, add remaining untracked files as well.
|
|||
tracking brach name suggesting a sensible default."
|
||||
(when (yes-or-no-p
|
||||
(format "Create local tracking branch for %s? " branch))
|
||||
(let* ((default-name (concat remote "-" branch))
|
||||
(let* ((default-name (concat remote
|
||||
"-"
|
||||
(replace-regexp-in-string "[/]" "-" branch)))
|
||||
(chosen-name (read-string (format "Call local branch (%s): " default-name)
|
||||
nil
|
||||
nil
|
||||
|
@ -2874,7 +2947,7 @@ Uncomitted changes in both working tree and staging area are lost.
|
|||
(error "You have uncommitted changes"))
|
||||
(or (not (magit-read-rewrite-info))
|
||||
(error "Rewrite in progress"))
|
||||
(let* ((orig (magit-git-string "rev-parse" "HEAD"))
|
||||
(let* ((orig (magit-rev-parse "HEAD"))
|
||||
(base (or (car (magit-commit-parents from))
|
||||
(error "Can't rewrite a commit without a parent, sorry")))
|
||||
(pending (magit-git-lines "rev-list" (concat base ".."))))
|
||||
|
@ -2890,7 +2963,7 @@ Uncomitted changes in both working tree and staging area are lost.
|
|||
(when (or noconfirm
|
||||
(yes-or-no-p "Stop rewrite? "))
|
||||
(magit-write-rewrite-info nil)
|
||||
(magit-need-refresh))))
|
||||
(magit-refresh))))
|
||||
|
||||
(defun magit-rewrite-abort ()
|
||||
(interactive)
|
||||
|
@ -2936,7 +3009,6 @@ prefix arg is given. With prefix arg, prompt for a remote and
|
|||
update it."
|
||||
(interactive (list (when current-prefix-arg (magit-read-remote))))
|
||||
(cond
|
||||
((magit-svn-enabled) (magit-run-git-async "svn" "fetch"))
|
||||
(remote (magit-run-git-async "fetch" remote))
|
||||
(t (magit-run-git-async "remote" "update"))))
|
||||
|
||||
|
@ -3037,8 +3109,7 @@ Prefix arg means justify as well."
|
|||
|
||||
(define-derived-mode magit-log-edit-mode text-mode "Magit Log Edit"
|
||||
(set (make-local-variable 'fill-paragraph-function)
|
||||
'magit-log-fill-paragraph)
|
||||
(run-mode-hooks 'magit-log-edit-mode-hook))
|
||||
'magit-log-fill-paragraph))
|
||||
|
||||
(defun magit-log-edit-cleanup ()
|
||||
(save-excursion
|
||||
|
@ -3686,7 +3757,7 @@ level commits."
|
|||
(dolist (branch branches)
|
||||
(let* ((name (car branch))
|
||||
(ref (cdr branch))
|
||||
(hash (magit-git-string "rev-parse" ref))
|
||||
(hash (magit-rev-parse ref))
|
||||
(reported-branch (gethash hash reported)))
|
||||
(unless (or (and reported-branch
|
||||
(string= (file-name-nondirectory ref)
|
||||
|
@ -3930,6 +4001,7 @@ Return values:
|
|||
|
||||
(defvar magit-show-branches-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "RET") 'magit-branches-window-checkout)
|
||||
(define-key map (kbd "b") 'magit-branches-window-checkout)
|
||||
(define-key map (kbd "k") 'magit-remove-branch)
|
||||
(define-key map (kbd "m") 'magit-branches-window-manual-merge)
|
||||
|
@ -3953,12 +4025,7 @@ Return values:
|
|||
|
||||
(defun magit--branch-name-from-line (line)
|
||||
"Extract the branch name from line LINE of 'git branch' output."
|
||||
(let ((branch (get-text-property 0 'branch-name line)))
|
||||
(if (and branch
|
||||
(get-text-property 0 'remote line)
|
||||
(string-match-p "^remotes/" branch))
|
||||
(substring branch 8)
|
||||
branch)))
|
||||
(get-text-property 0 'branch-name line))
|
||||
|
||||
(defun magit--branch-name-at-point ()
|
||||
"Get the branch name in the line at point."
|
||||
|
@ -3972,6 +4039,12 @@ Return values:
|
|||
(save-excursion
|
||||
(magit-show-branches)))
|
||||
|
||||
(defun magit-remove-remote (ref)
|
||||
"Return REF with any remote part removed."
|
||||
(if (string-match "^remotes/" ref)
|
||||
(substring ref 8)
|
||||
ref))
|
||||
|
||||
(defun magit-remove-branch (&optional force)
|
||||
"Remove the branch in the line at point.
|
||||
With prefix force the removal even it it hasn't been merged."
|
||||
|
@ -3979,7 +4052,9 @@ With prefix force the removal even it it hasn't been merged."
|
|||
(let ((args (list "branch"
|
||||
(if force "-D" "-d")
|
||||
(when (magit--is-branch-at-point-remote) "-r")
|
||||
(magit--branch-name-at-point))))
|
||||
;; remove the remotes part
|
||||
(magit-remove-remote
|
||||
(magit--branch-name-at-point)))))
|
||||
(save-excursion
|
||||
(apply 'magit-run-git (remq nil args))
|
||||
(magit-show-branches))))
|
||||
|
|
11
magit.texi
11
magit.texi
|
@ -500,7 +500,8 @@ local branch. Deleting works for both local and remote branches.
|
|||
You can merge the branch in the current line by typing @kbd{m} for a
|
||||
manual merge and @kbd{M} for an automatic merge.
|
||||
|
||||
With @kbd{b} you can check out the branch in the current line.
|
||||
With @kbd{RET} or @kbd{b} you can check out the branch in the current
|
||||
line.
|
||||
|
||||
Typing @kbd{$} shows the @code{*magit-process*} buffer which contains
|
||||
the transcript of the most recent command.
|
||||
|
@ -678,13 +679,13 @@ Magit shows them in a section called @emph{Unpulled changes}. Typing
|
|||
@node Interfacing with Subversion
|
||||
@chapter Interfacing with Subversion
|
||||
|
||||
Typing @kbd{N r} runs @code{git svn rebase} and typing @kbd{N c} runs
|
||||
@code{git svn dcommit}.
|
||||
Typing @kbd{N r} runs @code{git svn rebase}, typing @kbd{N c} runs
|
||||
@code{git svn dcommit} and typing @kbd{N f} runs @code{git svn fetch}.
|
||||
|
||||
@kbd{N f} will prompt you for a (numeric, Subversion) revision and
|
||||
@kbd{N s} will prompt you for a (numeric, Subversion) revision and
|
||||
then search for a corresponding Git sha1 for the commit. This is
|
||||
limited to the path of the remote Subversion repository. With a prefix
|
||||
(@kbd{C-u N f} the user will also be prompted for a branch to search
|
||||
(@kbd{C-u N s} the user will also be prompted for a branch to search
|
||||
in.
|
||||
|
||||
@node Using Git Directly
|
||||
|
|
Loading…
Reference in a new issue