1
+ #include "git-compat-util.h"
1
2
#include "cache.h"
2
3
#include "branch.h"
3
4
#include "refs.h"
@@ -49,12 +50,11 @@ static int should_setup_rebase(const char *origin)
49
50
50
51
void install_branch_config (int flag , const char * local , const char * origin , const char * remote )
51
52
{
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/" );
54
54
struct strbuf key = STRBUF_INIT ;
55
55
int rebasing = should_setup_rebase (origin );
56
56
57
- if (remote_is_branch
57
+ if (shortname
58
58
&& !strcmp (local , shortname )
59
59
&& !origin ) {
60
60
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
77
77
strbuf_release (& key );
78
78
79
79
if (flag & BRANCH_CONFIG_VERBOSE ) {
80
- if (remote_is_branch && origin )
80
+ if (shortname && origin )
81
81
printf_ln (rebasing ?
82
82
_ ("Branch %s set up to track remote branch %s from %s by rebasing." ) :
83
83
_ ("Branch %s set up to track remote branch %s from %s." ),
84
84
local , shortname , origin );
85
- else if (remote_is_branch && !origin )
85
+ else if (shortname && !origin )
86
86
printf_ln (rebasing ?
87
87
_ ("Branch %s set up to track local branch %s by rebasing." ) :
88
88
_ ("Branch %s set up to track local branch %s." ),
89
89
local , shortname );
90
- else if (!remote_is_branch && origin )
90
+ else if (!shortname && origin )
91
91
printf_ln (rebasing ?
92
92
_ ("Branch %s set up to track remote ref %s by rebasing." ) :
93
93
_ ("Branch %s set up to track remote ref %s." ),
94
94
local , remote );
95
- else if (!remote_is_branch && !origin )
95
+ else if (!shortname && !origin )
96
96
printf_ln (rebasing ?
97
97
_ ("Branch %s set up to track local ref %s by rebasing." ) :
98
98
_ ("Branch %s set up to track local ref %s." ),
99
99
local , remote );
100
100
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 );
103
103
}
104
104
}
105
105
0 commit comments