aboutsummaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-02-07 02:03:03 -0500
committerShawn O. Pearce <spearce@spearce.org>2007-02-07 02:03:03 -0500
commit825769a8fe4d0529268fee7e763bc8f24ed4218e (patch)
tree8c8c4db7fbec5d41065d8ecaece4b6dd8d97347a /fast-import.c
parent9b92c82fde2dc42e5ec3240e673549418b88163e (diff)
downloadgit-825769a8fe4d0529268fee7e763bc8f24ed4218e.tar.gz
git-825769a8fe4d0529268fee7e763bc8f24ed4218e.tar.xz
Teach fast-import how to clear the internal branch content.
Some frontends may not be able to (easily) keep track of which files are included in the branch, and which aren't. Performing this tracking can be tedious and error prone for the frontend to do, especially if its foreign data source cannot supply the changed path list on a per-commit basis. fast-import now allows a frontend to request that a branch's tree be wiped clean (reset to the empty tree) at the start of a commit, allowing the frontend to feed in all paths which belong on the branch. This is ideal for a tar-file importer frontend, for example, as the frontend just needs to reformat the tar data stream into a gfi data stream, which may be something a few Perl regexps can take care of. :) Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fast-import.c b/fast-import.c
index c72c5c7a9..f80ddee2f 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -26,7 +26,8 @@ Format of STDIN stream:
lf;
commit_msg ::= data;
- file_change ::= file_del | file_obm | file_inm;
+ file_change ::= file_clr | file_del | file_obm | file_inm;
+ file_clr ::= 'deleteall' lf;
file_del ::= 'D' sp path_str lf;
file_obm ::= 'M' sp mode sp (hexsha1 | idnum) sp path_str lf;
file_inm ::= 'M' sp mode sp 'inline' sp path_str lf
@@ -1640,6 +1641,14 @@ static void file_change_d(struct branch *b)
free(p_uq);
}
+static void file_change_deleteall(struct branch *b)
+{
+ release_tree_content_recursive(b->branch_tree.tree);
+ hashclr(b->branch_tree.versions[0].sha1);
+ hashclr(b->branch_tree.versions[1].sha1);
+ load_tree(&b->branch_tree);
+}
+
static void cmd_from(struct branch *b)
{
const char *from;
@@ -1784,6 +1793,8 @@ static void cmd_new_commit(void)
file_change_m(b);
else if (!strncmp("D ", command_buf.buf, 2))
file_change_d(b);
+ else if (!strcmp("deleteall", command_buf.buf))
+ file_change_deleteall(b);
else
die("Unsupported file_change: %s", command_buf.buf);
read_next_command();