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

Re: Bug: "git checkout -b" should be allowed in empty repo

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:57

Junio C Hamano [off-list ref] writes:
The patch is made on maint-1.7.6 track for no good reason, so it may have
some merge conflicts around "resolve_ref()" vs "resolve_refdup()" if we
were to apply it on a more modern codebase, but the resolution should be
trivial.
The resolution should look like this, just in case.

diff --cc builtin/checkout.c
index 5bf96ba,5894f40..41b9b34
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@@ -1079,5 -1102,16 +1092,16 @@@ int cmd_checkout(int argc, const char *
  	if (opts.writeout_stage)
  		die(_("--ours/--theirs is incompatible with switching branches."));
  
+ 	if (!new.commit) {
+ 		unsigned char rev[20];
+ 		int flag, status;
 -		const char *old_ref = resolve_ref("HEAD", rev, 0, &flag);
++		char *old_ref = resolve_refdup("HEAD", rev, 0, &flag);
+ 
+ 		if ((flag & REF_ISSYMREF) && is_null_sha1(rev)) {
+ 			status = switch_unborn_to_new_branch(&opts, old_ref);
 -			free((char *)old_ref);
++			free(old_ref);
+ 			return status;
+ 		}
+ 	}
  	return switch_branches(&opts, &new);
  }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help