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

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

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 29, 2013, 12:12 UTC
Message-ID
<1359461574-24529-1-git-send-email-pclouds@gmail.com>
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.
 builtin/branch.c            | 10 +++++++++-
 t/t6030-bisect-porcelain.sh |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 873f624..b0c5a20 100644
--- 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))
+			item.name = xstrdup(_("(rebasing)"));
+		else if (!stat(git_path("BISECT_LOG"), &st))
+			item.name = xstrdup(_("(bisecting)"));
+		else
+			item.name = xstrdup(_("(no branch)"));
 		item.width = utf8_strwidth(item.name);
 		item.kind = REF_LOCAL_BRANCH;
 		item.dest = NULL;
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 3e0e15f..bc21bc9 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -164,7 +164,7 @@ test_expect_success 'bisect start: existing ".git/BISECT_START" not modified if
 	cp .git/BISECT_START saved &&
 	test_must_fail git bisect start $HASH4 foo -- &&
 	git branch > branch.output &&
-	test_i18ngrep "* (no branch)" branch.output > /dev/null &&
+	test_i18ngrep "* (bisecting)" branch.output > /dev/null &&
 	test_cmp saved .git/BISECT_START
 '
 test_expect_success 'bisect start: no ".git/BISECT_START" if mistaken rev' '
-- 
1.8.1.1.459.g5970e58
Next: Jonathan Nieder
Message 1 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.