summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 10831c5)
raw | patch | inline | side by side (parent: 10831c5)
author | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 6 Feb 2007 01:30:37 +0000 (20:30 -0500) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 6 Feb 2007 01:30:37 +0000 (20:30 -0500) |
The current implementation of shell-style quoted refnames and
SHA-1 expressions within fast-import contains a bad memory leak.
We leak the unquoted strings used by the `from` and `merge`
commands, maybe others. Its also just muddling up the docs.
Since Git refnames cannot contain LF, and that is our delimiter
for the end of the refname, and we accept any other character
as-is, there is no reason for these strings to support quoting,
except to be nice to frontends. But frontends shouldn't be
expecting to use funny refs in Git, and its just as simple to
never quote them as it is to always pass them through the same
quoting filter as pathnames. So frontends should never quote
refs, or ref expressions.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
SHA-1 expressions within fast-import contains a bad memory leak.
We leak the unquoted strings used by the `from` and `merge`
commands, maybe others. Its also just muddling up the docs.
Since Git refnames cannot contain LF, and that is our delimiter
for the end of the refname, and we accept any other character
as-is, there is no reason for these strings to support quoting,
except to be nice to frontends. But frontends shouldn't be
expecting to use funny refs in Git, and its just as simple to
never quote them as it is to always pass them through the same
quoting filter as pathnames. So frontends should never quote
refs, or ref expressions.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
fast-import.c | patch | blob | history |
diff --git a/fast-import.c b/fast-import.c
index 9658c28413bc01b7f096b96841f6ed993d055b48..e6342386fc709ff661375b9e25317da0c780eb2f 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
# stream formatting is: \, " and LF. Otherwise these values
# are UTF8.
#
- ref_str ::= ref | '"' quoted(ref) '"' ;
- sha1exp_str ::= sha1exp | '"' quoted(sha1exp) '"' ;
- tag_str ::= tag | '"' quoted(tag) '"' ;
+ ref_str ::= ref;
+ sha1exp_str ::= sha1exp;
+ tag_str ::= tag;
path_str ::= path | '"' quoted(path) '"' ;
mode ::= '100644' | '644'
| '100755' | '755'
static void cmd_from(struct branch *b)
{
- const char *from, *endp;
- char *str_uq;
+ const char *from;
struct branch *s;
if (strncmp("from ", command_buf.buf, 5))
die("Can't reinitailize branch %s", b->name);
from = strchr(command_buf.buf, ' ') + 1;
- str_uq = unquote_c_style(from, &endp);
- if (str_uq) {
- if (*endp)
- die("Garbage after string in: %s", command_buf.buf);
- from = str_uq;
- }
-
s = lookup_branch(from);
if (b == s)
die("Can't create a branch from itself: %s", b->name);
static struct hash_list* cmd_merge(unsigned int *count)
{
struct hash_list *list = NULL, *n, *e;
- const char *from, *endp;
- char *str_uq;
+ const char *from;
struct branch *s;
*count = 0;
while (!strncmp("merge ", command_buf.buf, 6)) {
from = strchr(command_buf.buf, ' ') + 1;
- str_uq = unquote_c_style(from, &endp);
- if (str_uq) {
- if (*endp)
- die("Garbage after string in: %s", command_buf.buf);
- from = str_uq;
- }
-
n = xmalloc(sizeof(*n));
s = lookup_branch(from);
if (s)
struct branch *b;
void *msg;
size_t msglen;
- char *str_uq;
- const char *endp;
char *sp;
char *author = NULL;
char *committer = NULL;
/* 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 = new_branch(sp);
- if (str_uq)
- free(str_uq);
read_next_command();
cmd_mark();
static void cmd_new_tag(void)
{
- char *str_uq;
- const char *endp;
char *sp;
const char *from;
char *tagger;
/* Obtain the new tag 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 tag name in: %s", command_buf.buf);
- sp = str_uq;
- }
t = pool_alloc(sizeof(struct tag));
t->next_tag = NULL;
t->name = pool_strdup(sp);
else
first_tag = t;
last_tag = t;
- if (str_uq)
- free(str_uq);
read_next_command();
/* from ... */
if (strncmp("from ", command_buf.buf, 5))
die("Expected from command, got %s", command_buf.buf);
-
from = strchr(command_buf.buf, ' ') + 1;
- str_uq = unquote_c_style(from, &endp);
- if (str_uq) {
- if (*endp)
- die("Garbage after string in: %s", command_buf.buf);
- from = str_uq;
- }
-
s = lookup_branch(from);
if (s) {
hashcpy(sha1, s->sha1);
free(buf);
} else
die("Invalid ref name or SHA1 expression: %s", from);
-
- if (str_uq)
- free(str_uq);
read_next_command();
/* tagger ... */
static void cmd_reset_branch(void)
{
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;
}
else
b = new_branch(sp);
- if (str_uq)
- free(str_uq);
read_next_command();
cmd_from(b);
}