From: Pieter de Bie <pdebie@ai.rug.nl>
To: git@vger.kernel.org
Cc: Pieter de Bie <pdebie@ai.rug.nl>
Subject: [PATCH] builtin-fast-export: Remove double spaces in author line
Date: Fri, 30 May 2008 12:31:15 +0200 [thread overview]
Message-ID: <1212143475-48255-1-git-send-email-pdebie@ai.rug.nl> (raw)
At least the Samba repository has an extra space after the author's email
for some commits. This breaks builtin-fast-export as that format is required
to have only a single space.
This removes double spaces in committer and author lines.
---
This is an ugly hack and obviously not meant for application (which is why
I didn't sign it off).
The Samba thing can be seen by running:
git cat-file commit 65968b294351d2612d1bf94236d1fcbf853c494e
It produces
"author Samba Release Account <samba-bugs@samba.org> 831196245 +0000"
The git-fast-import syntax says there can only be a single space after the >
sign. This Samba commit breaks bzr-fast-import, for example.
I'm not sure how to properly fix the problem, as I'm not very deep into Git's
code. I included this patch in case anyone else has the same problem and wants
a quick fix. I'm also not sure if it's a fast-export problem, or if the Samba
repository is just invalid :)
- Pieter
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 1dfc01e..8218199 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -144,6 +144,24 @@ static const char *find_encoding(const char *begin, const char *end)
return bol;
}
+static void parse_line(char **begin, char **end)
+{
+ char *b = *begin;
+ char *e = *end;
+
+ char *line = xmalloc((e - b) * sizeof(char));
+ *begin = line;
+ char prev = 0;
+
+ for (; b < e; b++) {
+ if (!(prev == ' ' && *b == ' '))
+ *line++ = *b;
+ prev = *b;
+ }
+
+ *end = line;
+}
+
static void handle_commit(struct commit *commit, struct rev_info *rev)
{
int saved_output_format = rev->diffopt.output_format;
@@ -163,11 +181,14 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
author++;
author_end = strchrnul(author, '\n');
committer = strstr(author_end, "\ncommitter ");
+ parse_line(&author, &author_end);
+
if (!committer)
die ("Could not find committer in commit %s",
sha1_to_hex(commit->object.sha1));
committer++;
committer_end = strchrnul(committer, '\n');
+ parse_line(&committer, &committer_end);
message = strstr(committer_end, "\n\n");
encoding = find_encoding(committer_end, message);
if (message)
@@ -214,6 +235,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
printf("\n");
+ free(committer);
+ free(author);
show_progress();
}
--
1.5.6.rc0.163.g26db5e.dirty
next reply other threads:[~2008-05-30 10:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-30 10:31 Pieter de Bie [this message]
2008-05-30 20:27 ` [PATCH] builtin-fast-export: Remove double spaces in author line Junio C Hamano
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=1212143475-48255-1-git-send-email-pdebie@ai.rug.nl \
--to=pdebie@ai.rug.nl \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).