summaryrefslogtreecommitdiff
path: root/transport-helper.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2009-11-18 01:42:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-11-18 05:45:44 (GMT)
commit72ff894308d4f6eb9f081167377857f7a3268bca (patch)
tree03cd6caf19a32bd7fbd8d3c416f6a0700366839e /transport-helper.c
parente65e91ed4af5ed9c5c810a2cd77b8648a0287e66 (diff)
downloadgit-72ff894308d4f6eb9f081167377857f7a3268bca.zip
git-72ff894308d4f6eb9f081167377857f7a3268bca.tar.gz
git-72ff894308d4f6eb9f081167377857f7a3268bca.tar.bz2
Allow helper to map private ref names into normal names
This allows a helper to say that, when it handles "import refs/heads/topic", the script it outputs will actually write to refs/svn/origin/branches/topic; therefore, transport-helper should read it from the latter location after git-fast-import completes. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport-helper.c')
-rw-r--r--transport-helper.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/transport-helper.c b/transport-helper.c
index 82caaae..da8185a 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -5,6 +5,7 @@
#include "commit.h"
#include "diff.h"
#include "revision.h"
+#include "remote.h"
struct helper_data
{
@@ -12,6 +13,9 @@ struct helper_data
struct child_process *helper;
unsigned fetch : 1;
unsigned import : 1;
+ /* These go from remote name (as in "list") to private name */
+ struct refspec *refspecs;
+ int refspec_nr;
};
static struct child_process *get_helper(struct transport *transport)
@@ -20,6 +24,9 @@ static struct child_process *get_helper(struct transport *transport)
struct strbuf buf = STRBUF_INIT;
struct child_process *helper;
FILE *file;
+ const char **refspecs = NULL;
+ int refspec_nr = 0;
+ int refspec_alloc = 0;
if (data->helper)
return data->helper;
@@ -51,6 +58,21 @@ static struct child_process *get_helper(struct transport *transport)
data->fetch = 1;
if (!strcmp(buf.buf, "import"))
data->import = 1;
+ if (!data->refspecs && !prefixcmp(buf.buf, "refspec ")) {
+ ALLOC_GROW(refspecs,
+ refspec_nr + 1,
+ refspec_alloc);
+ refspecs[refspec_nr++] = strdup(buf.buf + strlen("refspec "));
+ }
+ }
+ if (refspecs) {
+ int i;
+ data->refspec_nr = refspec_nr;
+ data->refspecs = parse_fetch_refspec(refspec_nr, refspecs);
+ for (i = 0; i < refspec_nr; i++) {
+ free((char *)refspecs[i]);
+ }
+ free(refspecs);
}
return data->helper;
}
@@ -72,6 +94,9 @@ static int disconnect_helper(struct transport *transport)
static int release_helper(struct transport *transport)
{
+ struct helper_data *data = transport->data;
+ free_refspec(data->refspec_nr, data->refspecs);
+ data->refspecs = NULL;
disconnect_helper(transport);
free(transport->data);
return 0;
@@ -119,6 +144,7 @@ static int fetch_with_import(struct transport *transport,
{
struct child_process fastimport;
struct child_process *helper = get_helper(transport);
+ struct helper_data *data = transport->data;
int i;
struct ref *posn;
struct strbuf buf = STRBUF_INIT;
@@ -139,10 +165,16 @@ static int fetch_with_import(struct transport *transport,
finish_command(&fastimport);
for (i = 0; i < nr_heads; i++) {
+ char *private;
posn = to_fetch[i];
if (posn->status & REF_STATUS_UPTODATE)
continue;
- read_ref(posn->name, posn->old_sha1);
+ if (data->refspecs)
+ private = apply_refspecs(data->refspecs, data->refspec_nr, posn->name);
+ else
+ private = strdup(posn->name);
+ read_ref(private, posn->old_sha1);
+ free(private);
}
return 0;
}