[PATCH] builtin-fast-export: Remove double spaces in author line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>  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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux