From: Alex Henrie <alexhenrie24@gmail.com>
To: git@vger.kernel.org, git@matthieu-moy.fr, christiwald@gmail.com,
john@keeping.me.uk, philipoakley@iee.email,
phillip.wood123@gmail.com, phillip.wood@dunelm.org.uk
Cc: Alex Henrie <alexhenrie24@gmail.com>
Subject: [PATCH v5 1/3] wt-status: don't show divergence advice when committing
Date: Wed, 12 Jul 2023 22:41:13 -0600 [thread overview]
Message-ID: <20230713044128.3771818-2-alexhenrie24@gmail.com> (raw)
In-Reply-To: <20230713044128.3771818-1-alexhenrie24@gmail.com>
When the user is in the middle of making a commit, they are not yet at
the point where they are ready to think about integrating their local
branch with the corresponding remote branch or force-pushing over the
remote branch. Don't include advice on how to deal with divergent
branches in the commit template, to avoid giving the impression that the
divergence needs to be dealt with immediately. Similar advice will be
printed when it is most relevant, that is, if the user does try to push
without first reconciling the two branches.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
builtin/checkout.c | 2 +-
remote.c | 6 ++++--
remote.h | 3 ++-
t/t7508-status.sh | 10 ++++------
wt-status.c | 3 ++-
5 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index fd6ee8c272..c278c2169d 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -916,7 +916,7 @@ static void report_tracking(struct branch_info *new_branch_info)
struct strbuf sb = STRBUF_INIT;
struct branch *branch = branch_get(new_branch_info->name);
- if (!format_tracking_info(branch, &sb, AHEAD_BEHIND_FULL))
+ if (!format_tracking_info(branch, &sb, AHEAD_BEHIND_FULL, 1))
return;
fputs(sb.buf, stdout);
strbuf_release(&sb);
diff --git a/remote.c b/remote.c
index a81f2e2f17..d79aae0d76 100644
--- a/remote.c
+++ b/remote.c
@@ -2258,7 +2258,8 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
* Return true when there is anything to report, otherwise false.
*/
int format_tracking_info(struct branch *branch, struct strbuf *sb,
- enum ahead_behind_flags abf)
+ enum ahead_behind_flags abf,
+ int show_divergence_advice)
{
int ours, theirs, sti;
const char *full_base;
@@ -2321,7 +2322,8 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
"respectively.\n",
ours + theirs),
base, ours, theirs);
- if (advice_enabled(ADVICE_STATUS_HINTS))
+ if (show_divergence_advice &&
+ advice_enabled(ADVICE_STATUS_HINTS))
strbuf_addstr(sb,
_(" (use \"git pull\" to merge the remote branch into yours)\n"));
}
diff --git a/remote.h b/remote.h
index 929c7c676d..cdc8b1db42 100644
--- a/remote.h
+++ b/remote.h
@@ -380,7 +380,8 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
const char **upstream_name, int for_push,
enum ahead_behind_flags abf);
int format_tracking_info(struct branch *branch, struct strbuf *sb,
- enum ahead_behind_flags abf);
+ enum ahead_behind_flags abf,
+ int show_divergence_advice);
struct ref *get_local_heads(void);
/*
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 36567708f5..845af287d7 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -847,7 +847,6 @@ test_expect_success 'dry-run of partial commit excluding new file in index' '
On branch main
Your branch and '\''upstream'\'' have diverged,
and have 1 and 2 different commits each, respectively.
- (use "git pull" to merge the remote branch into yours)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
@@ -1013,7 +1012,7 @@ test_expect_success 'status -s submodule summary' '
'
test_expect_success 'status submodule summary (clean submodule): commit' '
- cat >expect <<EOF &&
+ cat >expect-status <<EOF &&
On branch main
Your branch and '\''upstream'\'' have diverged,
and have 2 and 2 different commits each, respectively.
@@ -1033,12 +1032,13 @@ Untracked files:
no changes added to commit (use "git add" and/or "git commit -a")
EOF
+ sed "/git pull/d" expect-status > expect-commit &&
git commit -m "commit submodule" &&
git config status.submodulesummary 10 &&
test_must_fail git commit --dry-run >output &&
- test_cmp expect output &&
+ test_cmp expect-commit output &&
git status >output &&
- test_cmp expect output
+ test_cmp expect-status output
'
cat >expect <<EOF
@@ -1065,7 +1065,6 @@ test_expect_success 'commit --dry-run submodule summary (--amend)' '
On branch main
Your branch and '\''upstream'\'' have diverged,
and have 2 and 2 different commits each, respectively.
- (use "git pull" to merge the remote branch into yours)
Changes to be committed:
(use "git restore --source=HEAD^1 --staged <file>..." to unstage)
@@ -1558,7 +1557,6 @@ test_expect_success 'git commit --dry-run will show a staged but ignored submodu
On branch main
Your branch and '\''upstream'\'' have diverged,
and have 2 and 2 different commits each, respectively.
- (use "git pull" to merge the remote branch into yours)
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
diff --git a/wt-status.c b/wt-status.c
index bcd0ef8044..e3e3732ea2 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1186,7 +1186,8 @@ static void wt_longstatus_print_tracking(struct wt_status *s)
t_begin = getnanotime();
- if (!format_tracking_info(branch, &sb, s->ahead_behind_flags))
+ if (!format_tracking_info(branch, &sb, s->ahead_behind_flags,
+ !s->commit_template))
return;
if (advice_enabled(ADVICE_STATUS_AHEAD_BEHIND_WARNING) &&
--
2.41.0
next prev parent reply other threads:[~2023-07-13 4:42 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-02 20:08 [PATCH 0/2] advise about force-pushing as an alternative to reconciliation Alex Henrie
2023-07-02 20:08 ` [PATCH 1/2] remote: " Alex Henrie
2023-07-02 20:08 ` [PATCH 2/2] push: " Alex Henrie
2023-07-03 15:33 ` [PATCH 0/2] " Phillip Wood
2023-07-03 16:26 ` Alex Henrie
2023-07-04 21:44 ` Junio C Hamano
2023-07-04 22:24 ` Alex Henrie
2023-07-05 5:30 ` Junio C Hamano
2023-07-06 2:32 ` Alex Henrie
2023-07-04 19:47 ` [PATCH v2 " Alex Henrie
2023-07-04 19:47 ` [PATCH v2 1/2] remote: " Alex Henrie
2023-07-04 21:51 ` Junio C Hamano
2023-07-04 22:41 ` Alex Henrie
2023-07-04 19:47 ` [PATCH v2 2/2] push: " Alex Henrie
2023-07-06 4:01 ` [PATCH v3 0/2] " Alex Henrie
2023-07-06 4:01 ` [PATCH v3 1/2] remote: " Alex Henrie
2023-07-06 20:25 ` Junio C Hamano
2023-07-06 20:40 ` Junio C Hamano
2023-07-06 23:23 ` Alex Henrie
2023-07-07 17:35 ` Junio C Hamano
2023-07-07 17:52 ` Junio C Hamano
2023-07-08 18:55 ` Alex Henrie
2023-07-09 1:38 ` Junio C Hamano
2023-07-10 4:44 ` Alex Henrie
2023-07-11 0:55 ` Junio C Hamano
2023-07-12 4:47 ` Alex Henrie
2023-07-12 15:18 ` Junio C Hamano
2023-07-13 4:09 ` Alex Henrie
2023-07-07 8:48 ` Phillip Wood
2023-07-06 4:01 ` [PATCH v3 2/2] push: " Alex Henrie
2023-07-07 8:49 ` Phillip Wood
2023-07-07 18:44 ` Junio C Hamano
2023-07-08 18:56 ` Alex Henrie
2023-07-11 18:33 ` Phillip Wood
2023-07-12 4:47 ` Alex Henrie
2023-07-12 4:55 ` Alex Henrie
2023-07-07 5:42 ` [PATCH v4 0/2] " Alex Henrie
2023-07-07 5:42 ` [PATCH v4 1/2] remote: " Alex Henrie
2023-07-07 5:42 ` [PATCH v4 2/2] push: " Alex Henrie
2023-07-13 4:41 ` [PATCH v5 0/3] don't imply that integration is always required before pushing Alex Henrie
2023-07-13 4:41 ` Alex Henrie [this message]
2023-07-13 4:41 ` [PATCH v5 2/3] remote: " Alex Henrie
2023-07-13 4:41 ` [PATCH v5 3/3] push: " Alex Henrie
2023-07-13 9:51 ` [PATCH v5 0/3] " Phillip Wood
2023-07-13 16:15 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230713044128.3771818-2-alexhenrie24@gmail.com \
--to=alexhenrie24@gmail.com \
--cc=christiwald@gmail.com \
--cc=git@matthieu-moy.fr \
--cc=git@vger.kernel.org \
--cc=john@keeping.me.uk \
--cc=philipoakley@iee.email \
--cc=phillip.wood123@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).