---
transport.c | 41 ++++++++++++++++++++++++++++++++++-------
1 file changed, 34 insertions(+), 7 deletions(-)
diff --git a/transport.c b/transport.c
index ca7bb44..ac933ee 100644
--- a/transport.c
+++ b/transport.c
@@ -143,6 +143,25 @@ static void insert_packed_refs(const char *packed_refs,
struct ref **list)
}
}
+/* That of course should not be hardcoded. */
+static const char* list_of_local_refs[] = {"refs/heads/", "refs/wip/", NULL};
+static const char** get_local_refs(void)
+{
+ return list_of_local_refs;
+}
+
+static int is_local_ref(const char *ref)
+{
+ const char **local_refs = get_local_refs();
+ const char **iter;
+
+ for (iter = local_refs; iter != NULL; ++iter)
+ if (starts_with(ref, *iter))
+ return strlen(*iter);
+
+ return 0;
+}
+
static void set_upstreams(struct transport *transport, struct ref *refs,
int pretend)
{
@@ -153,6 +172,8 @@ static void set_upstreams(struct transport *transport,
struct ref *refs,
const char *remotename;
unsigned char sha[20];
int flag = 0;
+ int localadd = 0;
+ int remoteadd = 0;
/*
* Check suitability for tracking. Must be successful /
* already up-to-date ref create/modify (not delete).
@@ -169,23 +190,29 @@ static void set_upstreams(struct transport *transport,
struct ref *refs,
localname = ref->peer_ref->name;
remotename = ref->name;
tmp = resolve_ref_unsafe(localname, sha, 1, &flag);
- if (tmp && flag & REF_ISSYMREF &&
- starts_with(tmp, "refs/heads/"))
- localname = tmp;
+
+ if (tmp && flag & REF_ISSYMREF) {
+ localadd = is_local_ref (tmp);
+ if (localadd > 0)
+ localname = tmp;
+ }
+ if (localadd == 0)
+ localadd = is_local_ref(localname);
+ remoteadd = is_local_ref(remotename);
/* Both source and destination must be local branches. */
- if (!localname || !starts_with(localname, "refs/heads/"))
+ if (!localname || localadd == 0)
continue;
- if (!remotename || !starts_with(remotename, "refs/heads/"))
+ if (!remotename || remoteadd == 0)
continue;
if (!pretend)
install_branch_config(BRANCH_CONFIG_VERBOSE,
- localname + 11, transport->remote->name,
+ localname + localadd, transport->remote->name,
remotename);
else
printf("Would set upstream of '%s' to '%s' of '%s'\n",
- localname + 11, remotename + 11,
+ localname + localadd, remotename + remoteadd,
transport->remote->name);
}
}
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html