{"thread":{"id":"10981","subject":"git-svn rebase issues (the commiter gets changed)","startedAt":"2007-11-22T16:15:11Z","lastAt":"2007-12-18T17:16:04Z","messageCount":7,"participants":["Kelvie Wong","Eric Wong","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"60692","messageId":"94ccbe710711220815j663d22e0v3c744244d0a87b66@mail.gmail.com","threadId":"10981","inReplyTo":null,"subject":"git-svn rebase issues (the commiter gets changed)","fromName":"Kelvie Wong","fromEmail":"kelvie@ieee.org","sentAt":"2007-11-22T16:15:11Z","receivedAt":"2007-11-22T16:15:11Z","isPatch":false,"sender":{"key":"kelvie@ieee.org","avatar":null},"body":"When using git-svn rebase (I'm not sure if this happens with a regular\nrebase as well, I use use git-svn primarily at work), the following\noddity happens:\n\nkelvie@mudd (working) qt $ git-cat-file commit\nc27e6207c9078d4225288d55454d6577f0135c16\ntree 13d9ef9cc67f5e6381d7697e5794c0ab5f72c729\nparent b9eb187d3029c5f9a816cb8f5473d9b239952d53\nauthor kwong <kwong@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195596864 +0000\ncommitter cscrimgeour\n<cscrimgeour@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195691944 +0000\n\nQt/FME Extensions: QFMEDialog/QFMEWizard -> Windows only, for now\n\nThis is also a reapplication of r39657, which got rolled back.\n\nThese have dependencies on QWinWidget (which is a part of the MFC/Qt Migration\nSolution), and thus, it does not build without it.\n<kw>\nkelvie@mudd (working) qt $ git-cat-file commit\n7075991c67c6d409ec2315dfeef6f45dd328485b\ntree 13d9ef9cc67f5e6381d7697e5794c0ab5f72c729\nparent b9eb187d3029c5f9a816cb8f5473d9b239952d53\nauthor kwong <kwong@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195596864 +0000\ncommitter Kelvie Wong <Kelvie.Wong@safe.com> 1195747291 +0000\n\nQt/FME Extensions: QFMEDialog/QFMEWizard -> Windows only, for now\n\nThis is also a reapplication of r39657, which got rolled back.\n\nThese have dependencies on QWinWidget (which is a part of the MFC/Qt Migration\nSolution), and thus, it does not build without it.\n<kw>\n\n\nThese are both the exact same commit (the tree, parent, and author are\nequivalent).\n\nSometimes (not always), the committer in a commit changes to be the\ncommitter of the parent (svn) commit.  This only happens to the\ncommits whose parent is the SVN commit.  In the above example,\ncscrimgeour is a SVN user, who obviously could not have changed my\ncode; the proper commit is the one at the bottom.\n\nBoth of these are the first local commit that I have rebased onto SVN.\n\n-- \nKelvie Wong\n"},{"id":"61374","messageId":"20071129075205.GB32277@soma","threadId":"10981","inReplyTo":"94ccbe710711220815j663d22e0v3c744244d0a87b66@mail.gmail.com","subject":"Re: git-svn rebase issues (the commiter gets changed)","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-11-29T07:52:05Z","receivedAt":"2007-11-29T07:52:05Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Kelvie Wong <kelvie@ieee.org> wrote:\n> When using git-svn rebase (I'm not sure if this happens with a regular\n> rebase as well, I use use git-svn primarily at work), the following\n> oddity happens:\n> \n> kelvie@mudd (working) qt $ git-cat-file commit\n> c27e6207c9078d4225288d55454d6577f0135c16\n> tree 13d9ef9cc67f5e6381d7697e5794c0ab5f72c729\n> parent b9eb187d3029c5f9a816cb8f5473d9b239952d53\n> author kwong <kwong@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195596864 +0000\n> committer cscrimgeour\n> <cscrimgeour@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195691944 +0000\n\nThis is strange.  Does this commit end below? or did you truncate\nthe git-svn-id: line from this message?\n\n> \n> Qt/FME Extensions: QFMEDialog/QFMEWizard -> Windows only, for now\n> \n> This is also a reapplication of r39657, which got rolled back.\n> \n> These have dependencies on QWinWidget (which is a part of the MFC/Qt Migration\n> Solution), and thus, it does not build without it.\n> <kw>\n> kelvie@mudd (working) qt $ git-cat-file commit\n> 7075991c67c6d409ec2315dfeef6f45dd328485b\n> tree 13d9ef9cc67f5e6381d7697e5794c0ab5f72c729\n> parent b9eb187d3029c5f9a816cb8f5473d9b239952d53\n> author kwong <kwong@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195596864 +0000\n> committer Kelvie Wong <Kelvie.Wong@safe.com> 1195747291 +0000\n\nThis commit hasn't made it into SVN, yet, right?  If so, then that's\nalright.\n\n> \n> Qt/FME Extensions: QFMEDialog/QFMEWizard -> Windows only, for now\n> \n> This is also a reapplication of r39657, which got rolled back.\n> \n> These have dependencies on QWinWidget (which is a part of the MFC/Qt Migration\n> Solution), and thus, it does not build without it.\n> <kw>\n> \n> \n> These are both the exact same commit (the tree, parent, and author are\n> equivalent).\n> \n> Sometimes (not always), the committer in a commit changes to be the\n> committer of the parent (svn) commit.  This only happens to the\n> commits whose parent is the SVN commit.  In the above example,\n> cscrimgeour is a SVN user, who obviously could not have changed my\n> code; the proper commit is the one at the bottom.\n> \n> Both of these are the first local commit that I have rebased onto SVN.\n\nDid you get these commits by cherry-picking (or format-patch + am)\nfrom another SVN branch?  Have these commits been made to SVN already?\n\n`gitk --reflog --all' may reveal some answers or clarify\nthings for you (assuming you have reflogs enabled in .git/config).\n\nRebase (all forms of it) *does* rewrite committer info, but how you got\ncscrimgeour in there is very strange to me.\n\n-- \nEric Wong\n"},{"id":"61406","messageId":"94ccbe710711290816t7a6ba9b1o8f37ecf583305a51@mail.gmail.com","threadId":"10981","inReplyTo":"20071129075205.GB32277@soma","subject":"Re: git-svn rebase issues (the commiter gets changed)","fromName":"Kelvie Wong","fromEmail":"kelvie@ieee.org","sentAt":"2007-11-29T16:16:32Z","receivedAt":"2007-11-29T16:16:32Z","isPatch":false,"sender":{"key":"kelvie@ieee.org","avatar":null},"body":"On Nov 28, 2007 11:52 PM, Eric Wong <normalperson@yhbt.net> wrote:\n> Kelvie Wong <kelvie@ieee.org> wrote:\n> > When using git-svn rebase (I'm not sure if this happens with a regular\n> > rebase as well, I use use git-svn primarily at work), the following\n> > oddity happens:\n> >\n> > kelvie@mudd (working) qt $ git-cat-file commit\n> > c27e6207c9078d4225288d55454d6577f0135c16\n> > tree 13d9ef9cc67f5e6381d7697e5794c0ab5f72c729\n> > parent b9eb187d3029c5f9a816cb8f5473d9b239952d53\n> > author kwong <kwong@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195596864 +0000\n> > committer cscrimgeour\n> > <cscrimgeour@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195691944 +0000\n>\n> This is strange.  Does this commit end below? or did you truncate\n> the git-svn-id: line from this message?\n>\n\nThis is one of my local commits, not yet commited to the SVN repo.\nI've talked on IRC, and it seems I'm not the only one that has this\nproblem.  I have heard that the committer timestamp of _all_ rebased\nlocal commits gets changed to the last SVN commit (made by someone\nelse), but the committer doesn't get changed (except in the first\ncommit rebased after SVN).\n\n> >\n> > Qt/FME Extensions: QFMEDialog/QFMEWizard -> Windows only, for now\n> >\n> > This is also a reapplication of r39657, which got rolled back.\n> >\n> > These have dependencies on QWinWidget (which is a part of the MFC/Qt Migration\n> > Solution), and thus, it does not build without it.\n> > <kw>\n> > kelvie@mudd (working) qt $ git-cat-file commit\n> > 7075991c67c6d409ec2315dfeef6f45dd328485b\n> > tree 13d9ef9cc67f5e6381d7697e5794c0ab5f72c729\n> > parent b9eb187d3029c5f9a816cb8f5473d9b239952d53\n> > author kwong <kwong@e2d93294-a71b-0410-9dca-e2ea525a67c9> 1195596864 +0000\n> > committer Kelvie Wong <Kelvie.Wong@safe.com> 1195747291 +0000\n>\n> This commit hasn't made it into SVN, yet, right?  If so, then that's\n> alright.\n>\n> >\n> > Qt/FME Extensions: QFMEDialog/QFMEWizard -> Windows only, for now\n> >\n> > This is also a reapplication of r39657, which got rolled back.\n> >\n> > These have dependencies on QWinWidget (which is a part of the MFC/Qt Migration\n> > Solution), and thus, it does not build without it.\n> > <kw>\n> >\n> >\n> > These are both the exact same commit (the tree, parent, and author are\n> > equivalent).\n> >\n> > Sometimes (not always), the committer in a commit changes to be the\n> > committer of the parent (svn) commit.  This only happens to the\n> > commits whose parent is the SVN commit.  In the above example,\n> > cscrimgeour is a SVN user, who obviously could not have changed my\n> > code; the proper commit is the one at the bottom.\n> >\n> > Both of these are the first local commit that I have rebased onto SVN.\n>\n> Did you get these commits by cherry-picking (or format-patch + am)\n> from another SVN branch?  Have these commits been made to SVN already?\n>\n\nIt's a commit I made directly.\n\n> `gitk --reflog --all' may reveal some answers or clarify\n> things for you (assuming you have reflogs enabled in .git/config).\n>\n> Rebase (all forms of it) *does* rewrite committer info, but how you got\n> cscrimgeour in there is very strange to me.\n>\n> --\n> Eric Wong\n>\n\nJust did it again this morning, with a clean test branch:\n\nkelvie@mudd (text-edit) qt $ git checkout -b test git-svn\nSwitched to a new branch \"test\"\nkelvie@mudd (test) qt $ touch test\nkelvie@mudd (test) qt $ git add test\nkelvie@mudd (test) qt $ git commit -a -m 'Test!'\nCreated commit 05c4016: Test!\n 0 files changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 apps/qt/test\nkelvie@mudd (test) qt $ git-cat-file commit HEAD\ntree 867c0aa4c814542f0752b5d4c85fc96ba2279aac\nparent 831ffbf25057ed30274d4216269c572cfce12184\nauthor Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\ncommitter Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\n\nTest!\nkelvie@mudd (test) qt $ git svn rebase\n<snip>\nHEAD is now at 7319c2a... (svn commit message)\nkelvie@mudd (test) qt $ git-cat-file commit HEAD\ntree 4edacbd41af76ac243099467b33350887c0fb03d\nparent 7319c2a810554aab25a688bcc2b16fc60529b59d\nauthor Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\ncommitter ogibbins <ogibbins@e2d93294-a71b-0410-9dca-e2ea525a67c9>\n1196346907 +0000\n\nTest!\nkelvie@mudd (test) qt $ git --version\ngit version 1.5.3.6.736.gb7f30\n\nAnd again, the committer of a local commit gets changed.\n\nNow, this part is more interesting:\n\nkelvie@mudd (test) qt $ git checkout working\nSwitched to branch \"working\"\nkelvie@mudd (working) qt $ git svn rebase\n<no fetch, just a checkout and rebase>\n\nAnd when I cat-file the commit, this time it's preserved.  Wild guess\nhere (this behaviour seems kind of inconsistent), but it has to do\nwith the transition between fetch and rebase?  Or is this a bug in\ngit-rebase somewhere?\n\n-- \nKelvie Wong\n"},{"id":"63288","messageId":"20071216032523.GA17666@muzzle","threadId":"10981","inReplyTo":"94ccbe710711290816t7a6ba9b1o8f37ecf583305a51@mail.gmail.com","subject":"Re: git-svn rebase issues (the commiter gets changed)","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-12-16T03:27:09Z","receivedAt":"2007-12-16T03:27:09Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Sorry for the late reply, I've been all over the place lately.\n\nKelvie Wong <kelvie@ieee.org> wrote:\n> Just did it again this morning, with a clean test branch:\n> \n> kelvie@mudd (text-edit) qt $ git checkout -b test git-svn\n> Switched to a new branch \"test\"\n> kelvie@mudd (test) qt $ touch test\n> kelvie@mudd (test) qt $ git add test\n> kelvie@mudd (test) qt $ git commit -a -m 'Test!'\n> Created commit 05c4016: Test!\n>  0 files changed, 0 insertions(+), 0 deletions(-)\n>  create mode 100644 apps/qt/test\n> kelvie@mudd (test) qt $ git-cat-file commit HEAD\n> tree 867c0aa4c814542f0752b5d4c85fc96ba2279aac\n> parent 831ffbf25057ed30274d4216269c572cfce12184\n> author Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\n> committer Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\n> \n> Test!\n> kelvie@mudd (test) qt $ git svn rebase\n> <snip>\n> HEAD is now at 7319c2a... (svn commit message)\n> kelvie@mudd (test) qt $ git-cat-file commit HEAD\n> tree 4edacbd41af76ac243099467b33350887c0fb03d\n> parent 7319c2a810554aab25a688bcc2b16fc60529b59d\n> author Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\n> committer ogibbins <ogibbins@e2d93294-a71b-0410-9dca-e2ea525a67c9>\n> 1196346907 +0000\n> \n> Test!\n> kelvie@mudd (test) qt $ git --version\n> git version 1.5.3.6.736.gb7f30\n> \n> And again, the committer of a local commit gets changed.\n> \n> Now, this part is more interesting:\n> \n> kelvie@mudd (test) qt $ git checkout working\n> Switched to branch \"working\"\n> kelvie@mudd (working) qt $ git svn rebase\n> <no fetch, just a checkout and rebase>\n> \n> And when I cat-file the commit, this time it's preserved.  Wild guess\n> here (this behaviour seems kind of inconsistent), but it has to do\n> with the transition between fetch and rebase?  Or is this a bug in\n> git-rebase somewhere?\n\nAh, it looks like a bug in git-svn.  The following should fix it:\n\n>From 84e99bffc72c10ec7db6d5ae7af6a795b75ef724 Mon Sep 17 00:00:00 2001\nFrom: Eric Wong <normalperson@yhbt.net>\nDate: Sat, 15 Dec 2007 19:08:22 -0800\nSubject: [PATCH] git-svn: avoid leaving leftover committer/author info in rebase\n\nWe set the 6 environment variables for controlling\ncommitter/author email/name/time for every commit.\n\nWe do this in the parent process to be passed to\ngit-commit-tree, because open3() doesn't afford us the control\nof doing it only in the child process.  This means we leave them\nhanging around in the main process until the next revision comes\naround and all 6 environment variables are overwridden again.\n\nUnfortunately, for the last commit, leaving them hanging around\nmeans the git-rebase invocation will pick it up, rewriting the\nrebased commit with incorrect author information.  This should fix\nit.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   50 +++++++++++++++++++++++++++++++++++++++-----------\n 1 files changed, 39 insertions(+), 11 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex d411a34..7cd62fc 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2052,18 +2052,16 @@ sub full_url {\n \t$self->{url} . (length $self->{path} ? '/' . $self->{path} : '');\n }\n \n-sub do_git_commit {\n-\tmy ($self, $log_entry) = @_;\n-\tmy $lr = $self->last_rev;\n-\tif (defined $lr && $lr >= $log_entry->{revision}) {\n-\t\tdie \"Last fetched revision of \", $self->refname,\n-\t\t    \" was r$lr, but we are about to fetch: \",\n-\t\t    \"r$log_entry->{revision}!\\n\";\n-\t}\n-\tif (my $c = $self->rev_map_get($log_entry->{revision})) {\n-\t\tcroak \"$log_entry->{revision} = $c already exists! \",\n-\t\t      \"Why are we refetching it?\\n\";\n+\n+sub set_commit_header_env {\n+\tmy ($log_entry) = @_;\n+\tmy %env;\n+\tforeach my $ned (qw/NAME EMAIL DATE/) {\n+\t\tforeach my $ac (qw/AUTHOR COMMITTER/) {\n+\t\t\t$env{\"GIT_${ac}_${ned}\"} = $ENV{\"GIT_${ac}_${ned}\"};\n+\t\t}\n \t}\n+\n \t$ENV{GIT_AUTHOR_NAME} = $log_entry->{name};\n \t$ENV{GIT_AUTHOR_EMAIL} = $log_entry->{email};\n \t$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_entry->{date};\n@@ -2074,7 +2072,36 @@ sub do_git_commit {\n \t$ENV{GIT_COMMITTER_EMAIL} = (defined $log_entry->{commit_email})\n \t\t\t\t\t\t? $log_entry->{commit_email}\n \t\t\t\t\t\t: $log_entry->{email};\n+\t\\%env;\n+}\n \n+sub restore_commit_header_env {\n+\tmy ($env) = @_;\n+\tforeach my $ned (qw/NAME EMAIL DATE/) {\n+\t\tforeach my $ac (qw/AUTHOR COMMITTER/) {\n+\t\t\tmy $k = \"GIT_${ac}_${ned}\";\n+\t\t\tif (defined $env->{$k}) {\n+\t\t\t\t$ENV{$k} = $env->{$k};\n+\t\t\t} else {\n+\t\t\t\tdelete $ENV{$k};\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+sub do_git_commit {\n+\tmy ($self, $log_entry) = @_;\n+\tmy $lr = $self->last_rev;\n+\tif (defined $lr && $lr >= $log_entry->{revision}) {\n+\t\tdie \"Last fetched revision of \", $self->refname,\n+\t\t    \" was r$lr, but we are about to fetch: \",\n+\t\t    \"r$log_entry->{revision}!\\n\";\n+\t}\n+\tif (my $c = $self->rev_map_get($log_entry->{revision})) {\n+\t\tcroak \"$log_entry->{revision} = $c already exists! \",\n+\t\t      \"Why are we refetching it?\\n\";\n+\t}\n+\tmy $old_env = set_commit_header_env($log_entry);\n \tmy $tree = $log_entry->{tree};\n \tif (!defined $tree) {\n \t\t$tree = $self->tmp_index_do(sub {\n@@ -2089,5 +2116,6 @@ sub do_git_commit {\n \tdefined(my $pid = open3(my $msg_fh, my $out_fh, '>&STDERR', @exec))\n \t                                                           or croak $!;\n \tprint $msg_fh $log_entry->{log} or croak $!;\n+\trestore_commit_header_env($old_env);\n \tunless ($self->no_metadata) {\n \t\tprint $msg_fh \"\\ngit-svn-id: $log_entry->{metadata}\\n\"\n\\ No newline at end of file\n-- \nEric Wong\n"},{"id":"63290","messageId":"20071216033947.GB17666@muzzle","threadId":"10981","inReplyTo":"20071216032523.GA17666@muzzle","subject":"Re: git-svn rebase issues (the commiter gets changed)","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-12-16T03:39:47Z","receivedAt":"2007-12-16T03:39:47Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n> From 84e99bffc72c10ec7db6d5ae7af6a795b75ef724 Mon Sep 17 00:00:00 2001\n> Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> ---\n>  git-svn.perl |   50 +++++++++++++++++++++++++++++++++++++++-----------\n>  1 files changed, 39 insertions(+), 11 deletions(-)\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index d411a34..7cd62fc 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -2089,5 +2116,6 @@ sub do_git_commit {\n>  \tdefined(my $pid = open3(my $msg_fh, my $out_fh, '>&STDERR', @exec))\n>  \t                                                           or croak $!;\n>  \tprint $msg_fh $log_entry->{log} or croak $!;\n> +\trestore_commit_header_env($old_env);\n>  \tunless ($self->no_metadata) {\n>  \t\tprint $msg_fh \"\\ngit-svn-id: $log_entry->{metadata}\\n\"\n> \\ No newline at end of file\n\nHi Junio,\n\nThis \"\\ No newline at end of file\" from git-format-patch seems wrong.\n\nBisecting reveals that it started happening at:\n\n  913b45f51b151d8e29f86df67d3e10853d831470\n  xdi_diff: trim common trailing lines\n\n-- \nEric Wong\n"},{"id":"63301","messageId":"7vve6zkx2a.fsf@gitster.siamese.dyndns.org","threadId":"10981","inReplyTo":"20071216033947.GB17666@muzzle","subject":"Re: git-svn rebase issues (the commiter gets changed)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-16T05:50:21Z","receivedAt":"2007-12-16T05:50:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yes, I think Jeff's patch (and my simplification) should fix it.  Sorry\nabout the brown-paper-bag bug.\n"},{"id":"63645","messageId":"94ccbe710712180916x10fc53fane4aae7cc60877e36@mail.gmail.com","threadId":"10981","inReplyTo":"20071216032523.GA17666@muzzle","subject":"Re: git-svn rebase issues (the commiter gets changed)","fromName":"Kelvie Wong","fromEmail":"kelvie@ieee.org","sentAt":"2007-12-18T17:16:04Z","receivedAt":"2007-12-18T17:16:04Z","isPatch":false,"sender":{"key":"kelvie@ieee.org","avatar":null},"body":"On Dec 15, 2007 7:27 PM, Eric Wong <normalperson@yhbt.net> wrote:\n> Sorry for the late reply, I've been all over the place lately.\n>\n> Kelvie Wong <kelvie@ieee.org> wrote:\n>\n> > Just did it again this morning, with a clean test branch:\n> >\n> > kelvie@mudd (text-edit) qt $ git checkout -b test git-svn\n> > Switched to a new branch \"test\"\n> > kelvie@mudd (test) qt $ touch test\n> > kelvie@mudd (test) qt $ git add test\n> > kelvie@mudd (test) qt $ git commit -a -m 'Test!'\n> > Created commit 05c4016: Test!\n> >  0 files changed, 0 insertions(+), 0 deletions(-)\n> >  create mode 100644 apps/qt/test\n> > kelvie@mudd (test) qt $ git-cat-file commit HEAD\n> > tree 867c0aa4c814542f0752b5d4c85fc96ba2279aac\n> > parent 831ffbf25057ed30274d4216269c572cfce12184\n> > author Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\n> > committer Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\n> >\n> > Test!\n> > kelvie@mudd (test) qt $ git svn rebase\n> > <snip>\n> > HEAD is now at 7319c2a... (svn commit message)\n> > kelvie@mudd (test) qt $ git-cat-file commit HEAD\n> > tree 4edacbd41af76ac243099467b33350887c0fb03d\n> > parent 7319c2a810554aab25a688bcc2b16fc60529b59d\n> > author Kelvie Wong <Kelvie.Wong@safe.com> 1196352603 -0800\n> > committer ogibbins <ogibbins@e2d93294-a71b-0410-9dca-e2ea525a67c9>\n> > 1196346907 +0000\n> >\n> > Test!\n> > kelvie@mudd (test) qt $ git --version\n> > git version 1.5.3.6.736.gb7f30\n> >\n> > And again, the committer of a local commit gets changed.\n> >\n> > Now, this part is more interesting:\n> >\n> > kelvie@mudd (test) qt $ git checkout working\n> > Switched to branch \"working\"\n> > kelvie@mudd (working) qt $ git svn rebase\n> > <no fetch, just a checkout and rebase>\n> >\n> > And when I cat-file the commit, this time it's preserved.  Wild guess\n> > here (this behaviour seems kind of inconsistent), but it has to do\n> > with the transition between fetch and rebase?  Or is this a bug in\n> > git-rebase somewhere?\n>\n> Ah, it looks like a bug in git-svn.  The following should fix it:\n>\n> From 84e99bffc72c10ec7db6d5ae7af6a795b75ef724 Mon Sep 17 00:00:00 2001\n> From: Eric Wong <normalperson@yhbt.net>\n> Date: Sat, 15 Dec 2007 19:08:22 -0800\n> Subject: [PATCH] git-svn: avoid leaving leftover committer/author info in rebase\n>\n> We set the 6 environment variables for controlling\n> committer/author email/name/time for every commit.\n>\n> We do this in the parent process to be passed to\n> git-commit-tree, because open3() doesn't afford us the control\n> of doing it only in the child process.  This means we leave them\n> hanging around in the main process until the next revision comes\n> around and all 6 environment variables are overwridden again.\n>\n> Unfortunately, for the last commit, leaving them hanging around\n> means the git-rebase invocation will pick it up, rewriting the\n> rebased commit with incorrect author information.  This should fix\n> it.\n>\n> Signed-off-by: Eric Wong <normalperson@yhbt.net>\n> ---\n>  git-svn.perl |   50 +++++++++++++++++++++++++++++++++++++++-----------\n>  1 files changed, 39 insertions(+), 11 deletions(-)\n>\n> diff --git a/git-svn.perl b/git-svn.perl\n> index d411a34..7cd62fc 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -2052,18 +2052,16 @@ sub full_url {\n>         $self->{url} . (length $self->{path} ? '/' . $self->{path} : '');\n>  }\n>\n> -sub do_git_commit {\n> -       my ($self, $log_entry) = @_;\n> -       my $lr = $self->last_rev;\n> -       if (defined $lr && $lr >= $log_entry->{revision}) {\n> -               die \"Last fetched revision of \", $self->refname,\n> -                   \" was r$lr, but we are about to fetch: \",\n> -                   \"r$log_entry->{revision}!\\n\";\n> -       }\n> -       if (my $c = $self->rev_map_get($log_entry->{revision})) {\n> -               croak \"$log_entry->{revision} = $c already exists! \",\n> -                     \"Why are we refetching it?\\n\";\n> +\n> +sub set_commit_header_env {\n> +       my ($log_entry) = @_;\n> +       my %env;\n> +       foreach my $ned (qw/NAME EMAIL DATE/) {\n> +               foreach my $ac (qw/AUTHOR COMMITTER/) {\n> +                       $env{\"GIT_${ac}_${ned}\"} = $ENV{\"GIT_${ac}_${ned}\"};\n> +               }\n>         }\n> +\n>         $ENV{GIT_AUTHOR_NAME} = $log_entry->{name};\n>         $ENV{GIT_AUTHOR_EMAIL} = $log_entry->{email};\n>         $ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_entry->{date};\n> @@ -2074,7 +2072,36 @@ sub do_git_commit {\n>         $ENV{GIT_COMMITTER_EMAIL} = (defined $log_entry->{commit_email})\n>                                                 ? $log_entry->{commit_email}\n>                                                 : $log_entry->{email};\n> +       \\%env;\n> +}\n>\n> +sub restore_commit_header_env {\n> +       my ($env) = @_;\n> +       foreach my $ned (qw/NAME EMAIL DATE/) {\n> +               foreach my $ac (qw/AUTHOR COMMITTER/) {\n> +                       my $k = \"GIT_${ac}_${ned}\";\n> +                       if (defined $env->{$k}) {\n> +                               $ENV{$k} = $env->{$k};\n> +                       } else {\n> +                               delete $ENV{$k};\n> +                       }\n> +               }\n> +       }\n> +}\n> +\n> +sub do_git_commit {\n> +       my ($self, $log_entry) = @_;\n> +       my $lr = $self->last_rev;\n> +       if (defined $lr && $lr >= $log_entry->{revision}) {\n> +               die \"Last fetched revision of \", $self->refname,\n> +                   \" was r$lr, but we are about to fetch: \",\n> +                   \"r$log_entry->{revision}!\\n\";\n> +       }\n> +       if (my $c = $self->rev_map_get($log_entry->{revision})) {\n> +               croak \"$log_entry->{revision} = $c already exists! \",\n> +                     \"Why are we refetching it?\\n\";\n> +       }\n> +       my $old_env = set_commit_header_env($log_entry);\n>         my $tree = $log_entry->{tree};\n>         if (!defined $tree) {\n>                 $tree = $self->tmp_index_do(sub {\n> @@ -2089,5 +2116,6 @@ sub do_git_commit {\n>         defined(my $pid = open3(my $msg_fh, my $out_fh, '>&STDERR', @exec))\n>                                                                    or croak $!;\n>         print $msg_fh $log_entry->{log} or croak $!;\n> +       restore_commit_header_env($old_env);\n>         unless ($self->no_metadata) {\n>                 print $msg_fh \"\\ngit-svn-id: $log_entry->{metadata}\\n\"\n> \\ No newline at end of file\n> --\n> Eric Wong\n>\n\nkelvie@mudd (test) qt $ git cat-file commit HEAD\ntree 20adec5e5b186ea4360b5866586af7cfa5e3d88a\nparent 15f3ab6b0c667b4900d5a7be0e80ef4e20b5bac2\nauthor Kelvie Wong <Kelvie.Wong@safe.com> 1197990883 -0800\ncommitter Kelvie Wong <Kelvie.Wong@safe.com> 1197990883 -0800\n\ntest\nkelvie@mudd (test) qt $ git svn rebase\n<snip>\nHEAD is now at ebd86b2... SnappingFactory: Fixed bizarre omission from\nprevious commit for this bug. (PR#12838) <omg>\nApplying test\nkelvie@mudd (test) qt $ git cat-file commit HEAD\ntree 2f242f83496f707758a863634a803f60a77c2786\nparent ebd86b245505a18603fd114862eb97ea9609d7e1\nauthor Kelvie Wong <Kelvie.Wong@safe.com> 1197990883 -0800\ncommitter Kelvie Wong <Kelvie.Wong@safe.com> 1197998130 +0000\n\ntest\nkelvie@mudd (test) qt $ git --version\ngit version 1.5.4.rc0.57.g4d99a\nkelvie@mudd (test) qt $ git svn --version\nUse of uninitialized value in pattern match (m//) at /usr/bin/git-svn line 202.\ngit-svn version 1.5.4.rc0.57.g4d99a (svn 1.4.4)\nkelvie@mudd (test) qt $\n\n\nLooks like it did it. Thanks for the fix.\n\n-- \nKelvie Wong\n"}]}