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

Re: [PATCH] branch: show (rebasing) or (bisecting) instead of (no branch) when possible

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 29, 2013, 19:13 UTC
Message-ID
<20130129191321.GB18266@google.com>
In-Reply-To
<1359461574-24529-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
Show 5 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  In the spirit of status' in-progress info. I think showing this is
>  more useful than "(no branch)". I tend to do "git br" more often than
>  "git st" and this catches my eyes.

Very nice idea. This would also have been a nice way to avoid confusion when my officemate used bisect for the first time.

Any particular reason the above explanation is after the triple-dash instead of before it?

[...]
Show 11 quoted lines
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -557,7 +557,15 @@ static void show_detached(struct ref_list *ref_list)
>  
>  	if (head_commit && is_descendant_of(head_commit, ref_list->with_commit)) {
>  		struct ref_item item;
> -		item.name = xstrdup(_("(no branch)"));
> +		struct stat st;
> +		if ((!stat(git_path("rebase-apply"), &st) &&
> +		     stat(git_path("rebase-apply/applying"), &st)) ||
> +		    !stat(git_path("rebase-merge"), &st))

Here's a straight translation of contrib/completion/prompt.sh for comparison, skipping the cases that don't involve automatically detaching HEAD:

	if (!stat(git_path("rebase-merge"), &st) && S_ISDIR(st.st_mode))
		item.name = xstrdup(_("(rebasing)"));
	else if (!access(git_path("rebase-apply/rebasing"), F_OK))
		item.name = xstrdup(_("(rebasing)"));
	else if (!access(git_path("BISECT_LOG"), F_OK))
		item.name = xstrdup(_("(bisecting)"));
	else
		item.name = xstrdup(_("(no branch)"));
That would mean:
 * using access() instead of stat() to avoid unnecessary work
 * relying on rebase--am to write .git/rebase-apply/rebasing when
   appropriate instead of guessing
Not important, though. :)
Jonathan
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 14 in “branch: show (rebasing) or (bisecting) instead of (no branch) when possible”
  1. branch: show (rebasing) or (bisecting) instead of (no branch) when possibleNguyễn Thái Ngọc Duy, Jan 29, 2013
  2. Jonathan NiederJan 29, 2013
  3. branch: show rebase/bisect info when possible instead of "(no branch)"Nguyễn Thái Ngọc Duy, Feb 3, 2013
  4. Matthieu MoyFeb 3, 2013
  5. Junio C HamanoFeb 3, 2013
  6. Junio C HamanoFeb 3, 2013
  7. Matthieu MoyFeb 4, 2013
  8. Junio C HamanoFeb 4, 2013
  9. Duy NguyenFeb 4, 2013
  10. Duy NguyenFeb 4, 2013
  11. branch: show rebase/bisect info when possible instead of "(no branch)"Nguyễn Thái Ngọc Duy, Feb 8, 2013
  12. Junio C HamanoFeb 8, 2013
  13. Duy NguyenFeb 14, 2013
  14. Junio C HamanoFeb 11, 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.