Skip to content

Commit 4de53ce

Browse files
apenwarrgitster
authored andcommitted
Reword "your branch has diverged..." lines to reduce line length
The message length depends on the length of the branch name. In my case, the branch name "origin/add-chickens2" put the first line of the "your branch has diverged" message over 80 characters, which triggered "less -FS" to not exit automatically as expected. This patch rewords the messages to make the lines generally shorter, so that you'd need a significantly longer branch name to trigger the problem. Signed-off-by: Avery Pennarun <apenwarr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fcab40a commit 4de53ce

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

remote.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,34 +1308,28 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
13081308
int format_tracking_info(struct branch *branch, struct strbuf *sb)
13091309
{
13101310
int num_ours, num_theirs;
1311-
const char *base, *remote_msg;
1311+
const char *base;
13121312

13131313
if (!stat_tracking_info(branch, &num_ours, &num_theirs))
13141314
return 0;
13151315

13161316
base = branch->merge[0]->dst;
13171317
if (!prefixcmp(base, "refs/remotes/")) {
1318-
remote_msg = " remote";
13191318
base += strlen("refs/remotes/");
1320-
} else {
1321-
remote_msg = "";
13221319
}
13231320
if (!num_theirs)
1324-
strbuf_addf(sb, "Your branch is ahead of the tracked%s branch '%s' "
1321+
strbuf_addf(sb, "Your branch is ahead of '%s' "
13251322
"by %d commit%s.\n",
1326-
remote_msg, base,
1327-
num_ours, (num_ours == 1) ? "" : "s");
1323+
base, num_ours, (num_ours == 1) ? "" : "s");
13281324
else if (!num_ours)
1329-
strbuf_addf(sb, "Your branch is behind the tracked%s branch '%s' "
1330-
"by %d commit%s,\n"
1325+
strbuf_addf(sb, "Your branch is behind '%s' "
1326+
"by %d commit%s, "
13311327
"and can be fast-forwarded.\n",
1332-
remote_msg, base,
1333-
num_theirs, (num_theirs == 1) ? "" : "s");
1328+
base, num_theirs, (num_theirs == 1) ? "" : "s");
13341329
else
1335-
strbuf_addf(sb, "Your branch and the tracked%s branch '%s' "
1336-
"have diverged,\nand respectively "
1337-
"have %d and %d different commit(s) each.\n",
1338-
remote_msg, base,
1339-
num_ours, num_theirs);
1330+
strbuf_addf(sb, "Your branch and '%s' have diverged,\n"
1331+
"and have %d and %d different commit(s) each, "
1332+
"respectively.\n",
1333+
base, num_ours, num_theirs);
13401334
return 1;
13411335
}

0 commit comments

Comments
 (0)