1+ #include "git-compat-util.h"
12#include "cache.h"
23#include "branch.h"
34#include "refs.h"
@@ -49,12 +50,11 @@ static int should_setup_rebase(const char *origin)
4950
5051void install_branch_config (int flag , const char * local , const char * origin , const char * remote )
5152{
52- const char * shortname = remote + 11 ;
53- int remote_is_branch = starts_with (remote , "refs/heads/" );
53+ const char * shortname = skip_prefix (remote , "refs/heads/" );
5454 struct strbuf key = STRBUF_INIT ;
5555 int rebasing = should_setup_rebase (origin );
5656
57- if (remote_is_branch
57+ if (shortname
5858 && !strcmp (local , shortname )
5959 && !origin ) {
6060 warning (_ ("Not setting branch %s as its own upstream." ),
@@ -77,29 +77,29 @@ void install_branch_config(int flag, const char *local, const char *origin, cons
7777 strbuf_release (& key );
7878
7979 if (flag & BRANCH_CONFIG_VERBOSE ) {
80- if (remote_is_branch && origin )
80+ if (shortname && origin )
8181 printf_ln (rebasing ?
8282 _ ("Branch %s set up to track remote branch %s from %s by rebasing." ) :
8383 _ ("Branch %s set up to track remote branch %s from %s." ),
8484 local , shortname , origin );
85- else if (remote_is_branch && !origin )
85+ else if (shortname && !origin )
8686 printf_ln (rebasing ?
8787 _ ("Branch %s set up to track local branch %s by rebasing." ) :
8888 _ ("Branch %s set up to track local branch %s." ),
8989 local , shortname );
90- else if (!remote_is_branch && origin )
90+ else if (!shortname && origin )
9191 printf_ln (rebasing ?
9292 _ ("Branch %s set up to track remote ref %s by rebasing." ) :
9393 _ ("Branch %s set up to track remote ref %s." ),
9494 local , remote );
95- else if (!remote_is_branch && !origin )
95+ else if (!shortname && !origin )
9696 printf_ln (rebasing ?
9797 _ ("Branch %s set up to track local ref %s by rebasing." ) :
9898 _ ("Branch %s set up to track local ref %s." ),
9999 local , remote );
100100 else
101- die ("BUG: impossible combination of %d and %p" ,
102- remote_is_branch , origin );
101+ die ("BUG: impossible combination of %p and %p" ,
102+ shortname , origin );
103103 }
104104}
105105
0 commit comments