summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 39bd2eb)
raw | patch | inline | side by side (parent: 39bd2eb)
author | Pierre Habouzit <madcoder@debian.org> | |
Sat, 15 Sep 2007 22:32:36 +0000 (00:32 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 19 Sep 2007 00:42:17 +0000 (17:42 -0700) |
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 files changed:
attr.c | patch | blob | history | |
builtin-add.c | patch | blob | history | |
builtin-apply.c | patch | blob | history | |
builtin-fetch--tool.c | patch | blob | history | |
builtin-fmt-merge-msg.c | patch | blob | history | |
builtin-for-each-ref.c | patch | blob | history | |
builtin-log.c | patch | blob | history | |
builtin-ls-files.c | patch | blob | history | |
builtin-mv.c | patch | blob | history | |
builtin-revert.c | patch | blob | history | |
builtin-shortlog.c | patch | blob | history | |
commit.c | patch | blob | history | |
connect.c | patch | blob | history | |
convert.c | patch | blob | history | |
diff.c | patch | blob | history | |
diffcore-order.c | patch | blob | history | |
fast-import.c | patch | blob | history | |
http-push.c | patch | blob | history | |
imap-send.c | patch | blob | history | |
merge-recursive.c | patch | blob | history | |
refs.c | patch | blob | history | |
sha1_file.c | patch | blob | history | |
tag.c | patch | blob | history |
index 129399310ae061a66527ce0b723cc0aeb30ef34c..92704a3f61c6d43d0377d86feb6598e68797022b 100644 (file)
--- a/attr.c
+++ b/attr.c
else if (!equals)
e->setto = ATTR__TRUE;
else {
- char *value;
- int vallen = ep - equals;
- value = xmalloc(vallen);
- memcpy(value, equals+1, vallen-1);
- value[vallen-1] = 0;
- e->setto = value;
+ e->setto = xmemdupz(equals + 1, ep - equals - 1);
}
e->attr = git_attr(cp, len);
}
diff --git a/builtin-add.c b/builtin-add.c
index 0d7d0ce4209114245ca07842d7d5a4546e5b6cfd..f9a65803d8dcbb9ae7eb3a3c61d8ac345b84d1cd 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
baselen = common_prefix(pathspec);
path = ".";
base = "";
- if (baselen) {
- char *common = xmalloc(baselen + 1);
- memcpy(common, *pathspec, baselen);
- common[baselen] = 0;
- path = base = common;
- }
+ if (baselen)
+ path = base = xmemdupz(*pathspec, baselen);
/* Read the directory and prune it */
read_directory(dir, path, base, baselen, pathspec);
diff --git a/builtin-apply.c b/builtin-apply.c
index f953c5b768480e87aeb98d90d73c81167a937505..512c9b61429f8344402bbf1120c4e90ccf2e17dd 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -293,11 +293,7 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
return def;
}
- name = xmalloc(len + 1);
- memcpy(name, start, len);
- name[len] = 0;
- free(def);
- return name;
+ return xmemdupz(start, len);
}
static int count_slashes(const char *cp)
break;
}
if (second[len] == '\n' && !memcmp(name, second, len)) {
- char *ret = xmalloc(len + 1);
- memcpy(ret, name, len);
- ret[len] = 0;
- return ret;
+ return xmemdupz(name, len);
}
}
}
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 514a3cc018651d1257d9f88d78f2c208148c7f19..349b59c25865fb8ea3946c4176cc2aa08869af1e 100644 (file)
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
}
if (!strncmp(remote_name, ref, len) && ref[len] == ':') {
const char *local_part = ref + len + 1;
- char *ret;
int retlen;
if (!next)
retlen = strlen(local_part);
else
retlen = next - local_part;
- ret = xmalloc(retlen + 1);
- memcpy(ret, local_part, retlen);
- ret[retlen] = 0;
*force_p = single_force;
*not_for_merge_p = not_for_merge;
- return ret;
+ return xmemdupz(local_part, retlen);
}
ref = next;
}
index ae60fccea74077b4d2456919d2f911f8a257c5b4..8a3c962f8920bb883287053c850adf78312ff19b 100644 (file)
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
if (!strcmp(".", src) || !strcmp(src, origin)) {
int len = strlen(origin);
if (origin[0] == '\'' && origin[len - 1] == '\'') {
- char *new_origin = xmalloc(len - 1);
- memcpy(new_origin, origin + 1, len - 2);
- new_origin[len - 2] = 0;
- origin = new_origin;
- } else
+ origin = xmemdupz(origin + 1, len - 2);
+ } else {
origin = xstrdup(origin);
+ }
} else {
char *new_origin = xmalloc(strlen(origin) + strlen(src) + 5);
sprintf(new_origin, "%s of %s", origin, src);
bol += 2;
eol = strchr(bol, '\n');
-
if (eol) {
- int len = eol - bol;
- oneline = xmalloc(len + 1);
- memcpy(oneline, bol, len);
- oneline[len] = 0;
- } else
+ oneline = xmemdupz(bol, eol - bol);
+ } else {
oneline = xstrdup(bol);
+ }
append_to_list(&subjects, oneline, NULL);
}
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 0afa1c5c41e79a05ddebb7d874956163510daf0b..725c1df0fca375e9585ac09757f68204406598ec 100644 (file)
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
static int parse_atom(const char *atom, const char *ep)
{
const char *sp;
- char *n;
int i, at;
sp = atom;
(sizeof *used_atom) * used_atom_cnt);
used_atom_type = xrealloc(used_atom_type,
(sizeof(*used_atom_type) * used_atom_cnt));
- n = xmalloc(ep - atom + 1);
- memcpy(n, atom, ep - atom);
- n[ep-atom] = 0;
- used_atom[at] = n;
+ used_atom[at] = xmemdupz(atom, ep - atom);
used_atom_type[at] = valid_atom[i].cmp_type;
return at;
}
@@ -305,46 +301,28 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
static const char *copy_line(const char *buf)
{
const char *eol = strchr(buf, '\n');
- char *line;
- int len;
if (!eol)
return "";
- len = eol - buf;
- line = xmalloc(len + 1);
- memcpy(line, buf, len);
- line[len] = 0;
- return line;
+ return xmemdupz(buf, eol - buf);
}
static const char *copy_name(const char *buf)
{
- const char *eol = strchr(buf, '\n');
- const char *eoname = strstr(buf, " <");
- char *line;
- int len;
- if (!(eoname && eol && eoname < eol))
- return "";
- len = eoname - buf;
- line = xmalloc(len + 1);
- memcpy(line, buf, len);
- line[len] = 0;
- return line;
+ const char *cp;
+ for (cp = buf; *cp != '\n'; cp++) {
+ if (!strncmp(cp, " <", 2))
+ return xmemdupz(buf, cp - buf);
+ }
+ return "";
}
static const char *copy_email(const char *buf)
{
const char *email = strchr(buf, '<');
const char *eoemail = strchr(email, '>');
- char *line;
- int len;
if (!email || !eoemail)
return "";
- eoemail++;
- len = eoemail - email;
- line = xmalloc(len + 1);
- memcpy(line, email, len);
- line[len] = 0;
- return line;
+ return xmemdupz(email, eoemail + 1 - email);
}
static void grab_date(const char *buf, struct atom_value *v)
diff --git a/builtin-log.c b/builtin-log.c
index 60819d15c52dc8cb13ac08ba23986e4be56279a4..e8b982db7cf7c98bff9d64affcb573b3d9676cb1 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
{
char ch;
const char *a, *z, *m;
- char *n;
- size_t len;
m = msg_id;
while ((ch = *m) && (isspace(ch) || (ch == '<')))
die("insane in-reply-to: %s", msg_id);
if (++z == m)
return a;
- len = z - a;
- n = xmalloc(len + 1);
- memcpy(n, a, len);
- n[len] = 0;
- return n;
+ return xmemdupz(a, z - a);
}
int cmd_format_patch(int argc, const char **argv, const char *prefix)
endpos = strchr(committer, '>');
if (!endpos)
die("bogos committer info %s\n", committer);
- add_signoff = xmalloc(endpos - committer + 2);
- memcpy(add_signoff, committer, endpos - committer + 1);
- add_signoff[endpos - committer + 1] = 0;
+ add_signoff = xmemdupz(committer, endpos - committer + 1);
}
else if (!strcmp(argv[i], "--attach")) {
rev.mime_boundary = git_version_string;
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 6c1db86e8056285cb25359d55f5ebf9dd0e6f489..48dd3f77a4157c6f9f7e52e9e9884faa06568955 100644 (file)
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
static const char *verify_pathspec(const char *prefix)
{
const char **p, *n, *prev;
- char *real_prefix;
unsigned long max;
prev = NULL;
if (prefix_offset > max || memcmp(prev, prefix, prefix_offset))
die("git-ls-files: cannot generate relative filenames containing '..'");
- real_prefix = NULL;
prefix_len = max;
- if (max) {
- real_prefix = xmalloc(max + 1);
- memcpy(real_prefix, prev, max);
- real_prefix[max] = 0;
- }
- return real_prefix;
+ return max ? xmemdupz(prev, max) : NULL;
}
/*
diff --git a/builtin-mv.c b/builtin-mv.c
index b95b7d286ab5358a89a0309927b9f5e5e23fc4d0..b9446516915c998e41e645a7cc3e28c25ee21dc1 100644 (file)
--- a/builtin-mv.c
+++ b/builtin-mv.c
for (i = 0; i < count; i++) {
int length = strlen(result[i]);
if (length > 0 && result[i][length - 1] == '/') {
- char *without_slash = xmalloc(length);
- memcpy(without_slash, result[i], length - 1);
- without_slash[length - 1] = '\0';
- result[i] = without_slash;
+ result[i] = xmemdupz(result[i], length - 1);
}
if (base_name) {
const char *last_slash = strrchr(result[i], '/');
diff --git a/builtin-revert.c b/builtin-revert.c
index 499bbe7343a635f1c7fc024ed6a1436042dcb8ac..a655c8ee2ab25ef778b182fbd5ff298a732c1cfd 100644 (file)
--- a/builtin-revert.c
+++ b/builtin-revert.c
char *line, *pend, *email, *timestamp;
p += 7;
- line = xmalloc(eol + 1 - p);
- memcpy(line, p, eol - p);
- line[eol - p] = '\0';
+ line = xmemdupz(p, eol - p);
email = strchr(line, '<');
if (!email)
die ("Could not extract author email from %s",
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 16af6199ab2bc8a663d16f78a5d461a5bee05bc7..3fe754677d3f7ab11419a04dd828c70b5958ed87 100644 (file)
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
while (authorlen > 0 && isspace(author[authorlen - 1]))
authorlen--;
- buffer = xmalloc(authorlen + 1);
- memcpy(buffer, author, authorlen);
- buffer[authorlen] = '\0';
-
+ buffer = xmemdupz(author, authorlen);
item = path_list_insert(buffer, list);
if (item->util == NULL)
item->util = xcalloc(1, sizeof(struct path_list));
oneline++;
onelinelen--;
}
-
while (onelinelen > 0 && isspace(oneline[onelinelen - 1]))
onelinelen--;
-
- buffer = xmalloc(onelinelen + 1);
- memcpy(buffer, oneline, onelinelen);
- buffer[onelinelen] = '\0';
+ buffer = xmemdupz(oneline, onelinelen);
if (dot3) {
int dot3len = strlen(dot3);
diff --git a/commit.c b/commit.c
index 85889f966457bf11004daa40c2cbe664baf96fb4..f86fa776c05b27d0e353cc70ee2b49d29a8de2e7 100644 (file)
--- a/commit.c
+++ b/commit.c
if (eol - line > key_len &&
!strncmp(line, key, key_len) &&
line[key_len] == ' ') {
- int len = eol - line - key_len;
- char *ret = xmalloc(len);
- memcpy(ret, line + key_len + 1, len - 1);
- ret[len - 1] = '\0';
- return ret;
+ return xmemdupz(line + key_len + 1, eol - line - key_len - 1);
}
line = next;
}
start = end + 1;
while (end > 0 && isspace(msg[end - 1]))
end--;
- table[0].value = xstrndup(msg, end);
+ table[0].value = xmemdupz(msg, end);
if (start >= len)
return;
if (end >= len)
return;
- table[1].value = xstrndup(msg + start, end - start);
+ table[1].value = xmemdupz(msg + start, end - start);
/* parse date */
for (start = end + 1; start < len && isspace(msg[start]); start++)
if (msg + start == ep)
return;
- table[5].value = xstrndup(msg + start, ep - (msg + start));
+ table[5].value = xmemdupz(msg + start, ep - (msg + start));
/* parse tz */
for (start = ep - msg + 1; start < len && isspace(msg[start]); start++)
; /* do nothing */
if (state == SUBJECT) {
- table[ISUBJECT].value = xstrndup(msg + i, eol - i);
+ table[ISUBJECT].value = xmemdupz(msg + i, eol - i);
i = eol;
}
if (i == eol) {
msg + i + 10, eol - i - 10);
else if (!prefixcmp(msg + i, "encoding "))
table[IENCODING].value =
- xstrndup(msg + i + 9, eol - i - 9);
+ xmemdupz(msg + i + 9, eol - i - 9);
i = eol;
}
if (msg[i])
diff --git a/connect.c b/connect.c
index 8b1e9935a85b639f6c48298d07299f72bceaad29..1653a0ef7f7b4fa529a7755aae070c1716dd8e24 100644 (file)
--- a/connect.c
+++ b/connect.c
if (matchlen == 4 &&
!memcmp(value, "none", 4))
matchlen = 0;
- git_proxy_command = xmalloc(matchlen + 1);
- memcpy(git_proxy_command, value, matchlen);
- git_proxy_command[matchlen] = 0;
+ git_proxy_command = xmemdupz(value, matchlen);
}
return 0;
}
diff --git a/convert.c b/convert.c
index 508d30b2f162b5d4dd8ad119d456dc6b32d21d87..79c9df2e918efe16da825895708c4ac6f08bfc62 100644 (file)
--- a/convert.c
+++ b/convert.c
if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
break;
if (!drv) {
- char *namebuf;
drv = xcalloc(1, sizeof(struct convert_driver));
- namebuf = xmalloc(namelen + 1);
- memcpy(namebuf, name, namelen);
- namebuf[namelen] = 0;
- drv->name = namebuf;
- drv->next = NULL;
+ drv->name = xmemdupz(name, namelen);
*user_convert_tail = drv;
user_convert_tail = &(drv->next);
}
index a5b69ed2d236309bb9e960251515e69cec528935..2216d756d1f351cf51eb4bca07c0cd5e0497b619 100644 (file)
--- a/diff.c
+++ b/diff.c
if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
break;
if (!drv) {
- char *namebuf;
drv = xcalloc(1, sizeof(struct ll_diff_driver));
- namebuf = xmalloc(namelen + 1);
- memcpy(namebuf, name, namelen);
- namebuf[namelen] = 0;
- drv->name = namebuf;
- drv->next = NULL;
+ drv->name = xmemdupz(name, namelen);
if (!user_diff_tail)
user_diff_tail = &user_diff;
*user_diff_tail = drv;
@@ -126,12 +121,8 @@ static int parse_funcname_pattern(const char *var, const char *ep, const char *v
if (!strncmp(pp->name, name, namelen) && !pp->name[namelen])
break;
if (!pp) {
- char *namebuf;
pp = xcalloc(1, sizeof(*pp));
- namebuf = xmalloc(namelen + 1);
- memcpy(namebuf, name, namelen);
- namebuf[namelen] = 0;
- pp->name = namebuf;
+ pp->name = xmemdupz(name, namelen);
pp->next = funcname_pattern_list;
funcname_pattern_list = pp;
}
diff --git a/diffcore-order.c b/diffcore-order.c
index 2a4bd8232eb185f195c513c3509a72a92d172818..23e93852d8c701760d56e7e728dba7c08367fbe8 100644 (file)
--- a/diffcore-order.c
+++ b/diffcore-order.c
if (*ep == '\n') {
*ep = 0;
order[cnt] = cp;
- }
- else {
- order[cnt] = xmalloc(ep-cp+1);
- memcpy(order[cnt], cp, ep-cp);
- order[cnt][ep-cp] = 0;
+ } else {
+ order[cnt] = xmemdupz(cp, ep - cp);
}
cnt++;
}
diff --git a/fast-import.c b/fast-import.c
index e2a4834706659c050cdfd0d53ad3340c9522fa47..f9906586ee252519e65f6d9c4e6a2cff417262bc 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
endp = strchr(s, ' ');
if (!endp)
die("Missing space after source: %s", command_buf.buf);
- s_uq = xmalloc(endp - s + 1);
- memcpy(s_uq, s, endp - s);
- s_uq[endp - s] = 0;
+ s_uq = xmemdupz(s, endp - s);
}
s = s_uq;
diff --git a/http-push.c b/http-push.c
index 7c3720f602bb8f50ed54a4f7e7a85c7e08d1c07b..276e1eb1d913f5e8f274545495e39ed7530d5244 100644 (file)
--- a/http-push.c
+++ b/http-push.c
{
struct xml_ctx *ctx = (struct xml_ctx *)userData;
free(ctx->cdata);
- ctx->cdata = xmalloc(len + 1);
- /* NB: 's' is not null-terminated, can not use strlcpy here */
- memcpy(ctx->cdata, s, len);
- ctx->cdata[len] = '\0';
+ ctx->cdata = xmemdupz(s, len);
}
static struct remote_lock *lock_remote(const char *path, long timeout)
@@ -2172,9 +2169,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
/* If it's a symref, set the refname; otherwise try for a sha1 */
if (!prefixcmp((char *)buffer.buffer, "ref: ")) {
- *symref = xmalloc(buffer.posn - 5);
- memcpy(*symref, (char *)buffer.buffer + 5, buffer.posn - 6);
- (*symref)[buffer.posn - 6] = '\0';
+ *symref = xmemdupz((char *)buffer.buffer + 5, buffer.posn - 6);
} else {
get_sha1_hex(buffer.buffer, sha1);
}
diff --git a/imap-send.c b/imap-send.c
index 86e4a0f6a06e7c66b67de6639a93b20223bbda19..905d09746aa36f18d873605518fbeaca25d17f73 100644 (file)
--- a/imap-send.c
+++ b/imap-send.c
goto bail;
cur->len = s - p;
s++;
- cur->val = xmalloc( cur->len + 1 );
- memcpy( cur->val, p, cur->len );
- cur->val[cur->len] = 0;
+ cur->val = xmemdupz(p, cur->len);
} else {
/* atom */
p = s;
if (level && *s == ')')
break;
cur->len = s - p;
- if (cur->len == 3 && !memcmp ("NIL", p, 3))
+ if (cur->len == 3 && !memcmp ("NIL", p, 3)) {
cur->val = NIL;
- else {
- cur->val = xmalloc( cur->len + 1 );
- memcpy( cur->val, p, cur->len );
- cur->val[cur->len] = 0;
+ } else {
+ cur->val = xmemdupz(p, cur->len);
}
}
if (p)
msg->len = &p[1] - data;
- msg->data = xmalloc( msg->len + 1 );
- if (!msg->data)
- return 0;
-
- memcpy( msg->data, data, msg->len );
- msg->data[ msg->len ] = 0;
-
+ msg->data = xmemdupz(data, msg->len);
*ofs += msg->len;
return 1;
}
diff --git a/merge-recursive.c b/merge-recursive.c
index 19d5f3b2872ec7039508c9b12a89f3013d58c68d..14b56c2f20651711727169b6d1f28df66bfe775d 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
static int remove_path(const char *name)
{
- int ret, len;
+ int ret;
char *slash, *dirs;
ret = unlink(name);
if (ret)
return ret;
- len = strlen(name);
- dirs = xmalloc(len+1);
- memcpy(dirs, name, len);
- dirs[len] = '\0';
+ dirs = xstrdup(name);
while ((slash = strrchr(name, '/'))) {
*slash = '\0';
- len = slash - name;
if (rmdir(name) != 0)
break;
}
flush_buffer(fd, buf, size);
close(fd);
} else if (S_ISLNK(mode)) {
- char *lnk = xmalloc(size + 1);
- memcpy(lnk, buf, size);
- lnk[size] = '\0';
+ char *lnk = xmemdupz(buf, size);
mkdir_p(path, 0777);
unlink(path);
symlink(lnk, path);
if (!strncmp(fn->name, name, namelen) && !fn->name[namelen])
break;
if (!fn) {
- char *namebuf;
fn = xcalloc(1, sizeof(struct ll_merge_driver));
- namebuf = xmalloc(namelen + 1);
- memcpy(namebuf, name, namelen);
- namebuf[namelen] = 0;
- fn->name = namebuf;
+ fn->name = xmemdupz(name, namelen);
fn->fn = ll_ext_merge;
- fn->next = NULL;
*ll_user_merge_tail = fn;
ll_user_merge_tail = &(fn->next);
}
index 7fb3350789a407e36dc74418b79508e9bf916594..07e260c8a15c9118ee829964aed65b209900dc36 100644 (file)
--- a/refs.c
+++ b/refs.c
static char *ref_msg(const char *line, const char *endp)
{
const char *ep;
- char *msg;
-
line += 82;
- for (ep = line; ep < endp && *ep != '\n'; ep++)
- ;
- msg = xmalloc(ep - line + 1);
- memcpy(msg, line, ep - line);
- msg[ep - line] = 0;
- return msg;
+ ep = memchr(line, '\n', endp - line);
+ if (!ep)
+ ep = endp;
+ return xmemdupz(line, ep - line);
}
int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
diff --git a/sha1_file.c b/sha1_file.c
index 59325d46bec1ec604e65f9e5414cd75bba929c63..385c5d891af9b7c79dd93e0e6777b0975ff5dbef 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
ent->lru.next->prev = ent->lru.prev;
ent->lru.prev->next = ent->lru.next;
delta_base_cached -= ent->size;
- }
- else {
- ret = xmalloc(ent->size + 1);
- memcpy(ret, ent->data, ent->size);
- ((char *)ret)[ent->size] = 0;
+ } else {
+ ret = xmemdupz(ent->data, ent->size);
}
*type = ent->type;
*base_size = ent->size;
co = find_cached_object(sha1);
if (co) {
- buf = xmalloc(co->size + 1);
- memcpy(buf, co->buf, co->size);
- ((char*)buf)[co->size] = 0;
*type = co->type;
*size = co->size;
- return buf;
+ return xmemdupz(co->buf, co->size);
}
buf = read_packed_sha1(sha1, type, size);
index bbacd59a23f7994980f4bf017324833ca3d4adb3..f62bcdd994509323080683ce19c1a4d8241f9dec 100644 (file)
--- a/tag.c
+++ b/tag.c
memcpy(type, type_line + 5, typelen);
type[typelen] = '\0';
taglen = sig_line - tag_line - strlen("tag \n");
- item->tag = xmalloc(taglen + 1);
- memcpy(item->tag, tag_line + 4, taglen);
- item->tag[taglen] = '\0';
+ item->tag = xmemdupz(tag_line + 4, taglen);
if (!strcmp(type, blob_type)) {
item->tagged = &lookup_blob(sha1)->object;