git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] branch: add show-tracking option

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
May 16, 2013, 08:00 UTC
Message-ID
<5194921F.4080103@drmicha.warpmail.net>
In-Reply-To
<1368690532-12093-1-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras venit, vidit, dixit 16.05.2013 09:48:
> Showing the tracking information for all the branches takes significant
> amount of time. The user might not want that. The --no-show-tracking
> option allows that.

I really like the idea of allowing that - not just because I've suggested so myself in the past ;)

I feel, though, that we're really exploding our option and config realm. For "git branch" in list mode, we are already able to stack "-v", i.e. "-v" and "-vv" do different things. How about maybe adding "-vvv" and arranging things so that the verbosity and the run time increases with the number of v's?

-v list with sha1 + subject of last commit -vv add upstream branch name -vvv add ahead/behind info (the only costly mode) -vvvv same with "--cherry" (ahead/behind/same)

Or maybe combine the middle two cases into "-vv", which means it would be the same as "-vv", with only "-v" changing what it does now.

Yes, this changes current behavior (at least fpr -v), which sucks anyways because of the costly lookup. And those scripting around "branch -v" should get what they deserve. (I may sound annoyed by our compatibility brakes, but here's a case where breaking it should be OK.)

Show 59 quoted lines
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  Documentation/git-branch.txt | 5 ++++-
>  builtin/branch.c             | 4 +++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
> index b7cb625..1db04cd 100644
> --- a/Documentation/git-branch.txt
> +++ b/Documentation/git-branch.txt
> @@ -9,7 +9,7 @@ SYNOPSIS
>  --------
>  [verse]
>  'git branch' [--color[=<when>] | --no-color] [-r | -a]
> -	[--list] [-v [--abbrev=<length> | --no-abbrev]]
> +	[--list] [-v [--abbrev=<length> | --no-abbrev] --show-tracking]
>  	[--column[=<options>] | --no-column]
>  	[(--merged | --no-merged | --contains) [<commit>]] [<pattern>...]
>  'git branch' [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]
> @@ -154,6 +154,9 @@ This option is only applicable in non-verbose mode.
>  --no-abbrev::
>  	Display the full sha1s in the output listing rather than abbreviating them.
>  
> +--show-tracking::
> +	Display the tracking information when using --verbose, or not.
> +
>  -t::
>  --track::
>  	When creating a new branch, set up configuration to mark the
> diff --git a/builtin/branch.c b/builtin/branch.c
> index 0836890..2b586ea 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -33,6 +33,7 @@ static const char * const builtin_branch_usage[] = {
>  
>  static const char *head;
>  static unsigned char head_sha1[20];
> +static int show_tracking = 1;
>  
>  static int branch_use_color = -1;
>  static char branch_colors[][COLOR_MAXLEN] = {
> @@ -424,7 +425,7 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
>  	struct branch *branch = branch_get(branch_name);
>  	struct strbuf fancy = STRBUF_INIT;
>  
> -	if (!stat_tracking_info(branch, &ours, &theirs)) {
> +	if (!(show_tracking && stat_tracking_info(branch, &ours, &theirs))) {
>  		if (branch && branch->merge && branch->merge[0]->dst &&
>  		    show_upstream_ref) {
>  			ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
> @@ -840,6 +841,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>  			opt_parse_merge_filter, (intptr_t) "HEAD",
>  		},
>  		OPT_COLUMN(0, "column", &colopts, N_("list branches in columns")),
> +		OPT_BOOL(0, "show-tracking", &show_tracking, N_("show tracking information")),
>  		OPT_END(),
>  	};
>  
> 
Previous: Felipe ContrerasNext: Felipe Contreras
Message 5 of 14 in “branch: add show-tracking option”
  1. branch: add show-tracking optionFelipe Contreras, May 16, 2013
  2. Felipe ContrerasMay 16, 2013
  3. Duy NguyenMay 16, 2013
  4. Felipe ContrerasMay 16, 2013
  5. Michael J GruberMay 16, 2013
  6. Felipe ContrerasMay 16, 2013
  7. Michael J GruberMay 16, 2013
  8. Duy NguyenMay 16, 2013
  9. Michael J GruberMay 16, 2013
  10. Duy NguyenMay 16, 2013
  11. Junio C HamanoMay 16, 2013
  12. Felipe ContrerasMay 16, 2013
  13. Junio C HamanoMay 16, 2013
  14. Junio C HamanoMay 16, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.