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 4fbb1a47cc20a69215f2da487df284cb40e20b85 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..c5c6f32 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