blob: 129ff57f11d2cdfdacc6be9685736ada07caef7f [file] [log] [blame]
Carlos Rica62e09ce2007-07-20 01:42:28 +02001/*
2 * Builtin "git tag"
3 *
4 * Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>,
5 * Carlos Rica <jasampler@gmail.com>
6 * Based on git-tag.sh and mktag.c by Linus Torvalds.
7 */
8
9#include "cache.h"
10#include "builtin.h"
11#include "refs.h"
12#include "tag.h"
13#include "run-command.h"
Carlos Rica39686582007-11-09 14:42:56 +010014#include "parse-options.h"
Carlos Rica62e09ce2007-07-20 01:42:28 +020015
Carlos Rica39686582007-11-09 14:42:56 +010016static const char * const git_tag_usage[] = {
17 "git-tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
18 "git-tag -d <tagname>...",
Carlos Rica3f36cbb2008-04-09 13:07:14 +020019 "git-tag -l [-n[<num>]] [<pattern>]",
Carlos Rica39686582007-11-09 14:42:56 +010020 "git-tag -v <tagname>...",
21 NULL
22};
Carlos Rica62e09ce2007-07-20 01:42:28 +020023
24static char signingkey[1000];
25
Pierre Habouzit8babab92007-11-26 09:59:27 +010026void launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
Carlos Rica62e09ce2007-07-20 01:42:28 +020027{
28 const char *editor, *terminal;
Carlos Rica62e09ce2007-07-20 01:42:28 +020029
Johannes Schindelin4d87b9c2007-07-20 13:06:09 +010030 editor = getenv("GIT_EDITOR");
31 if (!editor && editor_program)
32 editor = editor_program;
33 if (!editor)
34 editor = getenv("VISUAL");
Carlos Rica62e09ce2007-07-20 01:42:28 +020035 if (!editor)
36 editor = getenv("EDITOR");
37
38 terminal = getenv("TERM");
39 if (!editor && (!terminal || !strcmp(terminal, "dumb"))) {
40 fprintf(stderr,
41 "Terminal is dumb but no VISUAL nor EDITOR defined.\n"
42 "Please supply the message using either -m or -F option.\n");
43 exit(1);
44 }
45
46 if (!editor)
47 editor = "vi";
48
Johannes Schindeline97c9ad2007-11-08 14:06:52 +000049 if (strcmp(editor, ":")) {
Junio C Hamano5e2de4f2007-12-22 09:45:10 -080050 size_t len = strlen(editor);
51 int i = 0;
52 const char *args[6];
Johannes Schindelinfc994692008-03-11 10:56:30 +010053 struct strbuf arg0;
Junio C Hamano5e2de4f2007-12-22 09:45:10 -080054
Johannes Schindelinfc994692008-03-11 10:56:30 +010055 strbuf_init(&arg0, 0);
Junio C Hamano5e2de4f2007-12-22 09:45:10 -080056 if (strcspn(editor, "$ \t'") != len) {
57 /* there are specials */
Johannes Schindelinfc994692008-03-11 10:56:30 +010058 strbuf_addf(&arg0, "%s \"$@\"", editor);
Junio C Hamano5e2de4f2007-12-22 09:45:10 -080059 args[i++] = "sh";
60 args[i++] = "-c";
Johannes Schindelinfc994692008-03-11 10:56:30 +010061 args[i++] = arg0.buf;
Junio C Hamano5e2de4f2007-12-22 09:45:10 -080062 }
63 args[i++] = editor;
64 args[i++] = path;
65 args[i] = NULL;
Carlos Rica62e09ce2007-07-20 01:42:28 +020066
Pierre Habouzit8babab92007-11-26 09:59:27 +010067 if (run_command_v_opt_cd_env(args, 0, NULL, env))
Johannes Schindeline97c9ad2007-11-08 14:06:52 +000068 die("There was a problem with the editor %s.", editor);
Johannes Schindelinfc994692008-03-11 10:56:30 +010069 strbuf_release(&arg0);
Johannes Schindeline97c9ad2007-11-08 14:06:52 +000070 }
Carlos Rica62e09ce2007-07-20 01:42:28 +020071
Junio C Hamano740001a2007-12-08 23:23:20 -080072 if (!buffer)
73 return;
Pierre Habouzit387e7e12007-09-27 15:25:55 +020074 if (strbuf_read_file(buffer, path, 0) < 0)
Kristian Høgsberga9390b92007-09-17 20:06:46 -040075 die("could not read message file '%s': %s",
76 path, strerror(errno));
Carlos Rica62e09ce2007-07-20 01:42:28 +020077}
78
79struct tag_filter {
80 const char *pattern;
81 int lines;
82};
83
84#define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
85
86static int show_reference(const char *refname, const unsigned char *sha1,
87 int flag, void *cb_data)
88{
89 struct tag_filter *filter = cb_data;
90
91 if (!fnmatch(filter->pattern, refname, 0)) {
92 int i;
93 unsigned long size;
94 enum object_type type;
95 char *buf, *sp, *eol;
96 size_t len;
97
98 if (!filter->lines) {
99 printf("%s\n", refname);
100 return 0;
101 }
102 printf("%-15s ", refname);
103
Mike Hommeye1f14cc2007-11-03 14:08:05 +0100104 buf = read_sha1_file(sha1, &type, &size);
105 if (!buf || !size)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200106 return 0;
Mike Hommeye1f14cc2007-11-03 14:08:05 +0100107
108 /* skip header */
109 sp = strstr(buf, "\n\n");
110 if (!sp) {
Carlos Ricae317cfa2007-07-21 14:13:12 +0200111 free(buf);
112 return 0;
113 }
Carlos Rica62e09ce2007-07-20 01:42:28 +0200114 /* only take up to "lines" lines, and strip the signature */
Carlos Ricae317cfa2007-07-21 14:13:12 +0200115 for (i = 0, sp += 2;
116 i < filter->lines && sp < buf + size &&
Carlos Rica62e09ce2007-07-20 01:42:28 +0200117 prefixcmp(sp, PGP_SIGNATURE "\n");
118 i++) {
119 if (i)
120 printf("\n ");
121 eol = memchr(sp, '\n', size - (sp - buf));
122 len = eol ? eol - sp : size - (sp - buf);
123 fwrite(sp, len, 1, stdout);
124 if (!eol)
125 break;
126 sp = eol + 1;
127 }
128 putchar('\n');
129 free(buf);
130 }
131
132 return 0;
133}
134
135static int list_tags(const char *pattern, int lines)
136{
137 struct tag_filter filter;
Carlos Rica62e09ce2007-07-20 01:42:28 +0200138
139 if (pattern == NULL)
Carlos Rica18e32b52007-09-01 07:10:09 +0200140 pattern = "*";
Carlos Rica62e09ce2007-07-20 01:42:28 +0200141
Carlos Rica18e32b52007-09-01 07:10:09 +0200142 filter.pattern = pattern;
Carlos Rica62e09ce2007-07-20 01:42:28 +0200143 filter.lines = lines;
144
145 for_each_tag_ref(show_reference, (void *) &filter);
146
Carlos Rica62e09ce2007-07-20 01:42:28 +0200147 return 0;
148}
149
Carlos Ricae317cfa2007-07-21 14:13:12 +0200150typedef int (*each_tag_name_fn)(const char *name, const char *ref,
Carlos Rica62e09ce2007-07-20 01:42:28 +0200151 const unsigned char *sha1);
152
Carlos Ricae317cfa2007-07-21 14:13:12 +0200153static int for_each_tag_name(const char **argv, each_tag_name_fn fn)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200154{
155 const char **p;
156 char ref[PATH_MAX];
157 int had_error = 0;
158 unsigned char sha1[20];
159
160 for (p = argv; *p; p++) {
161 if (snprintf(ref, sizeof(ref), "refs/tags/%s", *p)
162 >= sizeof(ref)) {
163 error("tag name too long: %.*s...", 50, *p);
164 had_error = 1;
165 continue;
166 }
167 if (!resolve_ref(ref, sha1, 1, NULL)) {
168 error("tag '%s' not found.", *p);
169 had_error = 1;
170 continue;
171 }
172 if (fn(*p, ref, sha1))
173 had_error = 1;
174 }
175 return had_error;
176}
177
178static int delete_tag(const char *name, const char *ref,
179 const unsigned char *sha1)
180{
181 if (delete_ref(ref, sha1))
182 return 1;
183 printf("Deleted tag '%s'\n", name);
184 return 0;
185}
186
187static int verify_tag(const char *name, const char *ref,
188 const unsigned char *sha1)
189{
190 const char *argv_verify_tag[] = {"git-verify-tag",
191 "-v", "SHA1_HEX", NULL};
192 argv_verify_tag[2] = sha1_to_hex(sha1);
193
194 if (run_command_v_opt(argv_verify_tag, 0))
195 return error("could not verify the tag '%s'", name);
196 return 0;
197}
198
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200199static int do_sign(struct strbuf *buffer)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200200{
201 struct child_process gpg;
202 const char *args[4];
203 char *bracket;
204 int len;
205
206 if (!*signingkey) {
Junio C Hamano774751a2007-12-08 17:32:08 -0800207 if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
Carlos Ricae317cfa2007-07-21 14:13:12 +0200208 sizeof(signingkey)) > sizeof(signingkey) - 1)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200209 return error("committer info too long.");
210 bracket = strchr(signingkey, '>');
211 if (bracket)
212 bracket[1] = '\0';
213 }
214
Carlos Ricaaba91192007-09-09 02:39:29 +0200215 /* When the username signingkey is bad, program could be terminated
216 * because gpg exits without reading and then write gets SIGPIPE. */
217 signal(SIGPIPE, SIG_IGN);
218
Carlos Rica62e09ce2007-07-20 01:42:28 +0200219 memset(&gpg, 0, sizeof(gpg));
220 gpg.argv = args;
221 gpg.in = -1;
222 gpg.out = -1;
223 args[0] = "gpg";
224 args[1] = "-bsau";
225 args[2] = signingkey;
226 args[3] = NULL;
227
228 if (start_command(&gpg))
229 return error("could not run gpg.");
230
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200231 if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) {
Carlos Ricaaba91192007-09-09 02:39:29 +0200232 close(gpg.in);
Johannes Sixte72ae282008-02-16 18:36:38 +0100233 close(gpg.out);
Carlos Ricaaba91192007-09-09 02:39:29 +0200234 finish_command(&gpg);
235 return error("gpg did not accept the tag data");
236 }
Carlos Rica62e09ce2007-07-20 01:42:28 +0200237 close(gpg.in);
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200238 len = strbuf_read(buffer, gpg.out, 1024);
Johannes Sixte72ae282008-02-16 18:36:38 +0100239 close(gpg.out);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200240
Carlos Ricaaba91192007-09-09 02:39:29 +0200241 if (finish_command(&gpg) || !len || len < 0)
242 return error("gpg failed to sign the tag");
Carlos Rica62e09ce2007-07-20 01:42:28 +0200243
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200244 return 0;
Carlos Rica62e09ce2007-07-20 01:42:28 +0200245}
246
247static const char tag_template[] =
248 "\n"
249 "#\n"
250 "# Write a tag message\n"
251 "#\n";
252
Linus Torvaldsbe15f502007-12-10 20:08:06 -0800253static void set_signingkey(const char *value)
254{
255 if (strlcpy(signingkey, value, sizeof(signingkey)) >= sizeof(signingkey))
256 die("signing key value too long (%.10s...)", value);
257}
258
Carlos Rica62e09ce2007-07-20 01:42:28 +0200259static int git_tag_config(const char *var, const char *value)
260{
261 if (!strcmp(var, "user.signingkey")) {
262 if (!value)
Junio C Hamano406d95f2008-02-11 10:51:31 -0800263 return config_error_nonbool(value);
Linus Torvaldsbe15f502007-12-10 20:08:06 -0800264 set_signingkey(value);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200265 return 0;
266 }
267
268 return git_default_config(var, value);
269}
270
Mike Hommeybab81182007-11-04 01:11:14 +0100271static void write_tag_body(int fd, const unsigned char *sha1)
272{
273 unsigned long size;
274 enum object_type type;
275 char *buf, *sp, *eob;
276 size_t len;
277
278 buf = read_sha1_file(sha1, &type, &size);
279 if (!buf)
280 return;
281 /* skip header */
282 sp = strstr(buf, "\n\n");
283
284 if (!sp || !size || type != OBJ_TAG) {
285 free(buf);
286 return;
287 }
288 sp += 2; /* skip the 2 LFs */
289 eob = strstr(sp, "\n" PGP_SIGNATURE "\n");
290 if (eob)
291 len = eob - sp;
292 else
293 len = buf + size - sp;
294 write_or_die(fd, sp, len);
295
296 free(buf);
297}
298
Carlos Rica62e09ce2007-07-20 01:42:28 +0200299static void create_tag(const unsigned char *object, const char *tag,
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200300 struct strbuf *buf, int message, int sign,
Junio C Hamanobd46c9a2007-11-22 23:16:51 -0800301 unsigned char *prev, unsigned char *result)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200302{
303 enum object_type type;
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200304 char header_buf[1024];
305 int header_len;
Carlos Rica62e09ce2007-07-20 01:42:28 +0200306
307 type = sha1_object_info(object, NULL);
Carlos Ricae317cfa2007-07-21 14:13:12 +0200308 if (type <= OBJ_NONE)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200309 die("bad object type.");
310
311 header_len = snprintf(header_buf, sizeof(header_buf),
312 "object %s\n"
313 "type %s\n"
314 "tag %s\n"
315 "tagger %s\n\n",
316 sha1_to_hex(object),
317 typename(type),
318 tag,
Junio C Hamano774751a2007-12-08 17:32:08 -0800319 git_committer_info(IDENT_ERROR_ON_NO_NAME));
Carlos Rica62e09ce2007-07-20 01:42:28 +0200320
Carlos Ricae317cfa2007-07-21 14:13:12 +0200321 if (header_len > sizeof(header_buf) - 1)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200322 die("tag header too big.");
323
324 if (!message) {
325 char *path;
326 int fd;
327
328 /* write the template message before editing: */
329 path = xstrdup(git_path("TAG_EDITMSG"));
330 fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
331 if (fd < 0)
332 die("could not create file '%s': %s",
333 path, strerror(errno));
Mike Hommeybab81182007-11-04 01:11:14 +0100334
335 if (!is_null_sha1(prev))
336 write_tag_body(fd, prev);
337 else
338 write_or_die(fd, tag_template, strlen(tag_template));
Carlos Rica62e09ce2007-07-20 01:42:28 +0200339 close(fd);
340
Pierre Habouzit8babab92007-11-26 09:59:27 +0100341 launch_editor(path, buf, NULL);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200342
343 unlink(path);
344 free(path);
345 }
Carlos Rica62e09ce2007-07-20 01:42:28 +0200346
Kristian Høgsberg6d69b6f2007-09-17 20:06:45 -0400347 stripspace(buf, 1);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200348
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200349 if (!message && !buf->len)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200350 die("no tag message?");
351
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200352 strbuf_insert(buf, 0, header_buf, header_len);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200353
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200354 if (sign && do_sign(buf) < 0)
355 die("unable to sign the tag");
356 if (write_sha1_file(buf->buf, buf->len, tag_type, result) < 0)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200357 die("unable to write tag file");
Carlos Rica62e09ce2007-07-20 01:42:28 +0200358}
359
Junio C Hamanobd46c9a2007-11-22 23:16:51 -0800360struct msg_arg {
361 int given;
362 struct strbuf buf;
363};
364
365static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
366{
367 struct msg_arg *msg = opt->value;
368
369 if (!arg)
370 return -1;
371 if (msg->buf.len)
372 strbuf_addstr(&(msg->buf), "\n\n");
373 strbuf_addstr(&(msg->buf), arg);
374 msg->given = 1;
375 return 0;
376}
377
Carlos Rica62e09ce2007-07-20 01:42:28 +0200378int cmd_tag(int argc, const char **argv, const char *prefix)
379{
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200380 struct strbuf buf;
Carlos Rica62e09ce2007-07-20 01:42:28 +0200381 unsigned char object[20], prev[20];
Carlos Rica62e09ce2007-07-20 01:42:28 +0200382 char ref[PATH_MAX];
383 const char *object_ref, *tag;
Carlos Rica62e09ce2007-07-20 01:42:28 +0200384 struct ref_lock *lock;
385
Carlos Rica39686582007-11-09 14:42:56 +0100386 int annotate = 0, sign = 0, force = 0, lines = 0,
Pierre Habouzit78d776a2007-12-21 11:50:58 +0100387 list = 0, delete = 0, verify = 0;
388 char *msgfile = NULL, *keyid = NULL;
Junio C Hamanobd46c9a2007-11-22 23:16:51 -0800389 struct msg_arg msg = { 0, STRBUF_INIT };
Carlos Rica39686582007-11-09 14:42:56 +0100390 struct option options[] = {
Pierre Habouzit78d776a2007-12-21 11:50:58 +0100391 OPT_BOOLEAN('l', NULL, &list, "list tag names"),
Carlos Rica39686582007-11-09 14:42:56 +0100392 { OPTION_INTEGER, 'n', NULL, &lines, NULL,
393 "print n lines of each tag message",
394 PARSE_OPT_OPTARG, NULL, 1 },
395 OPT_BOOLEAN('d', NULL, &delete, "delete tags"),
396 OPT_BOOLEAN('v', NULL, &verify, "verify tags"),
397
398 OPT_GROUP("Tag creation options"),
399 OPT_BOOLEAN('a', NULL, &annotate,
400 "annotated tag, needs a message"),
Junio C Hamanobd46c9a2007-11-22 23:16:51 -0800401 OPT_CALLBACK('m', NULL, &msg, "msg",
402 "message for the tag", parse_msg_arg),
Carlos Rica39686582007-11-09 14:42:56 +0100403 OPT_STRING('F', NULL, &msgfile, "file", "message in a file"),
404 OPT_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"),
405 OPT_STRING('u', NULL, &keyid, "key-id",
406 "use another key to sign the tag"),
407 OPT_BOOLEAN('f', NULL, &force, "replace the tag if exists"),
408 OPT_END()
409 };
410
Carlos Rica62e09ce2007-07-20 01:42:28 +0200411 git_config(git_tag_config);
Carlos Rica39686582007-11-09 14:42:56 +0100412
413 argc = parse_options(argc, argv, options, git_tag_usage, 0);
414
Linus Torvaldsbe15f502007-12-10 20:08:06 -0800415 if (keyid) {
416 sign = 1;
417 set_signingkey(keyid);
418 }
Junio C Hamanoc1a41b92007-11-25 15:21:42 -0800419 if (sign)
420 annotate = 1;
421
Carlos Rica39686582007-11-09 14:42:56 +0100422 if (list)
Pierre Habouzit78d776a2007-12-21 11:50:58 +0100423 return list_tags(argv[0], lines);
Carlos Rica39686582007-11-09 14:42:56 +0100424 if (delete)
425 return for_each_tag_name(argv, delete_tag);
426 if (verify)
427 return for_each_tag_name(argv, verify_tag);
428
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200429 strbuf_init(&buf, 0);
Junio C Hamanobd46c9a2007-11-22 23:16:51 -0800430 if (msg.given || msgfile) {
431 if (msg.given && msgfile)
Carlos Rica39686582007-11-09 14:42:56 +0100432 die("only one -F or -m option is allowed.");
433 annotate = 1;
Junio C Hamanobd46c9a2007-11-22 23:16:51 -0800434 if (msg.given)
435 strbuf_addbuf(&buf, &(msg.buf));
Carlos Rica39686582007-11-09 14:42:56 +0100436 else {
437 if (!strcmp(msgfile, "-")) {
Pierre Habouzit387e7e12007-09-27 15:25:55 +0200438 if (strbuf_read(&buf, 0, 1024) < 0)
Carlos Rica39686582007-11-09 14:42:56 +0100439 die("cannot read %s", msgfile);
Pierre Habouzit387e7e12007-09-27 15:25:55 +0200440 } else {
Carlos Rica39686582007-11-09 14:42:56 +0100441 if (strbuf_read_file(&buf, msgfile, 1024) < 0)
Pierre Habouzit387e7e12007-09-27 15:25:55 +0200442 die("could not open or read '%s': %s",
Carlos Rica39686582007-11-09 14:42:56 +0100443 msgfile, strerror(errno));
Carlos Rica62e09ce2007-07-20 01:42:28 +0200444 }
Carlos Rica62e09ce2007-07-20 01:42:28 +0200445 }
Carlos Rica62e09ce2007-07-20 01:42:28 +0200446 }
447
Carlos Rica39686582007-11-09 14:42:56 +0100448 if (argc == 0) {
Carlos Rica62e09ce2007-07-20 01:42:28 +0200449 if (annotate)
Carlos Rica39686582007-11-09 14:42:56 +0100450 usage_with_options(git_tag_usage, options);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200451 return list_tags(NULL, lines);
452 }
Carlos Rica39686582007-11-09 14:42:56 +0100453 tag = argv[0];
Carlos Rica62e09ce2007-07-20 01:42:28 +0200454
Carlos Rica39686582007-11-09 14:42:56 +0100455 object_ref = argc == 2 ? argv[1] : "HEAD";
456 if (argc > 2)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200457 die("too many params");
458
459 if (get_sha1(object_ref, object))
460 die("Failed to resolve '%s' as a valid ref.", object_ref);
461
Carlos Ricae317cfa2007-07-21 14:13:12 +0200462 if (snprintf(ref, sizeof(ref), "refs/tags/%s", tag) > sizeof(ref) - 1)
Carlos Rica62e09ce2007-07-20 01:42:28 +0200463 die("tag name too long: %.*s...", 50, tag);
464 if (check_ref_format(ref))
465 die("'%s' is not a valid tag name.", tag);
466
467 if (!resolve_ref(ref, prev, 1, NULL))
468 hashclr(prev);
469 else if (!force)
470 die("tag '%s' already exists", tag);
471
472 if (annotate)
Junio C Hamanobd46c9a2007-11-22 23:16:51 -0800473 create_tag(object, tag, &buf, msg.given || msgfile,
474 sign, prev, object);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200475
476 lock = lock_any_ref_for_update(ref, prev, 0);
477 if (!lock)
478 die("%s: cannot lock the ref", ref);
479 if (write_ref_sha1(lock, object, NULL) < 0)
480 die("%s: cannot update the ref", ref);
481
Pierre Habouzitfd17f5b2007-09-10 12:35:09 +0200482 strbuf_release(&buf);
Carlos Rica62e09ce2007-07-20 01:42:28 +0200483 return 0;
484}