[PATCH 3/3] rebase: hint when failing on branch used by another worktree
From: "Gabriel.Scherer" <gabriel.scherer@inria.fr>
Signed-off-by: Gabriel Scherer <gabriel.scherer@inria.fr>
---
builtin/rebase.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 7a57ebd852..05c86117fc 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -9,6 +9,7 @@
#include "builtin.h"
+#include "advice.h"
#include "abspath.h"
#include "environment.h"
#include "gettext.h"
@@ -1687,8 +1688,15 @@ int cmd_rebase(int argc,
strbuf_reset(&buf);
strbuf_addf(&buf, "refs/heads/%s", branch_name);
if (!refs_read_ref(get_main_ref_store(the_repository), buf.buf, &branch_oid)) {
- if (!options.ignore_other_worktrees)
- die_if_checked_out(buf.buf, 1);
+ if (!options.ignore_other_worktrees) {
+ int code = die_message_if_checked_out(buf.buf, 1);
+ if (code) {
+ advise_if_enabled(
+ ADVICE_BRANCH_USED_IN_OTHER_WORKTREE,
+ _("Use --ignore-other-worktrees to proceed anyway."));
+ exit(code);
+ }
+ }
options.head_name = xstrdup(buf.buf);
options.orig_head =
lookup_commit_object(the_repository,
--
2.51.0