branch: elpa/magit
commit f0fdeab4c94beecfc102a95dab0c8e26fbb37dd0
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-wip-merge-branch: Remove adventurous "immediately" variant
It has a race condition and that isn't worth it.
---
docs/magit.org | 12 ++++--------
docs/magit.texi | 12 ++++--------
lisp/magit-wip.el | 31 +++++++++----------------------
3 files changed, 17 insertions(+), 38 deletions(-)
diff --git a/docs/magit.org b/docs/magit.org
index 3c6502ba90..2e566dfb5a 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -7851,19 +7851,15 @@ are being committed.
This option controls whether the current branch is merged into the
wip refs after a new commit was created on the branch.
- If non-~nil~ and the current branch has new commits, then it is
- merged into the wip ref before creating a new wip commit. This
- makes it easier to inspect wip history and the wip commits are
- never garbage collected.
-
If ~nil~ and the current branch has new commits, then the wip ref
is reset to the tip of the branch before creating a new wip
commit. With this setting wip commits are eventually garbage
collected.
- If ~immediately~, then use ~git-commit-post-finish-hook~ to
- create the merge commit. This is discouraged because it can
- lead to a race condition, e.g., during rebases.
+ If non-~nil~ and the current branch has new commits, then it is
+ merged into the wip ref before creating a new wip commit. This
+ makes it easier to inspect wip history and the wip commits are
+ never garbage collected.
When ~magit-wip-merge-branch~ is ~t~, then the history looks like this:
diff --git a/docs/magit.texi b/docs/magit.texi
index 2b4dccda7e..880e789ab4 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -9448,19 +9448,15 @@ Mode-line lighter for @code{magit-wip--mode}.
This option controls whether the current branch is merged into the
wip refs after a new commit was created on the branch.
-If non-@code{nil} and the current branch has new commits, then it is
-merged into the wip ref before creating a new wip commit. This
-makes it easier to inspect wip history and the wip commits are
-never garbage collected.
-
If @code{nil} and the current branch has new commits, then the wip ref
is reset to the tip of the branch before creating a new wip
commit. With this setting wip commits are eventually garbage
collected.
-If @code{immediately}, then use @code{git-commit-post-finish-hook} to
-create the merge commit. This is discouraged because it can
-lead to a race condition, e.g., during rebases.
+If non-@code{nil} and the current branch has new commits, then it is
+merged into the wip ref before creating a new wip commit. This
+makes it easier to inspect wip history and the wip commits are
+never garbage collected.
@end defopt
When @code{magit-wip-merge-branch} is @code{t}, then the history looks like
this:
diff --git a/lisp/magit-wip.el b/lisp/magit-wip.el
index d3131a619c..24a8503c83 100644
--- a/lisp/magit-wip.el
+++ b/lisp/magit-wip.el
@@ -49,19 +49,15 @@
(defcustom magit-wip-merge-branch nil
"Whether to merge the current branch into its wip ref.
-If non-nil and the current branch has new commits, then it is
-merged into the wip ref before creating a new wip commit. This
-makes it easier to inspect wip history and the wip commits are
-never garbage collected.
-
If nil and the current branch has new commits, then the wip ref
is reset to the tip of the branch before creating a new wip
commit. With this setting wip commits are eventually garbage
collected. This is currently the default.
-If `immediately', then use `git-commit-post-finish-hook' to
-create the merge commit. This is discouraged because it can
-lead to a race condition, e.g., during rebases.
+If non-nil and the current branch has new commits, then it is
+merged into the wip ref before creating a new wip commit. This
+makes it easier to inspect wip history and the wip commits are
+never garbage collected.
If `githook', then use `magit-common-git-post-commit-hook' to
create the merge commit. This uses the experimental support for
@@ -70,15 +66,8 @@ Customize `magit-overriding-githook-directory' to enable use
of
Git hooks."
:package-version '(magit . "2.90.0")
:group 'magit-wip
- :set (lambda (symbol value)
- (set-default-toplevel-value symbol value)
- (when (bound-and-true-p magit-wip-mode)
- (if (eq value 'immediately)
- (add-hook 'git-commit-post-finish-hook #'magit-wip-commit)
- (remove-hook 'git-commit-post-finish-hook #'magit-wip-commit))))
:type '(choice
- (const :tag "Yes (safely, just in time)" t)
- (const :tag "Yes (immediately, with race condition)" immediately)
+ (const :tag "Yes (just in time)" t)
(const :tag "Yes (using experimental Git hook support)" githook)
(const :tag "No" nil)))
@@ -110,23 +99,21 @@ buffer."
:package-version '(magit . "2.90.0")
:lighter magit-wip-mode-lighter
:global t
- :set-after '(magit-wip-merge-branch)
(cond
(magit-wip-mode
(add-hook 'after-save-hook #'magit-wip-commit-buffer-file)
(add-hook 'magit-after-apply-functions #'magit-wip-commit)
(add-hook 'magit-before-change-functions #'magit-wip-commit)
(add-hook 'before-save-hook #'magit-wip-commit-initial-backup)
- (add-hook 'magit-common-git-post-commit-functions #'magit-wip-post-commit)
- (when (eq magit-wip-merge-branch 'immediately)
- (add-hook 'git-commit-post-finish-hook #'magit-wip-commit)))
+ (add-hook 'magit-common-git-post-commit-functions
+ #'magit-wip-post-commit))
(t
(remove-hook 'after-save-hook #'magit-wip-commit-buffer-file)
(remove-hook 'magit-after-apply-functions #'magit-wip-commit)
(remove-hook 'magit-before-change-functions #'magit-wip-commit)
(remove-hook 'before-save-hook #'magit-wip-commit-initial-backup)
- (remove-hook 'magit-common-git-post-commit-functions
#'magit-wip-post-commit)
- (remove-hook 'git-commit-post-finish-hook #'magit-wip-commit))))
+ (remove-hook 'magit-common-git-post-commit-functions
+ #'magit-wip-post-commit))))
(defun magit-wip-commit-buffer-file (&optional msg)
"Commit visited file to a worktree work-in-progress ref."