Allow creating branches without committing in fast-import.
Some importers may want to create a branch long before they actually commit to it, or in some cases they may never commit to the branch but they still need the ref to be created in the repository after the import is complete. This extends the 'reset ' command to automatically create a new branch if the supplied reference isn't already known as a branch. While I'm at it I also modified the syntax of the reset command to terminate with an empty line, like commit and tag operate. This just makes the command set more consistent. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 11, 2007 at 22:28 UTC
9938ffc53a15c755bbd3894c02492b940ea34c4c
1 file changed
+7
-1
fast-import.c
+7
-1
@@ -36,7 +36,9 @@ Format of STDIN stream:
36
tag_msg;
37
tag_msg ::= data;
38
39
- reset_branch ::= 'reset' sp ref_str lf;
39
+ reset_branch ::= 'reset' sp ref_str lf
40
+ ('from' sp (ref_str | hexsha1 | sha1exp_str | idnum) lf)?
41
+ lf;
42
43
# note: the first idnum in a stream should be 1 and subsequent
44
# idnums should not have gaps between values as this will cause
@@ -1794,8 +1796,12 @@ static void cmd_reset_branch()
1796
b->branch_tree.tree = NULL;
1797
}
1798
}
1799
+ else
1800
+ b = new_branch(sp);
1801
if (str_uq)
1802
free(str_uq);
1803
+ read_next_command();
1804
+ cmd_from(b);
1805
}
1806
1807
static const char fast_import_usage[] =