Subject: Re: Porcelain support for daggy-fixes?

From: Mikko Rantalainen <[email-masked]>
Date: Fri, 11 Jun 2010 14:25:09 +0300

Pascal Obry wrote:
> I would probably create a topic/fix branch:
> 
> 1) figure out the proper parent for the bug fix
> 2) create the fix branch and move to it
>     $ git co -b fix-feature-whatever parent
> 3) implement the fix
> 4) commit the fix
> 5) checkout HEAD
> 6) merge with the commit from step 4
> 
> And also merge on release branch if needed.

OK. I agree with this. The only problem is step 1 above (plus the other
repeated steps if this is done every time you find a bug).

I'm still wondering if it would be possible to figure the correct parent
automatically. How about the following:

Given: minimal patch to fix a bug committed to tip of the master.
Target: find proper parent for daggy-fix for the given bugfix (and then
later rewrite history to put the fix as daggy-fix and merge with the master)

Idea:

Compare the list of removed lines from latest commit (the bugfix) with
the output of the same lines from git blame --cc (immediately before the
bugfix). Proper parent for the bug fix is the commit that is newest for
any removed line from the parent of the bugfix in the tip of the master
(HEAD^).

Does it sound sensible to assume that the proper parent for the bug fix
is the newest commit that has modified any line that is removed or
replaced by the bug fix?

Why do I even think about this? I believe that daggy-fix style would be
beneficial for many software projects but for small fixes it requires
many little steps to implement and extra work to figure out the correct
parent. Small bugs are often easy to fix at the tip of the master so the
fixes usually end up there. It would be awesome if git were smart enough
to move the fix to the correct location (daggy-fix)  and do automatic
merge, once told that the last commit was really a bugfix. If this ends
up working well enough, then it should be a flag for commit (--bugfix)
which does the commit to proper parent and then does another merge
commit with the current branch. Then the other branches (or forks) could
merge the fix more easily (daggy-fixes should merge without conflicts if
done correctly).

-- 
Mikko