From 60780379f715a5cf837a3a64d0bef54fb188022f Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Wed, 9 Jun 2010 14:36:29 -0700 Subject: [PATCH 01/25] Make sure the status buffer is updated after a rebase. --- magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magit.el b/magit.el index c03ad68d..ba06da8f 100644 --- a/magit.el +++ b/magit.el @@ -2939,7 +2939,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) From f846afe8507e5ca4cfdd7149b8b8ef13e13bc0cb Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Wed, 9 Jun 2010 22:26:13 -0700 Subject: [PATCH 02/25] Add an option to use "remote/name" style refs rather than "name (remote)". --- magit.el | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/magit.el b/magit.el index c03ad68d..1a20f50e 100644 --- a/magit.el +++ b/magit.el @@ -150,6 +150,16 @@ 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. + +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\"." + :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. @@ -571,12 +581,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)" - (match-string 2 ref) - (match-string 1 ref)) + (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)) From 7ef0b9e9cb357e760b929453ee72edae115d3686 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 10 Jun 2010 16:09:58 -0700 Subject: [PATCH 03/25] Make magit-update-remote respect a named remote above SVN. --- magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magit.el b/magit.el index c03ad68d..1069937c 100644 --- a/magit.el +++ b/magit.el @@ -2985,8 +2985,8 @@ 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)) + ((magit-svn-enabled) (magit-run-git-async "svn" "fetch")) (t (magit-run-git-async "remote" "update")))) (defun magit-pull () From c337dcc07cdbfd9e9724055708be249a40e746bf Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Wed, 16 Jun 2010 23:55:51 -0700 Subject: [PATCH 04/25] Make magit-name-rev a little cleaner. The main thing is using --no-undefined to eliminate an extra check. --- magit.el | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/magit.el b/magit.el index c03ad68d..7590e376 100644 --- a/magit.el +++ b/magit.el @@ -509,11 +509,9 @@ return nil." default-directory))))) (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)))) + (when rev + (let ((name (magit-git-string "name-rev" "--no-undefined" "--name-only" rev))) + (or name rev)))) (defun magit-put-line-property (prop val) (put-text-property (line-beginning-position) (line-beginning-position 2) From daa3ab8987db19194cbbf499af46738f0577861a Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 17 Jun 2010 00:10:35 -0700 Subject: [PATCH 05/25] Remove tags/ and remotes/ in name-rev when that doesn't create ambiguity. --- magit.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index 7590e376..b2080531 100644 --- a/magit.el +++ b/magit.el @@ -508,10 +508,22 @@ return nil." (or (magit-get-top-dir default-directory) default-directory))))) +(defun magit-ref-ambiguous-p (ref) + "Return whether or not REF is ambiguous." + (/= (magit-git-exit-code "rev-parse" "--abbrev-ref" ref) 0)) + (defun magit-name-rev (rev) + "Return a human-readable name for REV. +Unlike git name-rev, this will remove tags/ and remotes/ prefixes +if that can be done unambiguously." (when rev (let ((name (magit-git-string "name-rev" "--no-undefined" "--name-only" rev))) - (or name 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) From 8cc37dcb99abee8dd83481500b81e2aa32e985a2 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 17 Jun 2010 01:57:28 -0700 Subject: [PATCH 06/25] Fix ref ambiguity detection. --- magit.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index b2080531..1d54f9bb 100644 --- a/magit.el +++ b/magit.el @@ -510,7 +510,9 @@ return nil." (defun magit-ref-ambiguous-p (ref) "Return whether or not REF is ambiguous." - (/= (magit-git-exit-code "rev-parse" "--abbrev-ref" ref) 0)) + ;; 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) "Return a human-readable name for REV. From 2ea8cb2595328e685761258b15b307ba7629af29 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 24 Jun 2010 15:53:20 -0700 Subject: [PATCH 07/25] Add a magit-rev-parse function. --- magit.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/magit.el b/magit.el index 1d54f9bb..5e4863d4 100644 --- a/magit.el +++ b/magit.el @@ -508,6 +508,10 @@ 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, @@ -2935,7 +2939,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 "..")))) @@ -3765,7 +3769,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) From 1efde9202ce712495ed7010fac1c172be90d8b94 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 24 Jun 2010 15:56:54 -0700 Subject: [PATCH 08/25] Filter out HEAD refs from magit-name-rev. HEAD refs are nasty because they're highly contingent. Branches, tags, and remotes all require some commit to be made in order for the ref to point to a different rev, but HEADs just need something else to be checked out. Also, filtering out HEADs makes the name more portable. This is useful for Magithub, where the name may be passed on to GitHub. --- magit.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index 5e4863d4..81aaaee4 100644 --- a/magit.el +++ b/magit.el @@ -521,9 +521,23 @@ return nil." (defun magit-name-rev (rev) "Return a human-readable name for REV. Unlike git name-rev, this will remove tags/ and remotes/ prefixes -if that can be done unambiguously." +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 "^\\(.*\\" name)) + (setq name (magit-rev-parse ref))))) (setq rev (or name rev)) (when (string-match "^\\(?:tags\\|remotes\\)/\\(.*\\)" rev) (let ((plain-name (match-string 1 rev))) From 04984e5265fccc65822500b4daeebef66b4a7edc Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 29 Jun 2010 22:08:14 +0100 Subject: [PATCH 09/25] Checkout works again in the branch view. --- magit.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/magit.el b/magit.el index 884a4ecb..311633ab 100644 --- a/magit.el +++ b/magit.el @@ -4074,12 +4074,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." @@ -4093,6 +4088,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." @@ -4100,7 +4101,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)))) From b65979510e9ab71123ec87b022a9aadd30847105 Mon Sep 17 00:00:00 2001 From: Alan Falloon Date: Wed, 28 Apr 2010 10:10:00 +0800 Subject: [PATCH 10/25] Show branch name in "Remote:" section when tracking local branch When the current branch is tracking a local branch (the remote is ".") show the local upstream branch in the "Remote:" section. --- magit.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/magit.el b/magit.el index 311633ab..2f8e8a4a 100644 --- a/magit.el +++ b/magit.el @@ -2474,10 +2474,14 @@ insert a line to tell how to insert more of them" ;;; Status -(defun magit-remote-string (remote svn-info) - (if remote - (concat remote " " (magit-get "remote" remote "url")) - (when svn-info +(defun magit-remote-string (remote remote-branch svn-info) + (cond + ((string= "." remote) + (format "branch %s" + (propertize remote-branch 'face 'magit-branch))) + (remote + (concat remote " " (magit-get "remote" remote "url"))) + (svn-info (concat (cdr (assoc 'url svn-info)) " @ " (cdr (assoc 'revision svn-info)))))) @@ -2489,7 +2493,7 @@ insert a line to tell how to insert more of them" (remote (and branch (magit-get "branch" branch "remote"))) (remote-branch (or (and branch (magit-remote-branch-for branch)) branch)) (svn-info (magit-get-svn-ref-info)) - (remote-string (magit-remote-string remote svn-info)) + (remote-string (magit-remote-string remote remote-branch svn-info)) (head (magit-git-string "log" "--max-count=1" "--abbrev-commit" "--pretty=oneline")) (no-commit (not head))) From 809a5cb81c465a5deb6c109eca53d605ce49a109 Mon Sep 17 00:00:00 2001 From: Alan Falloon Date: Wed, 28 Apr 2010 09:35:50 +0800 Subject: [PATCH 11/25] Use just the branch name for unpushed/unpulled when the remote is "." When the remote is "." it signifies that the current branch is tracking another local branch, not a branch in one of the remotes. So, in that case, use just the branch name as the upstream branch instead of the "remote/branch" naming scheme. --- magit.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/magit.el b/magit.el index 2f8e8a4a..548b610d 100644 --- a/magit.el +++ b/magit.el @@ -2441,17 +2441,23 @@ 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))) + (defun magit-insert-unpulled-commits (remote branch) (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)))) (defun magit-insert-unpushed-commits (remote branch) (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-insert-unpulled-svn-commits (&optional use-cache) (magit-git-section 'svn-unpulled From 42a70d14cc5ac517bce2d810fc30b26ba2b7107d Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 29 Jun 2010 22:53:09 +0100 Subject: [PATCH 12/25] RET checks out a branch in the branch view. --- magit.el | 1 + 1 file changed, 1 insertion(+) diff --git a/magit.el b/magit.el index 548b610d..e80253d2 100644 --- a/magit.el +++ b/magit.el @@ -4061,6 +4061,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) From fd6f6d5ea7b209f8968dfcd999a20f84e6e63edc Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 29 Jun 2010 22:55:40 +0100 Subject: [PATCH 13/25] Manual entry for new branch mode binding. --- magit.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/magit.texi b/magit.texi index 23c8d528..fbbb9eae 100644 --- a/magit.texi +++ b/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. From dc49fde45e598812039623d77bf67410aea0e61e Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 29 Jun 2010 23:09:05 +0100 Subject: [PATCH 14/25] Replace slashes in tracking branch name suggestion. --- magit.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index e80253d2..02ab7340 100644 --- a/magit.el +++ b/magit.el @@ -2653,7 +2653,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 From bdba20d5ccc645b01401e6876005f86a0ca809ae Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Wed, 30 Jun 2010 15:55:01 +0100 Subject: [PATCH 15/25] Fixed the ref/rev typo. --- magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magit.el b/magit.el index 163ac635..c38dd2ed 100644 --- a/magit.el +++ b/magit.el @@ -550,7 +550,7 @@ out revs involving HEAD." modifier)) ;; If rev-parse doesn't give us what we want, just use the SHA. (when (or (null name) (string-match-p "\\" name)) - (setq name (magit-rev-parse ref))))) + (setq name (magit-rev-parse rev))))) (setq rev (or name rev)) (when (string-match "^\\(?:tags\\|remotes\\)/\\(.*\\)" rev) (let ((plain-name (match-string 1 rev))) From d4dd5c5da0f228c309084c31e3e38ec8207b2691 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 1 Jul 2010 09:52:00 +0100 Subject: [PATCH 16/25] Don't run magit-log-edit-mode-hook twice. --- magit.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/magit.el b/magit.el index 163ac635..996314fa 100644 --- a/magit.el +++ b/magit.el @@ -3160,8 +3160,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 From 997ecb4e104a75666e0f41cdadbf26d9682db784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 3 Jul 2010 00:31:48 +0800 Subject: [PATCH 17/25] magit-remote-ref-format: Improved documentation --- magit.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index 5c6c3af1..f62137cf 100644 --- a/magit.el +++ b/magit.el @@ -153,9 +153,15 @@ after a confirmation." (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\"." +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))) From 82883d1de353c06fc07f412fe5cac0b8321af837 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 5 Jul 2010 23:32:29 +0100 Subject: [PATCH 18/25] Removed old insert functions. --- magit.el | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/magit.el b/magit.el index b7b7af50..83b357dc 100644 --- a/magit.el +++ b/magit.el @@ -2521,43 +2521,19 @@ insert a line to tell how to insert more of them" (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" + "Unpulled commits:" 'magit-wash-log + "log" "--pretty=format:* %H %s" + (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 "HEAD..%s" + "Unpushed commits:" 'magit-wash-log + "log" "--pretty=format:* %H %s" + (format "HEAD..%s" (magit-remote-branch-name remote branch))))) -(defun magit-insert-unpulled-commits (remote branch) - (magit-git-section 'unpulled - "Unpulled commits:" 'magit-wash-log - "log" "--pretty=format:* %H %s" - (format "HEAD..%s/%s" remote branch))) - -(defun magit-insert-unpushed-commits (remote branch) - (magit-git-section 'unpushed - "Unpushed commits:" 'magit-wash-log - "log" "--pretty=format:* %H %s" - (format "%s/%s..HEAD" remote branch))) - -(defun magit-insert-unpulled-svn-commits (&optional use-cache) - (magit-git-section 'svn-unpulled - "Unpulled commits (SVN):" 'magit-wash-log - "log" "--pretty=format:* %H %s" - (format "HEAD..%s" (magit-get-svn-ref use-cache)))) - -(defun magit-insert-unpushed-svn-commits (&optional use-cache) - (magit-git-section 'svn-unpushed - "Unpushed commits (SVN):" 'magit-wash-log - "log" "--pretty=format:* %H %s" - (format "%s..HEAD" (magit-get-svn-ref use-cache)))) - (defun magit-remote-branch-for (local-branch) "Guess the remote branch name that LOCAL-BRANCH is tracking." (let ((merge (magit-get "branch" local-branch "merge"))) @@ -2592,11 +2568,11 @@ insert a line to tell how to insert more of them" (no-commit (not head))) (when remote-string (insert "Remote: " remote-string "\n")) - (insert (format "Local: %s %s\n" + (insert (format "Local: %s %s\n" (propertize (or branch "(detached)") 'face 'magit-branch) (abbreviate-file-name default-directory))) - (insert (format "Head: %s\n" + (insert (format "Head: %s\n" (if no-commit "nothing commited (yet)" head))) (let ((merge-heads (magit-file-lines ".git/MERGE_HEAD"))) (if merge-heads @@ -3027,7 +3003,6 @@ update it." (interactive (list (when current-prefix-arg (magit-read-remote)))) (cond (remote (magit-run-git-async "fetch" remote)) - ((magit-svn-enabled) (magit-run-git-async "svn" "fetch")) (t (magit-run-git-async "remote" "update")))) (magit-define-command pull () From e58b3c379ce2f57dc52c66f803c413eb2ad10723 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 5 Jul 2010 23:53:22 +0100 Subject: [PATCH 19/25] Added `magit-remote-branch-name'. Fixed unpushed args. --- magit.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/magit.el b/magit.el index 83b357dc..acc2af34 100644 --- a/magit.el +++ b/magit.el @@ -2518,6 +2518,12 @@ 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 @@ -2531,7 +2537,7 @@ insert a line to tell how to insert more of them" (magit-git-section 'unpushed "Unpushed commits:" 'magit-wash-log "log" "--pretty=format:* %H %s" - (format "HEAD..%s" + (format "%s..HEAD" (magit-remote-branch-name remote branch))))) (defun magit-remote-branch-for (local-branch) From 67af1eead8438177961da306ba5bacacc3068e3c Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Mon, 5 Jul 2010 23:54:23 +0100 Subject: [PATCH 20/25] Stop `magit-remote-string' expecting the svn-info cache. --- magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magit.el b/magit.el index acc2af34..e634ae7a 100644 --- a/magit.el +++ b/magit.el @@ -2551,7 +2551,7 @@ insert a line to tell how to insert more of them" (defvar magit-remote-string-hook nil) -(defun magit-remote-string (remote remote-branch svn-info) +(defun magit-remote-string (remote remote-branch) (cond ((string= "." remote) (format "branch %s" From f569ff83597fb805d3bf9562dbd9fca7c54fd049 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 6 Jul 2010 00:02:51 +0100 Subject: [PATCH 21/25] Fix `magit-refresh-status'. --- magit.el | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/magit.el b/magit.el index e634ae7a..c6ae0154 100644 --- a/magit.el +++ b/magit.el @@ -2567,18 +2567,17 @@ insert a line to tell how to insert more of them" (let* ((branch (magit-get-current-branch)) (remote (and branch (magit-get "branch" branch "remote"))) (remote-branch (or (and branch (magit-remote-branch-for branch)) branch)) - (svn-info (magit-get-svn-ref-info)) - (remote-string (magit-remote-string remote remote-branch svn-info)) + (remote-string (magit-remote-string remote remote-branch)) (head (magit-git-string "log" "--max-count=1" "--abbrev-commit" "--pretty=oneline")) (no-commit (not head))) (when remote-string (insert "Remote: " remote-string "\n")) - (insert (format "Local: %s %s\n" + (insert (format "Local: %s %s\n" (propertize (or branch "(detached)") 'face 'magit-branch) (abbreviate-file-name default-directory))) - (insert (format "Head: %s\n" + (insert (format "Head: %s\n" (if no-commit "nothing commited (yet)" head))) (let ((merge-heads (magit-file-lines ".git/MERGE_HEAD"))) (if merge-heads @@ -2593,17 +2592,15 @@ insert a line to tell how to insert more of them" (magit-git-exit-code "update-index" "--refresh") (magit-insert-untracked-files) (magit-insert-stashes) + (magit-insert-topics) (magit-insert-pending-changes) (magit-insert-pending-commits) - (when remote - (magit-insert-unpulled-commits remote 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:")) - (if staged - (magit-insert-staged-changes staged no-commit))) - (when remote - (magit-insert-unpushed-commits remote remote-branch)) + (magit-insert-staged-changes staged no-commit)) + (magit-insert-unpushed-commits remote branch) (run-hooks 'magit-refresh-status-hook))))) (defun magit-init (dir) From 9e457184916fc49878dcb28dbe9b94a042ee4a32 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 6 Jul 2010 00:07:37 +0100 Subject: [PATCH 22/25] Formatting. --- magit.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/magit.el b/magit.el index c6ae0154..6f71e917 100644 --- a/magit.el +++ b/magit.el @@ -2557,7 +2557,13 @@ insert a line to tell how to insert more of them" (format "branch %s" (propertize remote-branch 'face 'magit-branch))) (remote - (concat remote " " (magit-get "remote" remote "url"))) + (concat + (propertize remote-branch 'face 'magit-branch) + " @ " + remote + " (" + (magit-get "remote" remote "url") + ")")) (t (run-hook-with-args-until-success 'magit-remote-string-hook)))) @@ -2573,11 +2579,11 @@ insert a line to tell how to insert more of them" (no-commit (not head))) (when remote-string (insert "Remote: " remote-string "\n")) - (insert (format "Local: %s %s\n" + (insert (format "Local: %s %s\n" (propertize (or branch "(detached)") 'face 'magit-branch) (abbreviate-file-name default-directory))) - (insert (format "Head: %s\n" + (insert (format "Head: %s\n" (if no-commit "nothing commited (yet)" head))) (let ((merge-heads (magit-file-lines ".git/MERGE_HEAD"))) (if merge-heads From 6599b6ac579146553d681a5f37e323decf085973 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 6 Jul 2010 00:10:50 +0100 Subject: [PATCH 23/25] Use remote branch for unpushed ref. --- magit.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magit.el b/magit.el index 6f71e917..ce31ad63 100644 --- a/magit.el +++ b/magit.el @@ -2606,7 +2606,7 @@ insert a line to tell how to insert more of them" (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) From fd2fd4725c28f8377890c5c61ba403e171bfc734 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 6 Jul 2010 11:01:12 +0100 Subject: [PATCH 24/25] Make git svn fetch an explicit command rather than overriding remote-fetch. --- magit-svn.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/magit-svn.el b/magit-svn.el index 127bb8a1..5aab5bd3 100644 --- a/magit-svn.el +++ b/magit-svn.el @@ -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) From 64756e9940592f134a829da63de53764fb21ab69 Mon Sep 17 00:00:00 2001 From: Phil Jackson Date: Tue, 6 Jul 2010 11:03:18 +0100 Subject: [PATCH 25/25] Update manual with regards to the svn change. --- magit.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/magit.texi b/magit.texi index fbbb9eae..6c201330 100644 --- a/magit.texi +++ b/magit.texi @@ -679,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