{"action":"created","issue":{"url":"https://api.github.com/repos/magit/magit/issues/1723","labels_url":"https://api.github.com/repos/magit/magit/issues/1723/labels{/name}","comments_url":"https://api.github.com/repos/magit/magit/issues/1723/comments","events_url":"https://api.github.com/repos/magit/magit/issues/1723/events","html_url":"https://github.com/magit/magit/issues/1723","id":56519055,"number":1723,"title":"args-out-of-range on branches where the upstream branch is gone","user":{"login":"whirm","id":529494,"avatar_url":"https://avatars.githubusercontent.com/u/529494?v=3","gravatar_id":"","url":"https://api.github.com/users/whirm","html_url":"https://github.com/whirm","followers_url":"https://api.github.com/users/whirm/followers","following_url":"https://api.github.com/users/whirm/following{/other_user}","gists_url":"https://api.github.com/users/whirm/gists{/gist_id}","starred_url":"https://api.github.com/users/whirm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whirm/subscriptions","organizations_url":"https://api.github.com/users/whirm/orgs","repos_url":"https://api.github.com/users/whirm/repos","events_url":"https://api.github.com/users/whirm/events{/privacy}","received_events_url":"https://api.github.com/users/whirm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-04T12:12:17Z","updated_at":"2015-02-05T06:31:13Z","closed_at":null,"body":"If I check out any branch that has had it's upstream branch deleted, magit will fail with this error:\r\n\r\n```Debugger entered--Lisp error: (args-out-of-range \"\" 0 7)\r\n  match-string(1 \"\")\r\n\\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\t\\344H))I\\210)D\\211G\\206\\333C?\\205\\333HDHGCI\\352\\353\\215\\210D\\210.\\354\\355!\\210\\326c\\210\\356\t!\\210\\357\t\\306H\\n>\\204\\307\\310\\360\\312#\\210\t\\361H\\362\\\"\\210\t\\306H\\n>\\204\\307\\310\\363\\312#\\210\t\\211J\\364\\341 I)K\\365\\366\\367\t\\306H\\n>\\2044\\307\\310\\311\\312#\\210\t\\313H\\\"!L\\370L!\\205ELJL\\212\t\\306H\\n>\\204V\\307\\310\\360\\312#\\210\t\\361Hb\\210`KW\\203\\222\\371`\\312\\\"\\206kKM\\372`\\312\\\"\\204\\212\\373`M\\312\t$\\210L\\203\\212\\373`M\\374L$\\210Mb\\210)\\202[,\tH=\\203\\241\\375\t!\\210\\202\t\\306H\\n>\\204\\257\\307\\310\\376\\312#\\210\t\\377H\\306H\\n>\\204\\301\\307\\310\\201O\\312#\\210\t\\306H\\n>\\204\\317\\307\\310\\376\\312#\\210\t\\377H\\211N\\201P\t\\306H\\n>\\204\\346\\307\\310\\376\\312#\\210\t\\377H\\306H\\n>\\204\\370\\307\\310\\201O\\312#\\210\t\\306H\\n>\\204\\307\\310\\376\\312#\\210\t\\377H\\201PH\tC\\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\t\\321#\\205\\322\\312\\n\\313\\323\\320\t\\324#\\325\\230\\203-\\326\\202.\\327#\\316\r\n>\\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)\r\n  magit-insert-status-headers()\r\n  run-hooks(magit-status-sections-hook)\r\n  byte-code(\"\\306\\307!\\210\\31!\\210\\31\\312H\t>\\204\\313\\314\\315\\316#\\21\\317H\\320\\\"\\21\\312H\t>\\204+\\313\\314\\321\\316#\\21\\211\\322\\323 I)324\\325\\32\\312H\t>\\204E\\313\\314\\327\\316#\\21\\330H\\\"!\\331\\f!\\205S\\fJ\\21\\312H\t>\\204c\\313\\314\\315\\316#\\21\\317Hb\\210`\r\n                                                                                                                                                                                                                                                                     W\\203\\227\\332`\\316\\\"\\206v\r\nb\\210)\\202h#=\\203\\246\\33!\\210\\20\\312H\t>\\204\\264\\313\\314\\337\\316#\\21\\340H\\312H\t>\\204\\304\\313\\314\\341\\316#\\21\\312H\t>\\204\\322\\313\\314\\337\\316#\\21\\340H\\211$\\34\\312H\t>\\204\\347\\313\\314\\337\\316#\\21\\340H\\312H\t>\\204\\367\\313\\314\\341\\316#\\21\\312H\t>\\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)\r\n  magit-status-refresh-buffer()\r\n  apply(magit-status-refresh-buffer nil)\r\n  magit-refresh-buffer()\r\n  magit-refresh()\r\n  call-interactively(magit-refresh nil nil)\r\n  command-execute(magit-refresh)\r\n```\r\n\r\nIf I run ```git branch --unset-upstream``` everything is fine again.\r\n\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/magit/magit/issues/comments/73000912","html_url":"https://github.com/magit/magit/issues/1723#issuecomment-73000912","issue_url":"https://api.github.com/repos/magit/magit/issues/1723","id":73000912,"user":{"login":"kyleam","id":1297788,"avatar_url":"https://avatars.githubusercontent.com/u/1297788?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleam","html_url":"https://github.com/kyleam","followers_url":"https://api.github.com/users/kyleam/followers","following_url":"https://api.github.com/users/kyleam/following{/other_user}","gists_url":"https://api.github.com/users/kyleam/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleam/subscriptions","organizations_url":"https://api.github.com/users/kyleam/orgs","repos_url":"https://api.github.com/users/kyleam/repos","events_url":"https://api.github.com/users/kyleam/events{/privacy}","received_events_url":"https://api.github.com/users/kyleam/received_events","type":"User","site_admin":false},"created_at":"2015-02-05T06:31:13Z","updated_at":"2015-02-05T06:31:13Z","body":"I can reproduce this.  \r\n\r\nThe 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.\r\n\r\nUntil @tarsius gets back, you could try the patch below as a temporary fix.\r\n\r\n```diff\r\ndiff --git c/magit.el w/magit.el\r\nindex 5dd7a30..04e5119 100644\r\n--- c/magit.el\r\n+++ w/magit.el\r\n@@ -432,8 +432,9 @@ (defun magit-insert-status-headers (&optional branch upstream)\r\n               (and branch\r\n                    (concat (propertize branch 'face 'magit-branch-local) \" \"))\r\n               msg \"\\n\")\r\n-            (when (or upstream (setq upstream (magit-get-tracked-branch branch)))\r\n-              (setq line (or (magit-rev-format \"%h %s\" upstream) \"\"))\r\n+            (when (and (or upstream\r\n+                           (setq upstream (magit-get-tracked-branch branch)))\r\n+                       (setq line (magit-rev-format \"%h %s\" upstream)))\r\n               (string-match \"^\\\\([^ ]+\\\\) \\\\(.*\\\\)\" line)\r\n               (magit-bind-match-strings (hash msg) line\r\n                 (magit-insert-section (branch upstream\r\n```\r\n"}}