Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix "ambiguous argument" error when refspec contains {x,y,z}

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
  • Loading branch information...
commit 1b3d9650af4df571e2715d6014d46d28a7f17ed5 1 parent b635445
Graham Clark authored sigma committed
Showing with 13 additions and 1 deletion.
  1. +13 −1 magit-svn.el
View
14 magit-svn.el
@@ -65,9 +65,21 @@
(defun magit-svn-enabled ()
(not (null (magit-svn-get-ref-info t))))
+(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")
+ (let* ((branches (cons (magit-get "svn-remote" "svn" "fetch")
(magit-get-all "svn-remote" "svn" "branches")))
+ (branches (apply 'nconc
+ (mapcar 'magit-svn-expand-braces-in-branches
+ branches)))
(base-url (magit-get "svn-remote" "svn" "url"))
(result nil))
(while branches
Please sign in to comment.
Something went wrong with that request. Please try again.