From: Junio C Hamano <gitster@pobox.com>
To: "Pat Notz" <pknotz@sandia.gov>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH] Improve "git branch --tracking" output
Date: Tue, 10 Mar 2009 01:20:42 -0700 [thread overview]
Message-ID: <7v63ihbxgl.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vab7tbxo0.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Tue, 10 Mar 2009 01:16:15 -0700")
An earlier patch always spelled the full name of the ref that we track
(e.g. "refs/heads/frotz" instead of just "frotz" when we mean the branch
whose name is "frotz"). Worse yet, because we now use the true name of
the ref at the original repository when talk about a tracking branch that
copies from a remote, such a full name alone still does not give enough
information.
This reorganizes the verbose codepath to:
- differentiate "refs/heads/something" and everything else; we say that
the branch tracks "branch <something>" if it begins with "refs/heads/",
and otherwise the branch tracks "ref refs/<someother>/<something>";
- report the name of the remote when we talk about a tracking branch, by
saying "branch frotz from origin";
- not say "by merging" at the end; it is the default and is not worth
reporting.
Signed-off-by: Junio C Hamano <junio@pobox.com>
---
branch.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/branch.c b/branch.c
index d20fb04..5f889fe 100644
--- a/branch.c
+++ b/branch.c
@@ -65,12 +65,23 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
git_config_set(key.buf, "true");
}
- if (flag & BRANCH_CONFIG_VERBOSE)
- printf("Branch %s set up to track %s branch %s %s.\n",
- local,
- origin ? "remote" : "local",
- remote,
- rebasing ? "by rebasing" : "by merging");
+ if (flag & BRANCH_CONFIG_VERBOSE) {
+ strbuf_reset(&key);
+
+ strbuf_addstr(&key, origin ? "remote" : "local");
+
+ /* Are we tracking a proper "branch"? */
+ if (!prefixcmp(remote, "refs/heads/")) {
+ strbuf_addf(&key, " branch %s", remote + 11);
+ if (origin)
+ strbuf_addf(&key, " from %s", origin);
+ }
+ else
+ strbuf_addf(&key, " ref %s", remote);
+ printf("Branch %s set up to track %s%s.\n",
+ local, key.buf,
+ rebasing ? " by rebasing" : "");
+ }
strbuf_release(&key);
}
prev parent reply other threads:[~2009-03-10 8:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1cd1989b0903060621w60124401s9986507e356783b1@mail.gmail.com>
2009-03-10 3:26 ` [PATCHv5] Make git-clone respect branch.autosetuprebase Pat Notz
2009-03-10 4:24 ` [PATCHv6] " Pat Notz
2009-03-10 8:16 ` Junio C Hamano
2009-03-10 8:20 ` Junio C Hamano [this message]
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=7v63ihbxgl.fsf_-_@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pknotz@sandia.gov \
/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).