2

I wanted to investigate the difference between magit-branch-and-checkout (b c) and magit-branch-spinoff (b s), so I invoked the Magit output buffer with $. I see the following output:

  0 git … checkout -b energy-efficiency main
Switched to a new branch 'energy-efficiency'

  0 git … checkout -b prova main
Switched to a new branch 'prova'

Does the ellipsis mean something? Can I expand it? How?

And as a side question, should I expect two different commands? Can you point me to a resource to investigate the difference between a normal branch and a spinoff branch?

2 Answers 2

1

The ellipsis is the value of magit-git-global-arguments; it is reference in magit-process--format-arguments

If you would like to see what magit is doing underneath then do

(setq magit-process-extreme-logging t)

If you are familiar with git but not with magit, then the git commands logged in to *Messages* buffer should give you some clue about what is happening


magit-git-global-arguments is a variable defined in magit-git.el.

Its value is

("--no-pager"
 "--literal-pathspecs"
 #1="-c"
 "core.preloadindex=true"
 #1#
 "log.showSignature=false"
 #1#
 "color.ui=false"
 #1#
 "color.diff=false")

Global Git arguments.

The arguments set here are used every time the git executable is run as a subprocess. They are placed right after the executable itself and before the git command - as in git HERE ... COMMAND REST. See the manpage git(1) for valid arguments.

Be careful what you add here, especially if you are using Tramp to connect to servers with ancient Git versions. Never remove anything that is part of the default value, unless you really know what you are doing. And think very hard before adding something; it will be used every time Magit runs Git for any purpose.

This variable was introduced, or its default value was changed, in version 2.9.0 of the magit package. You can customize this variable.


magit-process-extreme-logging is a variable defined in magit-process.el.

Its value is t

Whether magit-process-file logs to the Messages buffer.

Only intended for temporary use when you try to figure out how Magit uses Git behind the scene. Output that normally goes to the magit-process buffer continues to go there. Not all output goes to either of these two buffers.

Also see magit-git-debug.

1
  • Thanks! So, IIUC, the value of the ellipsis is not something you'd normally issue in a terminal git session, right? In other words, to inspect the commands issued to git (for learning purposes), is it sufficient to look at the "visible" part of command? Oct 21, 2022 at 9:58
1

The ellipsis stands for global options passed to git. If you hover the mouse cursor over the , Emacs shows those options in a tooltip (or in the echo area if tooltips are disabled or not available) — it's the value of the help-echo property).

I can't find a built-in way to display this information without using the mouse. Here's a command to display it as a message.

(defun help-echo-at-point (&optional pos)
  "Return the tooltip text at point.

Interactively, display the tooltip text as a message in the echo area,
regardless of tooltip settings."
  (interactive "@d")
  (let ((text (get-text-property (or pos (point)) 'help-echo)))
    (if (and text (interactive-p))
        (message "%s" text))
    text))

Normally, these arguments are the ones from magit-git-global-arguments and they don't differ from command to command.


As for the difference between magit-branch-and-checkout and magit-branch-spinoff, it's explained in the function documentation and in the manual. magit-branch-and-checkout is git checkout -b: create a branch pointing to the current commit, and make it the current branch. (Plus possibly make it track the previously current branch.) magit-branch-spinoff does all that, but in addition, if the previous branch was tracking an upstream branch, it is reset to match the remote. This is useful if you have a local branch main which is meant to track the remote branch main, and you accidentally start committing to main: magit-branch-spinoff takes you to a state which is as if you'd done your local work on some branch my-feature all along.

2
  • Ah, I see, thanks. So, a spinoff is useful when you already have committed to the wrong branch, and it moves your commit to a new one, thus reverting your local (main in this case) to match origin/main (which hopefully is the state of main before your new commits), right? Oct 21, 2022 at 9:56
  • 1
    @AlessandroBertulli Yes, that's it. Oct 21, 2022 at 10:53

Your Answer

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

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