aboutsummaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-08-27 06:20:49 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-01-14 02:15:09 -0500
commit5fced8dc6f4844997b6e25a67a00f428775c5233 (patch)
treef474eb7bf82dbddb9443f606c5e4b2e8a5e0372d /fast-import.c
parent53dbce78a2a018bd2828d3ecc4123015f88ae36f (diff)
downloadgit-5fced8dc6f4844997b6e25a67a00f428775c5233.tar.gz
git-5fced8dc6f4844997b6e25a67a00f428775c5233.tar.xz
Added 'reset' command to clear a branch's tree.
Sometimes an import frontend may need to work with a temporary branch which will actually contain many different branches over the life of the import. This is especially useful when the frontend needs to create a tag from a set of file versions which are otherwise never a commit. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/fast-import.c b/fast-import.c
index f3376c60e..778b8bfdd 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -6,6 +6,7 @@ Format of STDIN stream:
cmd ::= new_blob
| new_commit
| new_tag
+ | reset_branch
;
new_blob ::= 'blob' lf
@@ -34,6 +35,8 @@ Format of STDIN stream:
tag_msg;
tag_msg ::= data;
+ reset_branch ::= 'reset' sp ref_str lf;
+
# note: the first idnum in a stream should be 1 and subsequent
# idnums should not have gaps between values as this will cause
# the stream parser to reserve space for the gapped values. An
@@ -1604,6 +1607,33 @@ static void cmd_new_tag()
}
}
+static void cmd_reset_branch()
+{
+ struct branch *b;
+ char *str_uq;
+ const char *endp;
+ char *sp;
+
+ /* Obtain the branch name from the rest of our command */
+ sp = strchr(command_buf.buf, ' ') + 1;
+ str_uq = unquote_c_style(sp, &endp);
+ if (str_uq) {
+ if (*endp)
+ die("Garbage after ref in: %s", command_buf.buf);
+ sp = str_uq;
+ }
+ b = lookup_branch(sp);
+ if (b) {
+ b->last_commit = 0;
+ if (b->branch_tree.tree) {
+ release_tree_content_recursive(b->branch_tree.tree);
+ b->branch_tree.tree = NULL;
+ }
+ }
+ if (str_uq)
+ free(str_uq);
+}
+
static const char fast_import_usage[] =
"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file] [--branch-log=log] temp.pack";
@@ -1673,6 +1703,8 @@ int main(int argc, const char **argv)
cmd_new_commit();
else if (!strncmp("tag ", command_buf.buf, 4))
cmd_new_tag();
+ else if (!strncmp("reset ", command_buf.buf, 6))
+ cmd_reset_branch();
else
die("Unsupported command: %s", command_buf.buf);
}