Bug 21185 - resolve-ChangeLogs should be able to fix poorly merged ChangeLog entries after a git svn rebase
Summary: resolve-ChangeLogs should be able to fix poorly merged ChangeLog entries afte...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-27 17:10 PDT by David Kilzer (:ddkilzer)
Modified: 2008-09-28 18:36 PDT (History)
2 users (show)

See Also:


Attachments
Patch v1 (7.03 KB, patch)
2008-09-27 17:24 PDT, David Kilzer (:ddkilzer)
aroben: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2008-09-27 17:10:46 PDT
* SUMMARY
When working in a local git repository and pushing commits to the WebKit svn directory, there are times when a "git svn rebase" will cause the ChangeLog entry for a locally committed patch to be merged incorrectly (e.g., not at the top of the ChangeLog file).

* STEPS TO REPRODUCE
1. You push a patch from git to svn (using git svn dcommit).
2. You commit another patch locally to git, such that a new ChangeLog entry has the same "date header" as the previous one (which is already committed to svn).
3. Someone else commits a ChangeLog entry above the entry from Step 1.
4. You're ready to commit your second patch, so you run "git svn rebase" to pull in svn commits and rebase your patch.

* RESULTS
After running "git svn rebase", git merges the ChangeLog entry for your second patch somewhere in the "middle" of the ChangeLog file, not at the top as you expected.

* WORKAROUND
Currently, your only option is to manually edit the ChangeLog file to correct it.
Comment 1 David Kilzer (:ddkilzer) 2008-09-27 17:24:09 PDT
Created attachment 23883 [details]
Patch v1

Suggested patch.
Comment 2 Adam Roben (:aroben) 2008-09-28 16:17:35 PDT
Comment on attachment 23883 [details]
Patch v1

The code/comments look good. Can you show an example usage of this new mode (what commands should the user type)?

r=me. Thanks for fixing this!!
Comment 3 David Kilzer (:ddkilzer) 2008-09-28 16:40:07 PDT
(In reply to comment #2)
> (From update of attachment 23883 [details] [edit])
> The code/comments look good. Can you show an example usage of this new mode
> (what commands should the user type)?

Well, if it doesn't do what you expected, please re-open this bug!

Basically, the -f|--fix-merge flag only works on the "last" git commit in the tree, so it assumes that you're going to do a "git commit --amend" after you run the command.  (If you have a commit buried in a rebase, your best bet is to use "git rebase -i commit-hash^" and then run this command when you've paused on the errant merge.)

* INITIAL STATE
The HEAD commit in your git branch contains a mis-merged ChangeLog entry (or two).

* STEPS
1. Run:  resolve-ChangeLogs -f < ChangeLog1> [< ChangeLog2> ...]
Example:  ./WebKitTools/Scripts/resolve-ChangeLogs -f WebCore/Changelog WebKit/ChangeLog

Note that the fixed ChangeLog files are automatically run through git-add.

2. Amend the commit:  git commit --amend

Note that you may want to fix up the commit message if it was also trashed.  (Is there an easy way to tell git to regenerate the commit message so the commit-log-editor does it's magic again?)

3. You're done.


I did notice that it doesn't print out a success message when it merges the file.  I will change that before landing.
Comment 4 David Kilzer (:ddkilzer) 2008-09-28 16:41:27 PDT
(In reply to comment #3)
> I did notice that it doesn't print out a success message when it merges the
> file.  I will change that before landing.

I also thought that there may be a better switch than "-f" (like -r|--remerge), but I was waiting for feedback that someone didn't like -f.  :)
Comment 5 David Kilzer (:ddkilzer) 2008-09-28 16:58:27 PDT
Committed r37047

I added code to output the status of the ChangeLog file after it was successfully updated, and added a couple missing lines of code.  (I did a poor job merging the patch from another tree before I posted it here previously).
Comment 6 Adam Roben (:aroben) 2008-09-28 18:19:56 PDT
(In reply to comment #3)
> Note that you may want to fix up the commit message if it was also trashed. 

When/how would the commit message get trashed?

> (Is there an easy way to tell git to regenerate the commit message so the
> commit-log-editor does it's magic again?)

commit-log-editor only generates a ChangeLog template if the input file contains no existing commit message. So you'd have to make sure that the input file is empty or contains only comments. This might involve messing with .git/MERGE_MSG and other files. I don't know all the details.
Comment 7 David Kilzer (:ddkilzer) 2008-09-28 18:36:30 PDT
(In reply to comment #6)
> (In reply to comment #3)
> > Note that you may want to fix up the commit message if it was also trashed. 
> 
> When/how would the commit message get trashed?

Nevermind.  I wasn't thinking when I wrote this.

> > (Is there an easy way to tell git to regenerate the commit message so the
> > commit-log-editor does it's magic again?)
> 
> commit-log-editor only generates a ChangeLog template if the input file
> contains no existing commit message. So you'd have to make sure that the input
> file is empty or contains only comments. This might involve messing with
> .git/MERGE_MSG and other files. I don't know all the details.

I may have to research this some time.  Hmm...looks like "man githooks" has some interesting information.  I wonder if I can write a prepare-commit-msg hook that conditionally regenerates the changelog entry (when I want it regenerated :)?