Jeff King wrote: > On Wed, Jun 11, 2008 at 11:02:29AM +0200, Thomas Rast wrote: > > > +# If the patch applies cleanly, the hunk will immediately be marked > > +# for staging as if you had answered 'y'. (However, if you remove > > +# everything, nothing happens.) Otherwise, you will be asked to edit > > +# again. > > This "however" confused me the first time I read it. I assume you mean > that "if the diff is empty, then staging it will do nothing"? I wonder > if that is even worth mentioning, since it seems obvious. I wanted to make the same special case that 'recount -i' has: Deleting everything does not "do nothing", but actually aborts the edit. So in rebase, deleting everything will not rebase anything (instead of rebasing "no patches" onto wherever you said). Along the same lines, in the above patch deleting everything does not patch "no changes", but aborts editing the hunk and leaves it unchanged. Do you think that behaviour confuses users? > > +# Do not add @ lines unless you know what you are doing. The original > > +# @ line will be reinserted if you remove it. > > This can probably be moved from the "every time" instructions to the > manual, if we want to keep the size of the instructions a bit smaller. > > > + if (diff_applies($head, > > + @{$hunk}[0..$ix-1], > > + $newhunk, > > + @{$hunk}[$ix+1..$#{$hunk}])) { > > I'm confused here...we are feeding _all_ of the hunks to git-apply. In > my patch, I simply fed the hunk of interest. Since we are recounting, > shouldn't the single hunk be enough? And if it isn't, then shouldn't we > be feeding only the hunks that are to be applied? Feeding it the single hunk would be enough, but doing it this way ensures that the edited hunk cannot step on another hunk's toes, i.e. produce a conflict that may prevent us from applying the patch at the end of the hunk selection loop. It's fairly unlikely of course, because the user would deliberately have to extend the hunk beyond its current borders by adding extra context from the original file. -- Thomas Rast trast@student.ethz.ch