aboutsummaryrefslogtreecommitdiff
path: root/lisp/magit-commit.el
AgeCommit message (Collapse)Author
2025-08-22Use Cond-Let's implementation of and-letJonas Bernoulli
Using the "other elements of VARLIST have access to SYMBOLs from earlier elements" variant is IMHO _wrong_ when there are in fact no other elements.
2025-08-22Use Cond-Let's implementations of {if,when,and,while}-let{,*}Jonas Bernoulli
Cond-Let's `if-let', `if-let*', `when-let', `when-let*' and `and-let*' implementations behave differently from the built-in implementations, but because I have been careful not to depend on the idiosyncrasies, switching over should be mostly safe. Also add shorthands for the other `cond-let--...' macros. We will start using those (and `cond-let' and `cond-let*') in later commits.
2025-07-25Use shorthand match-str instead of match-string-no-propertiesJonas Bernoulli
Almost always would it be better to use `match-string-no-properties' instead of `match-string', but because the name of the former is excruciatingly long for a function that one often wants to use in tight spaces and because it usually "does not really matter", I usually went for the latter. The problem is, it does matter. For example, even strings that are usually only used by code may end up obfuscating debug statements. So let's start doing the right thing, even though there surely will be people frowning at the use of a shorthand. The fake ("match-string" "match-string") shorthand is necessary to protect literal `match-string' and `match-string-no-properties' from being corrupted by interpreted as shorthand for the non-existent `match-stringing' and `match-string-no-propertiesing'. Unfortunately the shorthands have to be specified in each library individually. Using "dir-locals.el" only works if the libraries are compiled. At least this additional noise is neatly tucked away at the end of the files. It might turn out that out of the more than two hundred instances where this replaces `match-string' with `match-string-no-properties' we should have stuck with the former in an instance or two. That's the price of progress and can be fixed once such regressions are reported.
2025-03-01magit-commit: Add magit-rebase-reword-commit but hide it by defaultJonas Bernoulli
This command is also available from the `magit-rebase' menu, and has been for a long time. In the context of `magit-commit' it is the missing "Instant Reword" variant, which one might expect to find here, accompanying "Instant Fixup" and "Instant Squash". Do not make it available by default because it is different from all other commands in this menu, in that it does not create a commit in the presence which is send (whether instantly or later) into the past. In contrast, this command has you immediately hop into a time machine and only once you have arrived at your destiny, can you start messing with the timeline. While this command is unlike its second home neighbors, one can tell that "Rebase to modify/reword/remove a commit" all grew up in the same neighborhood, despite their diverging interests.
2025-02-21Fix various docstringsJonas Bernoulli
2025-02-04magit-commit-amend-assert: Return non-nil if NOPATCH is non-nilJonas Bernoulli
Closes #5306.
2025-02-02Use ## and seq-find instead of --firstJonas Bernoulli
In one case use lambda and in another pcase-lambda, not ##.
2025-01-31magit:--signoff: Set default level via prototypeJonas Bernoulli
2025-01-30Make --signoff available in more menusJonas Bernoulli
But "demote" it a bit, in all menus, by placing it after `--gpg-sign' and putging it on level 6. Closes #5297.
2025-01-20magit-commit-revise: Don't show diff in log-selectJonas Bernoulli
2025-01-17Improve documentation about commit commandsJonas Bernoulli
2025-01-17Rearrange definitions and documentation of commit commandsJonas Bernoulli
Rearrange their definitions and the order in which they are described in the manual, to better mirror their new arrangement in the menu.
2025-01-17magit-commit-squash-internal: Always add either --no-edit or --editJonas Bernoulli
Adding "--edit" is not actually necessary, because the variants that need it, use other arguments, which imply it. But users don't always know which arguments imply which of these two arguments, so it is a nice touch to include this information in the arguments, shown in the process buffer. This also makes it easier to document the behavior of variants; we can now say that some of them use "--edit", without that not actually being true.
2025-01-17magit-commit-{alter,revise}: New commandsJonas Bernoulli
- Bind "A" to `magit-commit-alter'. Previously that was bound to `magit-commit-augment', but the new command is more similar to `magit-commit-amend', whose binding is "a". `amend' and `alter' do the approximately same thing, but the former is limited to the "HEAD" commit. Additionally `alter' needs changes (else use `revise'). - Bind "W" to `magit-commit-revise' because "w" is bound to `magit-commit-reword' and these two are also HEAD/any variants. - Bind "n" to `magit-commit-augment'. The mnemonic being that this adds a "note", which we later have to take into account when writing the final commit message. - Bind "d" to `magit-commit-reshelve' because "n" is now taken. Use "d" because it changes dates. This command is disabled by default. - In the menu, arrange the variants in a way that hopefully makes these relations more obvious. Unfortunately this is not possible without leaving some "table cells" empty.
2025-01-17magit-commit-squash-internal: Change parameter orderJonas Bernoulli
This order better reflects the order in which the respective subtasks happen. Going forward it will also mean that fewer commands have to use nil to skip over an optional parameter. Leave CONFIRMED at the end because it is only used recursively. Also use more descriptive non-nil arguments.
2025-01-17magit-commit-squash-internal: Do not inject = between option and commitJonas Bernoulli
We'll add new variants that would break if we continued to do that. Instead require options to end with "=" if they need that.
2025-01-17magit-commit: Change descriptions of "spread" commandsJonas Bernoulli
2025-01-17magit-commit: Use more columns and add titles to allJonas Bernoulli
2025-01-17magit-commit: Disable magit-commit-reshelveJonas Bernoulli
It's a weird command and I suspect very few people use it. Let's not confuse everybody else. To re-enable this command users have to put it individually on any non-zero level that they have enabled for this menu.
2025-01-17magit-commit: CosmeticsJonas Bernoulli
2025-01-17magit-commit-{absorb,autofixup}: Explicitly set transient behaviorJonas Bernoulli
These commands behave as intended even without doing this, but the binding color in the `magit-commit' menu was still wrong.
2025-01-17magit-commit:--date: Define explicitlyJonas Bernoulli
2025-01-17magit-commit-create: No longer amend with a prefix argumentJonas Bernoulli
Several fine commands dedicated to amending exist, and have been preferable to this prefix argument for many years now.
2025-01-09magit-commit-assert: Call magit-diff-unstaged with magit-diff-argumentsNikita Leshenko
This is similar to how magit-diff-staged is called in this file. Before this change, the final Git command will be called without "--no-ext-diff", which results broken diffs when one has a custom external diff program.
2025-01-05Let the byte-compiler check more function referencesJonas Bernoulli
2025-01-01Bump copyright yearsJonas Bernoulli
2024-12-21magit-commit-absorb: Don't hardcode -v argumentJonas Bernoulli
Previously the argument was hardcoded and the user could additionally enable it explicitly. If they did, that resulted in an error because this command does not support duplicated arguments. Now we default to high verbosity but let the user drop the argument, if they so desire. Closes #5272.
2024-12-21magit-commit-autofixup: Support reducing verbosityJonas Bernoulli
Default to high verbosity but let the user drop the argument.
2024-10-17magit-commit-squash-internal: Reduce nestingJonas Bernoulli
2024-04-15Update contact informationJonas Bernoulli
2024-01-02magit-commit-extend: Fix misplaced newline in docstringJonas Bernoulli
2024-01-01Bump copyright yearsJonas Bernoulli
2023-09-08magit-commit-assert: Tweak behavior for merge commitsJonas Bernoulli
Signal an error if there are any unmerged changes. Instead of unconditionally signaling an error when there are unstaged changes, ask the user whether they want to proceed. Closes #4985.
2023-07-31Use when-let instead of --when-letJonas Bernoulli
In a few cases use `when-let*' or `and-let*' instead. I haven't done a full 180 on anaphoric conditionals; if a builtin equivalent existed, I would use that in some instances. However, having looked at all the existing uses of `when-let', it turns out there are way fewer such cases than I had anticipated.
2023-07-28Use seq-remove instead of -remove-firstJonas Bernoulli
Of course this is not an exact substitute — none exits — but that doesn't matter here because we know the list contains at most one matching element and the list is short enough for the needless work to be insignificant.
2023-06-06magit-commit-reshelve: Fix docstring typoJonas Bernoulli
2023-04-10Use the documented format construct %d instead of %iPhil Sainty
For printf compatibility, %i is equivalent[1] to %d -- but only %d is documented. The simple %i cases are being passed directly to `format', or indirectly via `magit-confirm'. The %%i cases are being processed by either (format (format ...)) or (magit-confirm (format ...)). [1] See styled_format() in src/editfns.c, which consistently tests conversion == 'd' || conversion == 'i'.
2023-03-18Record diff-type in magit-diff-mode buffersJonas Bernoulli
Closes #4900.
2023-03-17Deprecate magit-git-dir to avoid needlessly repeating workJonas Bernoulli
Five years ago in [1: 5f407a29ac] we took the first step toward this. 1: 2018-10-15 5f407a29ac63b338c3c75e30b4633b44d5745036 magit-gitdir: New function Previously we cached the wrong thing. `expand-file-name' is cheap but "git rev-parse --git-dir" is not. Because `magit-git-dir' is where we cached, rev-parse was still needlessly called multiple times with the same arguments during a refresh. The effect should be most noticeable during a rebase.
2023-02-11magit-commit-diff-1: Take --allow-empty into accountJonas Bernoulli
2023-01-03Bump copyright yearsJonas Bernoulli
2022-11-13Consider Git's exec path when searching for extensionsKyle Meyer
Commands that depend on optional third-party Git extensions use executable-find to check whether the extension is available. That misses the legitimate case where an extension is installed in Git's exec path rather than a directory in $PATH. Update these spots to call a new helper that looks in Git's exec path before calling executable-find. Note that the order is chosen to follow Git's precedence (though that doesn't matter for any of the current callers because they don't use the return value). Closes #4812.
2022-10-19magit-commit-squash-internal: Restore window conf after showing diffKyle Meyer
When magit-commit-show-diff is non-nil, the diff window is typically deleted by with-editor-return restoring the initial window configuration, but it isn't deleted by commands that go through magit-commit-squash-internal. In the case of magit-commit{,-instant}-{fixup,squash}, this is because the editor isn't invoked. For magit-commit-augment, the editor is invoked, but the diff is already displayed by the time with-editor stores the initial window configuration. Teach magit-commit-squash-internal to restore the window configuration so that these commands behave the same as other commit commands. Closes #4767.
2022-09-25magit-post-commit-hook: Fix variable reference in docsKyle Meyer
2022-09-19magit-commit-diff-1: Fix display buffer action alist syntaxBasil L. Contovounesios
Technically (t) and t are equally valid non-nil values for the `inhibit-same-window' display buffer action alist entry, but to minimize confusion and proliferation of future mistakes, use the simpler and more widespread boolean.
2022-07-21magit-commit-diff-1: Fix recent regression in --all handlingKyle Meyer
As of 2dfeaa68 (magit-commit-diff-1: Use different heuristics, 2022-06-07), magit-commit-diff-1 uses magit-anything-unstaged-p when deciding what diff to show. However, $GIT_DIR is the default directory when magit-commit-diff-1 is called, so the 'git diff' command used by magit-anything-unstaged-p fails with an exit code of 128, leading to magit-anything-unstaged-p returning nil even when there are unstaged changes. Switch to the top-level of the working tree so that magit-anything-unstaged-p gives an accurate answer. Closes #4725.
2022-06-07magit-commit-diff-1: Use different heuristicsJonas Bernoulli
Most importantly, do not show an alternative diff unless we are confident that doing so is useful, or at least not highly confusing. No longer derive the alternative diff from the arguments used for the initial diff. Ignore the last rebase command, because very often that has nothing to do with the commit that is being created. Closes #3246.
2022-06-07magit-commit-diff: Remember commit commandJonas Bernoulli
2022-06-07magit-commit-diff-1: Determine arguments only hereJonas Bernoulli
The logic is the same as before but instead of determining the appropriate diff command and calling that, we determine the appropriate diff arguments and then call `magit-diff-setup-buffer' directly instead of the respective command.
2022-06-06Remove outdated commit-diff commentJonas Bernoulli