How embarassing. My first patch didn't work. Please disregard my earlier message and consider the attached patch instead. Sorry...
Graham On Tue, Aug 17, 2010 at 3:14 PM, Graham Clark <[email protected]> wrote: > Hi - please find attached an attempt to fix the "ambiguous argument" error > message displayed when magit-status is run on a repository that features a > branch spec that looks like > > branches = branches/{a,b,c}:refs/remotes/* > > Best wishes, > Graham > >
From ffe747f76a2bf6c95c95f3169beeebfaaaef4533 Mon Sep 17 00:00:00 2001 From: Graham Clark <g...@indiana.(none)> Date: Tue, 17 Aug 2010 15:09:24 -0400 Subject: [PATCH] My .git/config svn-remote section looked like this: [svn-remote "svn"] url = https://server/svn/Product fetch = trunk:refs/remotes/trunk branches = branches/{a,b,c}:refs/remotes/* I did this to only pull down the commits I needed to work with branches a, b and c. However when I ran magit-status on my repository, I'd see Unpulled commits (SVN): fatal: ambiguous argument 'HEAD..nil': unknown revision or path not in the working tree. Use '--' to separate paths from revisions Unpushed commits (SVN): fatal: ambiguous argument 'nil..HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions This change adjusts magit-svn-get-local-ref to handle the "branches" format shown above by treating branches = branches/{a,b,c}:refs/remotes/* like branches = branches/a:refs/remotes/a branches = branches/b:refs/remotes/b branches = branches/c:refs/remotes/c --- magit-svn.el | 52 +++++++++++++++++++++++++++++++++++----------------- 1 files changed, 35 insertions(+), 17 deletions(-) diff --git a/magit-svn.el b/magit-svn.el index 5aab5bd..e6cda39 100644 --- a/magit-svn.el +++ b/magit-svn.el @@ -59,26 +59,44 @@ (defun magit-svn-enabled () (not (null (magit-svn-get-ref-info)))) +(defun magit-svn-flatten (list) + (mapcan (lambda (x) (if (listp x) x nil)) list)) + +(defun magit-svn-expand-braces-in-branches (branch) + (if (not (string-match "\\(.+\\){\\(.+,.+\\)}\\(.*\\):\\(.*\\)\\\*" branch)) + (list branch) + (let ((prefix (match-string 1 branch)) + (suffix (match-string 3 branch)) + (rhs (match-string 4 branch)) + (pieces (split-string (match-string 2 branch) ",")) + ) + (mapcar (lambda (p) (concat prefix p suffix ":" rhs p)) pieces) + ))) + (defun magit-svn-get-local-ref (url) - (let ((branches (cons (magit-get "svn-remote" "svn" "fetch") - (magit-get-all "svn-remote" "svn" "branches"))) - (base-url (magit-get "svn-remote" "svn" "url")) - (result nil)) + (let* ((branches (cons (magit-get "svn-remote" "svn" "fetch") + (magit-get-all "svn-remote" "svn" "branches"))) + (branches (magit-svn-flatten (mapcar 'magit-svn-expand-braces-in-branches branches))) + (base-url (magit-get "svn-remote" "svn" "url")) + (result nil)) (while branches (let* ((pats (split-string (pop branches) ":")) - (src (replace-regexp-in-string "\\*" "\\\\(.*\\\\)" (car pats))) - (dst (replace-regexp-in-string "\\*" "\\\\1" (cadr pats))) - (base-url (replace-regexp-in-string "\\+" "\\\\+" base-url)) - (pat1 (concat "^" src "$")) - (pat2 (cond ((equal src "") (concat "^" base-url "$")) - (t (concat "^" base-url "/" src "$"))))) - (cond ((string-match pat1 url) - (setq result (replace-match dst nil nil url)) - (setq branches nil)) - ((string-match pat2 url) - (setq result (replace-match dst nil nil url)) - (setq branches nil))))) - result)) + (src (replace-regexp-in-string "\\*" "\\\\(.*\\\\)" (car pats))) + (dst (replace-regexp-in-string "\\*" "\\\\1" (cadr pats))) + (base-url (replace-regexp-in-string "\\+" "\\\\+" base-url)) + (pat1 (concat "^" src "$")) + (pat2 (cond ((equal src "") (concat "^" base-url "$")) + (t (concat "^" base-url "/" src "$")))) + ) + (cond ((string-match pat1 url) + (setq result (replace-match dst nil nil url)) + (setq branches nil)) + ((string-match pat2 url) + (setq result (replace-match dst nil nil url)) + (setq branches nil))))) + result + ) + ) (defvar magit-svn-get-ref-info-cache nil "A cache for svn-ref-info. -- 1.7.0.4
