Thread (1 message) 1 message, 1 author, 2016-06-15

Re: git checkout creates strange '(null)'-branch

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:46

Erik Faye-Lund [off-list ref] writes:
Before this commit, the checkout would error out with "fatal: You are
on a branch yet to be born". Perhaps abe1998 was too optimistic about
allowing this, and something like this would be in order?
quoted hunk
---8<---
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 23fc56d..35924d4 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1091,7 +1091,7 @@ int cmd_checkout(int argc, const char **argv,
const char *prefix)
 	if (opts.writeout_stage)
 		die(_("--ours/--theirs is incompatible with switching branches."));

-	if (!new.commit) {
+	if (!new.commit && opts.new_branch) {
 		unsigned char rev[20];
 		int flag;
---8<---
The patch looks like it will avoid flipping the HEAD, and in that case we
would go to switch_branches() codepath and will resurrect the old error
message, so it seems correct.

Thanks for digging.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help