git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] branch -l: print useful info whilst rebasing a non-local branch
@ 2018-03-24 18:38 Kaartic Sivaraam
  2018-03-25  1:34 ` Eric Sunshine
  2018-04-03  4:31 ` [PATCH v2 1/2] branch --list: print useful info whilst interactive rebasing a detached HEAD Kaartic Sivaraam
  0 siblings, 2 replies; 27+ messages in thread
From: Kaartic Sivaraam @ 2018-03-24 18:38 UTC (permalink / raw)
  To: Git mailing list

When rebasing interacitvely (rebase -i), "git branch -l" prints a line
indicating the current branch being rebased. This works well when the
interactive rebase was intiated when a local branch is checked out.

This doesn't play well when the rebase was initiated on a remote
branch or an arbitrary commit that is not pointed to by a local
branch. In this case "git branch -l" tries to print the name of a
branch using an unintialized variable and thus tries to print a "null
pointer string". As a consequence, it does not provide useful
information while also inducing undefined behaviour.

So, print the commit from which the rebase started when interactive
rebasing a non-local branch.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
---
 ref-filter.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ref-filter.c b/ref-filter.c
index f9e25aea7..a4c917c96 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1310,8 +1310,16 @@ char *get_head_description(void)
 	wt_status_get_state(&state, 1);
 	if (state.rebase_in_progress ||
 	    state.rebase_interactive_in_progress)
+	{
+		const char *rebasing = NULL;
+		if (state.branch != NULL)
+			rebasing = state.branch;
+		else
+			rebasing = state.detached_from;
+
 		strbuf_addf(&desc, _("(no branch, rebasing %s)"),
-			    state.branch);
+			    rebasing);
+	}
 	else if (state.bisect_in_progress)
 		strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
 			    state.branch);
-- 
2.17.0.rc0.231.g781580f06


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2018-04-04  8:09 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-24 18:38 [PATCH] branch -l: print useful info whilst rebasing a non-local branch Kaartic Sivaraam
2018-03-25  1:34 ` Eric Sunshine
2018-03-25  3:41   ` Kaartic Sivaraam
2018-03-25  4:10     ` Jeff King
2018-03-25  4:13       ` Eric Sunshine
2018-03-25  4:28       ` Eric Sunshine
2018-03-25  4:33         ` Jeff King
2018-03-25  6:54           ` Kaartic Sivaraam
2018-03-25  7:15           ` Jacob Keller
2018-03-26  7:25             ` Jeff King
2018-03-26  7:26               ` [PATCH 1/5] t3200: unset core.logallrefupdates when testing reflog creation Jeff King
2018-03-26  7:26               ` [PATCH 2/5] t: switch "branch -l" to "branch --create-reflog" Jeff King
2018-03-26  7:28               ` [PATCH 3/5] branch: deprecate "-l" option Jeff King
2018-03-26  7:29               ` [PATCH 4/5] branch: drop deprecated " Jeff King
2018-03-26  7:29               ` [PATCH 5/5] branch: make "-l" a synonym for "--list" Jeff King
2018-03-26  7:44               ` [PATCH] branch -l: print useful info whilst rebasing a non-local branch Eric Sunshine
2018-03-26 18:38                 ` Jacob Keller
2018-03-25 17:06           ` Junio C Hamano
2018-03-25  5:48     ` Eric Sunshine
2018-03-25  7:36       ` Kaartic Sivaraam
2018-04-03  4:31 ` [PATCH v2 1/2] branch --list: print useful info whilst interactive rebasing a detached HEAD Kaartic Sivaraam
2018-04-03  4:31   ` [PATCH v2 2/2] t3200: verify "branch --list" sanity when rebasing from " Kaartic Sivaraam
2018-04-03  8:00     ` Eric Sunshine
2018-04-03 12:58       ` Kaartic Sivaraam
2018-04-03 14:47       ` [PATCH v3 " Kaartic Sivaraam
2018-04-04  8:09         ` Eric Sunshine
2018-04-03  5:02   ` [PATCH v2 0/2] branch --list: print useful info whilst interactive rebasing a " Kaartic Sivaraam

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).