1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 04:36:10 +02:00

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>
This commit is contained in:
Shawn O. Pearce 2006-08-27 06:20:49 -04:00
parent 53dbce78a2
commit 5fced8dc6f

View File

@ -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);
}