Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

args-out-of-range on branches where the upstream branch is gone #1723

Closed
whirm opened this issue Feb 4, 2015 · 4 comments
Closed

args-out-of-range on branches where the upstream branch is gone #1723

whirm opened this issue Feb 4, 2015 · 4 comments
Milestone

Comments

@whirm
Copy link

whirm commented Feb 4, 2015

If I check out any branch that has had it's upstream branch deleted, magit will fail with this error:

Debugger entered--Lisp error: (args-out-of-range "" 0 7)
  match-string(1 "")
\211D\306H\n>\204\207\307\310\343\312#\210D\211E\344\345\346D\"\211F\203\237F\347=\202\303G\205\254\350\351D!G\"\211\205\30211\2\306H\n>\204\277\307\310\343\312#\210   \344H))I\210)D\211G\206\333C?\205\333HDHGCI\352\353\215\210D\210.\354\355!\210\326c\210\356 !\210\357   \306H\n>\204\307\310\360\312#\210   \361H\362\"\210 \306H\n>\204\307\310\363\312#\210   \211J\364\341 I)K\365\366\367   \306H\n>\2044\307\310\311\312#\210  \313H\"!L\370L!\205ELJL\212 \306H\n>\204V\307\310\360\312#\210  \361Hb\210`KW\203\222\371`\312\"\206kKM\372`\312\"\204\212\373`M\312    $\210L\203\212\373`M\374L$\210Mb\210)\202[, H=\203\241\375  !\210\202   \306H\n>\204\257\307\310\376\312#\210   \377H\306H\n>\204\301\307\310\201O\312#\210 \306H\n>\204\317\307\310\376\312#\210   \377H\211N\201P \306H\n>\204\346\307\310\376\312#\210   \377H\306H\n>\204\370\307\310\201O\312#\210 \306H\n>\204\307\310\376\312#\210   \377H\201PH C\244I\210)\342\207" [branch it cl-struct-magit-section-tags v hash msg 0 error "%s accessing a non-%s" magit-section-type magit-section 1 commit magit-insert-heading magit-string-pad "Head: " 10 propertize face magit-hash " " magit-branch-local "\n" magit-get-tracked-branch magit-rev-format "%h %s" "" string-match "^\\([^ ]+\\) \\(.*\\)" match-string 2 vector cl-struct-magit-section point-marker nil magit-section-hidden 6 run-hook-with-args-until-success magit-section-set-visibility-hook hide magit-get-section magit-section-ident cancel-section (byte-code "\306\307\310\311\\203\31\313\314#\202\315\316\317\320   \321#\205\322\312\n\313\323\320 \324#\325\230\203-\326\202.\327#\316
>\204E\334\335\360\337#\210\f\361H\363H\fC\244I\210)\306\207" [hash branch upstream msg section74283 cl-struct-magit-section-tags magit-insert magit-string-pad "Upstream: " 10 propertize face magit-hash "missing" " " magit-get-boolean "branch" "rebase" "onto " magit-get "remote" "." magit-branch-local magit-branch-remote "\n" magit-insert-child-count set-marker-insertion-type 0 error "%s accessing a non-%s" magit-section-start magit-section 3 t magit-section-end 5 point-marker intern format "magit-%s-section-map" magit-section-type 1 boundp next-single-property-change get-text-property put-text-property keymap magit-section-show magit-section-parent 11 ...] 13) run-hooks magit-status-headers-hook magit-insert-child-count set-marker-insertion-type magit-section-start 3 ...] 15)
  magit-insert-status-headers()
  run-hooks(magit-status-sections-hook)
  byte-code("\306\307!\210\31!\210\31\312H  >\204\313\314\315\316#\21\317H\320\"\21\312H    >\204+\313\314\321\316#\21\211\322\323 I)324\325\32\312H    >\204E\313\314\327\316#\21\330H\"!\331\f!\205S\fJ\21\312H   >\204c\313\314\315\316#\21\317Hb\210`
                                                                                                                                                                                                                                                                     W\203\227\332`\316\"\206v
b\210)\202h#=\203\246\33!\210\20\312H   >\204\264\313\314\337\316#\21\340H\312H >\204\304\313\314\341\316#\21\312H  >\204\322\313\314\337\316#\21\340H\211$\34\312H >\204\347\313\314\337\316#\21\340H\312H >\204\367\313\314\341\316#\21\312H  >\204\313\314\337\316#\21\340H\342C\244I\210)\306\207" [section74280 cl-struct-magit-section-tags v end map next run-hooks magit-status-sections-hook magit-insert-child-count set-marker-insertion-type 0 error "%s accessing a non-%s" magit-section-start magit-section 3 t magit-section-end 5 point-marker intern format "magit-%s-section-map" magit-section-type 1 boundp next-single-property-change get-text-property put-text-property keymap magit-section-show magit-section-parent 11 magit-section-children 12 magit-root-section v] 8)
  magit-status-refresh-buffer()
  apply(magit-status-refresh-buffer nil)
  magit-refresh-buffer()
  magit-refresh()
  call-interactively(magit-refresh nil nil)
  command-execute(magit-refresh)

If I run git branch --unset-upstream everything is fine again.

Thanks!

@whirm
Copy link
Author

whirm commented Feb 4, 2015

I forgot to say: that's for current next

@kyleam
Copy link
Member

kyleam commented Feb 5, 2015

I can reproduce this.

The issue seems to be that magit-insert-status-headers relies on magit-get-tracked-branch to get the tracked branch name, which uses git config ... to retrieve it. However, '.git/config' isn't updated when the remote branch is deleted, so magit-get-tracked-branch returns the deleted name and passes it to magit-rev-format, which returns nil due to the error in the underlying git command.

Until @tarsius gets back, you could try the patch below as a temporary fix.

diff --git c/magit.el w/magit.el
index 5dd7a30..04e5119 100644
--- c/magit.el
+++ w/magit.el
@@ -432,8 +432,9 @@ (defun magit-insert-status-headers (&optional branch upstream)
               (and branch
                    (concat (propertize branch 'face 'magit-branch-local) " "))
               msg "\n")
-            (when (or upstream (setq upstream (magit-get-tracked-branch branch)))
-              (setq line (or (magit-rev-format "%h %s" upstream) ""))
+            (when (and (or upstream
+                           (setq upstream (magit-get-tracked-branch branch)))
+                       (setq line (magit-rev-format "%h %s" upstream)))
               (string-match "^\\([^ ]+\\) \\(.*\\)" line)
               (magit-bind-match-strings (hash msg) line
                 (magit-insert-section (branch upstream

@whirm
Copy link
Author

whirm commented Feb 5, 2015

@kyleam works fine for me!

Thanks!

tarsius added a commit that referenced this issue Feb 27, 2015
Fixes #1723 and completes an earlier attempt at fixing
this issue in 43abff3.

Suggested-by: Kyle Meyer <kyle@kyleam.com>
tarsius added a commit that referenced this issue Feb 27, 2015
Fixes #1723 and completes an earlier attempt at fixing
this issue in 43abff3.

Suggested-by: Kyle Meyer <kyle@kyleam.com>
@tarsius
Copy link
Member

tarsius commented Feb 27, 2015

I've applied this patch, thanks.

@tarsius tarsius closed this as completed Feb 27, 2015
@tarsius tarsius modified the milestone: 2.1.0 Apr 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants