I find the VC status on the modeline useful (the one that shows
Git[:-]branchname) This indicates when the buffer's associated file was
changed on disk (`:' for edited, `-' for unedited.) This indicator is
not affected by a commit with magit, so it keeps signaling a file as
edited when in fact it is not. This patch reverts all buffers that are
visiting a file in the current working tree after a commit.
We need process-connection-type to be nil on cygwin
We need process-connection-type to be t for magit to ask for password
So we now use the new variable magit-process-connection-type for this,
defaulting to nil on cygwin, and to t on others platform.
Then we can use "l" to show short-log from long log an reflog.
At the same time we add the different keybinding to see the different
kind of logs from the others logs.
This patch removes the runtime dependences on the cl package.
Luckily, there weren't too many of these.
From the GNU emacs lisp manual (Appendix D.1 coding conventions)
* Please don't require the `cl' package of Common Lisp extensions
at run time. Use of this package is optional, and it is not part
of the standard Emacs namespace. If your package loads `cl' at
run time, that could cause name clashes for users who don't use
that package.
However, there is no problem with using the `cl' package at
compile time, with `(eval-when-compile (require 'cl))'. That's
sufficient for using the macros in the `cl' package, because the
compiler expands them before generating the byte-code.
There's also the small matter that many of the function implementations
in cl, striving for the full generality of Common Lisp (much of which
is completely useless in Emacs), turn out to be horrible.
E.g., for a fun time, dig down through
(find-if pred list :from-end t),
and look at what it ACTUALLY does when you finish macroexpanding
everything. It tests *every* element of the list against the
predicate, not just the rightmost ones stopping when it finds the
first match. Once it determines the rightmost match, it then retains
NOT the element itself, but its *ordinal* position N, which then gets
used in (elt list N), meaning ANOTHER listwalk, just to get the
element back in order to return it. Nor is the byte-compiler anywhere
near smart enough to optimize this away (I'm not sure *any* compiler
would be...)
I'll grant cl has some useful macros in it, but it comes bundled with a
lot of crap and you need to be really careful about what you use. For
many things, you're better off rolling your own functionality using
the standard routines available (e.g., while, mapcar, and reverse are
all written directly in C).
And you most definitely do NOT want to be foisting the crap on
everybody else, hence the need to keep it out of the runtime.
Meanwhile, here's The Patch:
Modified magit.el
Introduces
magit-log-buffer-name *magit-log*
magit-log-edit-buffer-name *magit-edit-log* (was *magit-log-edit*)
magit-log-grep-buffer-name *magit-grep-log* (was *magit-log-grep*)
magit-process-buffer-name *magit-process*
magit-commit-buffer-name *magit-commit*
magit-stash-buffer-name *magit-stash*
Also adds C-c C-] as a binding for magit-log-edit-cancel-log-message
since C-c C-] as the aborting counterpart to C-c C-c is at least a
vague convention for other modes (cf. rmail, vm, query-replace...)
Motives:
It annoys me that, when wanting to switch to the *magit-log* buffer
from some random place, I can't type *ma<space>-l<space> and have it
complete properly, at least not if I've previously ever done a commit
(because there's then a *magit-log-edit* out there stealing the
completion).
Also looks like if I ever use magit-log-grep, I will be likewise
screwed.
Finally, it disturbs my sense of aesthetics when I look at source code
and see the same strings occuring over and over. Usually, that's
crying defvars/defconsts. (And this will also makes life easier
in the event you don't like my buffer name changes for -log-edit
and -log-grep).
- -
(...This all leaves *magit-tmp* as the only remaining case of a buffer
name string occurring multiple times, but that needs to be handled
differently, so that'll be a different patch...)
(...Note that having buffer names as variables also allows the
eventual possibility of making them local --- or at least the
option thereof --- so that one can be visiting several
repositories at once and not having these buffers all clobbering
each other. There's a tradeoff here in that some folks may find
it confusing/annoying to have more than one set of these buffers
to deal with,... hence option.
*If* one is going to go that route, current gut feeling is buffer
name variables should be local to *just* the status buffer(s),
void elsewhere, and anything needing one of the auxiliary buffers
should dispatch through its own status buffer to get what it
wants. That way, we're not having to repeat/update/copy
per-repository definitions everywhere....)
The patch:
Here, have some docstrings:
(...it being something of a show-stopper for newbies when they want to
find out what a given keystroke will do, they hit ^Hk [or ^Hf or ^Hv],
and nothing useful comes out...)
If you do
. magit-status on repository .../x
. V (magit-show-branches)
. magit-status on repository .../y
. V (magit-show-branches)
you get the branch listing for repository .../x
Also, as a side issue, functionality of a buffer should not be
keyed off of the buffer name (in this case, renaming the buffer
should not change what V or g does).
The following patch deals with both of these.
They all apply to hunk, commit and diff that are in
status, stash, log, reflog, diff and wazzup buffers.
Signed-off-by: Rémi Vanicat <vanicat@debian.org>
magit's interactive rebase feature tries to start the server even if
it is already running. If it is already running then Emacs asks
whether or not it should destroy existing clients. This is fatal if
the frame magit is running in was created by emacsclient
itself (e.g. Emacs is running in the background with "--daemon"), so
the user has to answer "no".
This question can be avoided if the server is only startet if it isn't
already running.
The following functions are available from the branch list (which in
turn is made read-only):
- Checking out the branch in the current line
- Deleting the branch in the current line (prefix forces deletion even
if not merged into current branch); works on both local and remote
branches
- Manual and automatic merges of the branch in the current line into
the current branch
- Quitting the branch list
Includes updated documentation.
If you have a local tracking branch, e.g. called 'test', and the
remote branch name is different than test (e.g. 'somwhere/master')
then the commands for retrieving the unpulled and unpushed commits was
calling "git log test..somwehere/test" which may or may not exist.
Intended to be bound to X instead of magit-reset-working-tree for those who
feel it is a more consistent pair for x. Suggests HEAD and therefore works
like magit-reset-working-tree by default. Eliminates need to use C-u x.
One might argue that this also makes it work better in a case when GIT_DIR
points outside of a work tree, but because in that case any directory is a
valid "top dir" from GIT's point of view, that is debatable. But at least
one can use Magit in that case by first making sure that default-directory
is the top dir and then executing magit-status.
Forces emacs to use pipes for communication with git subprocess.
Although default PTY method should work too, there is probably
something broken in cygwin causing that resulting process never
receives any input and hangs forever.
In any case, setting communication to 'pipe' is recommended by
start-process docs anyway for background processes, as it is usually
faster and more efficient.
Instead of a --numstat diff. This gives more information.
* magit.el (magit-insert-diff-title): Factored out of
magit-wash-diff-section. Don't handle mode changes separately from
content changes.
(magit-wash-raw-diffs, magit-wash-raw-diff): New.
(magit-wash-numstat-diffs, magit-wash-numstat-diff): Removed.
(magit-insert-unstaged-changes): Use git diff-files.
(magit-insert-staged-changes): Use git diff-index.
* magit.el (magit-ref-exists-p): Use correct invocation and turn exit
code into a boolean. (Saturday night hacking sessions are not my
forte. Sundays on the other hand...)
* magit.el (magit-set-section-needs-refresh-on-show): New.
(magit-section-set-hidden): Call magit-refresh when a
'needs-refresh-on-show' section is shown.
(magit-show-level): Wrap it in magit-with-refresh.
(magit-wash-diff, magit-wash-diff-section): Factored washing and
section construction into seperate functions.
(magit-insert-diff, magit-wash-numstat-diffs,
magit-wash-numstat-diff): New. Use magit-insert-diff for visible
sections or for small changes.
(magit-insert-unstaged-changes): Use a numstat diff instead of a full diff.
(magit-insert-staged-changes): Likewise.
* magit.el (magit-list-interesting-refs): Use "git show-ref" instead
of trying to parse output of "git branch". Return alist with name /
ref pairs.
(magit-read-rev, magit-get-svn-branch-name): Updated.
(magit-refresh-wazzup-buffer): Use magit-list-interesting-refs instead
of parsing "git branch" output.
* magit.el (magit-rebase-info): Also look for .git/rebase-apply.
(magit-log-edit): Don't commit in the middle of a rebase, offer to
continue it instead.
(magit-add-log): Likewise.
If you have a topic branch (any branch named t/foo), Magit will create a
section named Topics and show you all outstanding topic branches.
Hitting RET on a topic does a checkout.
This gives users an easy way to interface with external tools like
"topgit". You type !, followed by "tg create t/foo", and then
everything including magit refreshing the buffer gets handled
automatically.
From Tom Tromey. Thanks!
* Makefile.am (elpa): New target to create elpa tarball.
* magit-pkg.el.in: New.
* configure.ac: Create magit-pkg.el from it.
* magit.el: Added autoload for magit-status.
Thanks to Travis B. Hartwell!
* magit.el (magit-get-svn-branch-name): New.
(magit-insert-unpulled-svn-commits, magit-insert-unpushed-svn-commits,
magit-svn-enabled): Use it.
* magit.el (magit-wazzup-ignore): New.
(magit-refresh-wazzup-buffer): Read wazzup-exclude and optionally omit
the branches listed in it. Added 'all' parameter to control this.
(magit-wazzup): Show all branches with prefix.
(magit-ignore-item): Call magit-wazzup-ignore for wazzup branches.
* magit.texi: Document it.
* magit.el (magit-reset-head): Reflect it in the prompt whether this
is going to be a hard reset or not. Added optional argument instead
of using current-prefix-arg directly.
* magit.texi: Document it.
* magit.el: Permit cancelling log edits.
magit-log-edit-confirm-cancellation: New defcustom.
magit-log-edit-map: New keybinding: C-c C-k to cancel the log.
magit-log-edit-cancel-log-message: New function.
magit-pop-to-log-edit: Indicate that cancellation is possible.
Previously it was insisting on a branch named "git-svn", but I'm not
sure if this is ever created by default. Also, there is no need to call
"remote update", and if it is called asynchronously, it blocks the
subsequent call to svn fetch.
* magit.el (magit-log-edit-get-field): New.
(magit-commit-all-when-nothing-staged): New.
(magit-log-edit): Set 'commit-all field accordingly.
(magit-log-edit-commit): Use that field to control "--all" option.
1. Don't report a branch if it has no commit in common with HEAD. This
is for people who keep alternate histories in their repositories.
2. Don't report a branch if another branch with the same basename and
commit as HEAD has already been reported. Thus, if a branch "foo"
with 5 unpulled commits was pushed to origin, don't display both
"foo" and "origin/foo" in the whazzup buffer, since they reflect the
same thing.
* magit.el (magit-prefix-p): Compare components with equal so that it
works for strings.
(magit-process-indicator-from-command): Take
magit-git-standard-options into account when choping off the head.
* magit.el (magit-cherry-pick-commit): Removed, replaced with
magit-apply-item.
(magit-revert-commit): Likewise.
(magit-apply-commit): Use git cherry pick and optionally do everything
magit-cherry-pick-commit and magit-revert-commit could do.
* magit.el (magit-stash-snapshot): Wrap calls to magit-run in one
magit-with-refresh so that magit-revert-files is only called once.
Calling it twice within one second does not work.
* magit.el (magit-insert-hunk-item-region-patch): Pass through "+"
lines for reverse patches.
(magit-apply-hunk-item*): New, factored out of magit-apply-hunk-item
and magit-apply-hunk-item-reverse.
(magit-apply-hunk-item-reverse): New. Use it instead of passing
"--reverse" to magit-apply-hunk-item so that
magit-insert-hunk-item-region-patch knows whether we are applying in
reverse or not.
From John Wiegly.
Defines a number of seconds, after which magit will automatically
popup the magit-process buffer so the user can see what git is up to.
Off by default. I use this because sometimes when a commit or push
takes more than an expected amount of time, I start to wonder what
happened.
This is different from regular stashing because there is no prompting for a
name, and the stash is immediately re-applied. It's just a way of taking a
quick snapshot of your working tree, so you can come back to later if need
be.
For example, if you had just made a lot of changes to your project, and then
needed to make another sweeping change before you could commit again, this
would let you safely store your changes without having to resort to a branch.
The other day I hacked some file, and all changes obviously split in
two commits logically, but I can't do that because changes from
"different commits" were to close to each other and diff shows them
ina single hunk. There's possibility in git add -i to split current
hunk into smaller ones in such situations. I wanted to do this without
leaving emacs.
Now magit have control over -U<n> option to git-diff.
It was imposible to see what was staged for a first commit on a fresh
git repository. The only visible lines was fatal error messages from
git. Now diff against null tree object is shown in magit status buffer
if nothing was yet commited to the repository. The cost is 15-byte
object added to the repo, but it shuld disappear on first call to git
gc.
The usual behavior of committing all unstaged changes when there are
no staged changes makes it impossible to amend a commit just to fix
the commit message, which is a quite common thing to do.
* magit.el (magit-log-edit-commit): Do not pass "--all" to git commit
when amending.
* magit.el (magit-section-lineage, magit-section-show-level, magit-show-level,
magit-define-level-shower-1): New.
(magit-mode-map): Bind the digits and M-digits to magit-show-level-N
and magit-show-level-N-all.
* magit.texi: Document it in a new chapter for Sections.
* magit.el (magit-status): Only read the top directory with e prefix
argument or when we are not inside a Git repository.
* magit.texi, NEWS: Document the new behavior.
* magit.el (magit-show-stash): New.
(magit-visit-item): Use it and pop to the buffer for stashes.
(magit-show-item-or-scroll-up, magit-show-item-or-scroll-down): Handle
stashes.
* magit.el (magit-read-rev-range): Don't do anything special when
current-prefix-arg is set.
(magit-log): Use magit-read-rev-range instead of read-string.
(magit-log-long): Likewise.
On non-existent directiories magit-get-top-dir was failing returning
garbage string like "zsh: cd: no such file or directory: ...". Now it
returns nil in such cases.
Signed-off-by: John Wiegley <johnw@newartisans.com>
* magit.el (magit-insert-section): Revert earlier change: first
argument is used as the section title and the section type is usually
nil. When the first argument is a pair, it specvifies both the title
and the type.
* magit.el (magit-section-hidden-default): New.
(magit-new-section): Only expect type as argument, not a general list
of slots. Take 'hidden' value from magit-section-hidden-default.
(magit-with-section): Likewise.
(magit-wash-diff): Adapted.
* magit.el (magit-refresh-commit-buffer): Use nil as type for outer
section so that the highlight is not used for it.
(magit-refresh-log-buffer): Likewise.
* magit.el (magit-with-section): Check that args is a list before
accessing its car.
(magit-insert-section): Set the title of the section from the real
title, and the txpe from the real type.
If branch or tag name is the same as some file in repository, git log
was reporting that as "ambiguous argument 'test': both revision and
filename. Use '--' to separate filenames from revisions".