From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Pieter de Bie <pdebie@ai.rug.nl>
Cc: Git Mailinglist <git@vger.kernel.org>
Subject: Re: [PATCH] builtin-fast-export: Add importing and exporting of revision marks
Date: Thu, 5 Jun 2008 01:00:32 +0100 (BST) [thread overview]
Message-ID: <alpine.DEB.1.00.0806050052390.21190@racer> (raw)
In-Reply-To: <1212612947-34720-1-git-send-email-pdebie@ai.rug.nl>
Hi,
On Wed, 4 Jun 2008, Pieter de Bie wrote:
> +static void export_marks(char * file)
Extra space after star.
> +{
> + unsigned int i;
> + uintmax_t mark;
> + struct object_decoration *deco = idnums.hash;
> + FILE *f;
> +
> + f = fopen(file, "w");
> + if (!f)
> + error("Unable to open marks file %s for writing", file);
> +
> + for (i = 0; i < idnums.size; ++i) {
> + deco++;
> + if (deco && deco->base && deco->base->type == 1) {
> + mark = (uint32_t *) deco-> decoration - (uint32_t *)NULL;
Why do you use uint32_t here, when you use uintmax_t to declare "mark"?
Also, there is an extra space after the closing paren.
Is "- (uint32_t *)NULL" needed?
> + fprintf(f, ":%" PRIuMAX " %s\n", mark, sha1_to_hex(deco->base->sha1));
Too long line.
If you already only use uint32_t, I think you do not need the (ugly)
PRIuMAX.
> +static void import_marks(char * input_file)
> +{
> + char line[512];
> + FILE *f = fopen(input_file, "r");
> + if (!f)
> + die("cannot read %s: %s", input_file, strerror(errno));
> +
> + while (fgets(line, sizeof(line), f)) {
> + uintmax_t mark;
> + char *end;
> + unsigned char sha1[20];
> + struct object *object;
> +
> + end = strchr(line, '\n');
> + if (line[0] != ':' || !end)
> + die("corrupt mark line: %s", line);
> + *end = 0;
> + mark = strtoumax(line + 1, &end, 10);
> + if (!mark || end == line + 1
> + || *end != ' ' || get_sha1(end + 1, sha1))
> + die("corrupt mark line: %s", line);
You do a bit too much with "end" for my liking. Better use two variables,
and spare the reader a (brief) "Huh?" moment.
> + object = parse_object(sha1);
> + if (!object)
> + die ("Could not read blob %s", sha1_to_hex(sha1));
> +
> + if (object->flags & SHOWN)
> + error("Object %s was already has a mark", sha1);
s/was //
> + add_decoration(&idnums, object, ((uint32_t *)NULL) + mark);
Better write (void *)mark.
> + char *export_filename, *import_filename;
> struct option options[] = {
> OPT_INTEGER(0, "progress", &progress,
> "show progress after <n> objects"),
> OPT_CALLBACK(0, "signed-tags", &signed_tag_mode, "mode",
> "select handling of signed tags",
> parse_opt_signed_tag_mode),
> + OPT_STRING(0, "export-marks", &export_filename, "FILE", "Dump marks to this file"),
> + OPT_STRING(0, "import-marks", &import_filename, "FILE", "Import marks from this file"),
Two long lines.
> OPT_END()
> };
>
> /* we handle encodings */
> git_config(git_default_config, NULL);
>
> +
> init_revisions(&revs, prefix);
Unnecessary change.
Other than that: ACK.
Thanks,
Dscho
next prev parent reply other threads:[~2008-06-05 0:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-04 20:55 [PATCH] builtin-fast-export: Add importing and exporting of revision marks Pieter de Bie
2008-06-05 0:00 ` Johannes Schindelin [this message]
2008-06-05 10:46 ` Pieter de Bie
2008-06-05 10:52 ` [PATCH v2] " Pieter de Bie
2008-06-05 13:35 ` Johannes Schindelin
2008-06-06 23:09 ` Junio C Hamano
2008-06-07 13:06 ` Pieter de Bie
2008-06-07 15:19 ` Johannes Schindelin
2008-06-07 16:37 ` Junio C Hamano
2008-06-11 19:45 ` Johannes Schindelin
2008-06-07 13:25 ` [PATCH] Documentation/fast-export: Document --import-marks and --export-marks options Pieter de Bie
2008-06-07 15:20 ` Johannes Schindelin
2008-06-10 6:47 ` Junio C Hamano
2008-06-11 11:17 ` [PATCH v3] builtin-fast-export: Add importing and exporting of revision marks Pieter de Bie
2008-06-11 11:24 ` Pieter de Bie
2008-06-11 18:45 ` Johannes Schindelin
2008-06-11 21:43 ` Junio C Hamano
2008-06-05 13:31 ` [PATCH] " Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.1.00.0806050052390.21190@racer \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=pdebie@ai.rug.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox