Nguyễn Thái Ngọc Duy wrote:

> Signed-off-by: Nguyễn Thái Ngọc Duy <>
> ---
>  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?

> --- 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;
> -    = 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/ for
comparison, skipping the cases that don't involve automatically
detaching HEAD:

        if (!stat(git_path("rebase-merge"), &st) && S_ISDIR(st.st_mode))
       = xstrdup(_("(rebasing)"));
        else if (!access(git_path("rebase-apply/rebasing"), F_OK))
       = xstrdup(_("(rebasing)"));
        else if (!access(git_path("BISECT_LOG"), F_OK))
       = xstrdup(_("(bisecting)"));
       = 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. :)

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to