This is an initial attempt to enable history tracking for multiple repositories in a consistent state. At the moment this can only be done by heuristic guessing on the parent dates and the committer names. This fails for example with Dave Millers net-2.6 and sparc-2.6 trees, as in both cases the committer name is the same. It fails also completely in cases where the system clock of the committer is wrong and the merge is a head forward. The old bk repository contains entries from 1999 and 2027, which will happen also with git over the time.
To identify a repository commit-tree tries to read an environment variable "GIT_REPOSITORY_ID" and has a fallback to the current working directory. The environment variable keeps the door open for managed repository id's, but the current working directory is certainly a quite helpful information to solve the origin decision for history tracking.
Adding a line after the committer should not break any existing tools AFAICS.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Show changes to commit-tree.c +11 −1
--- a/commit-tree.c +++ b/commit-tree.c @@ -110,6 +110,7 @@ int main(int argc, char **argv) char *gecos, *realgecos, *commitgecos; char *email, *commitemail, realemail[1000]; char date[20], realdate[20]; + char *repoid, repoidbuf[MAXPATHLEN]; char *audate; char comment[1000]; struct passwd *pw; @@ -154,6 +155,14 @@ int main(int argc, char **argv) if (audate) parse_date(audate, date, sizeof(date)); + repoid = getenv("GIT_REPOSITORY_ID"); + if (!repoid) + repoid = getcwd(repoidbuf, MAXPATHLEN); + else { + if (strlen(repoid) == 0) + die("GIT_REPOSITORY_ID is empty. Fix it !"); + } + remove_special(gecos); remove_special(realgecos); remove_special(commitgecos); remove_special(email); remove_special(realemail); remove_special(commitemail); @@ -170,7 +179,8 @@ int main(int argc, char **argv) /* Person/date information */ add_buffer(&buffer, &size, "author %s <%s> %s\n", gecos, email, date); - add_buffer(&buffer, &size, "committer %s <%s> %s\n\n", commitgecos, commitemail, realdate); + add_buffer(&buffer, &size, "committer %s <%s> %s\n", commitgecos, commitemail, realdate); + add_buffer(&buffer, &size, "repoid %s\n\n", repoid); /* And add the comment */ while (fgets(comment, sizeof(comment), stdin) != NULL)