1

I seem to have inconsistent behavior with magit-insert-remote-header. On some repositories I get a remote header, which I can navigate to and use P-p to push commits to the remote, where other repositories I don't have a remote header, but can still push to remote using P-p.

I have deleted and re-added remotes using Magit, and doing this does not cause the header to appear.

I believe that the repos that do have headers have remotes that were not added using Magit, but I could be mistaken.

I have the following in my custom-set-variables:

'(magit-status-headers-hook
   (quote
    (magit-insert-repo-header magit-insert-remote-header magit-insert-head-header magit-insert-upstream-header magit-insert-tags-header)))

which gives me the "repo" and "head" headers (I don't use the other ones besides "remote").

Any guidance would be appreciated. I expect it's something simple I'm overlooking.

1 Answer 1

1

The remote header is only known when we know for sure which one should be shown. I.e. when the current branch tracks a remote branch.


It might make sense to fall back to some other remote, likely "origin". And maybe if there is no such remote to some random remote (in practice the first in alphabetic order).

(defun magit-insert-remote-header ()
  "Insert a header line about the remote of the current branch."
  (-when-let (remote (or (magit-get-remote)
                         (let ((remotes (magit-list-remotes)))
                           (or (car (member "origin" remotes))
                               (car remotes)))))
    (magit-insert-section (remote remote)
      (magit-insert
       (concat (format "%-10s" "Remote: ")
               (propertize remote 'face 'magit-branch-remote) " "
               (magit-get "remote" remote "url") "\n")))))

In fact I have just added that.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.