@matheusbsbs / matheus-bagliano / commits / 4de53ce043
Fork 0

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>

Avery Pennarun committed Jul 16, 2008 at 15:19 UTC 4de53ce0437e7326908c4a0571ac4ff9b8d5aeff
1 file changed +10 -16
remote.c
+10 -16
@@ -1308,34 +1308,28 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
1308 int format_tracking_info(struct branch *branch, struct strbuf *sb)
1309 {
1310 int num_ours, num_theirs;
1311 - const char *base, *remote_msg;
1311 + const char *base;
1312
1313 if (!stat_tracking_info(branch, &num_ours, &num_theirs))
1314 return 0;
1315
1316 base = branch->merge[0]->dst;
1317 if (!prefixcmp(base, "refs/remotes/")) {
1318 - remote_msg = " remote";
1318 base += strlen("refs/remotes/");
1320 - } else {
1321 - remote_msg = "";
1319 }
1320 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' "
1322 "by %d commit%s.\n",
1326 - remote_msg, base,
1327 - num_ours, (num_ours == 1) ? "" : "s");
1323 + base, num_ours, (num_ours == 1) ? "" : "s");
1324 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, "
1327 "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");
1329 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);
1334 return 1;
1335 }