git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Detecting redundant commits
@ 2016-01-04 15:59 greened
  2016-01-05  4:00 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: greened @ 2016-01-04 15:59 UTC (permalink / raw)
  To: git

I am attempting to teach cherry-pick to handle redundant commits
gracefully (via a new --skip-redundant-commits option) instead of
aborting.  However, I'm struggling a bit with how to check if the
changes in a commit will become redundant when appied to the new HEAD.

I found diff_tree_sha1 which seems promising.  Am I on the right track?
If not, what's the best way to determine whether a commit object is
redundant with respect to HEAD?

                           -David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Detecting redundant commits
  2016-01-04 15:59 Detecting redundant commits greened
@ 2016-01-05  4:00 ` Jeff King
  2016-01-05 16:31   ` David Greene
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2016-01-05  4:00 UTC (permalink / raw)
  To: greened; +Cc: git

On Mon, Jan 04, 2016 at 09:59:09AM -0600, greened@obbligato.org wrote:

> I am attempting to teach cherry-pick to handle redundant commits
> gracefully (via a new --skip-redundant-commits option) instead of
> aborting.  However, I'm struggling a bit with how to check if the
> changes in a commit will become redundant when appied to the new HEAD.
> 
> I found diff_tree_sha1 which seems promising.  Am I on the right track?
> If not, what's the best way to determine whether a commit object is
> redundant with respect to HEAD?

Do you mean commits that are in the cherry-pick range but have matching
commits already in HEAD? For that, you'd want to use patch-ids.[ch], but
I think we already do.

Or do you mean commits that, when applied, we find turn out to have
empty changes (e.g., because we have a set of commits that have
different patch-ids, but do roughly the same thing)? I don't think you
can find that with a straight end-to-end diff. You have try to apply and
then look at the result. I think we already catch that case (see
--allow-empty), though I think the only options are "preserve" or
"abort", not "silently skip" (and it sounds like the latter is what you
would want).

Or am I missing the point completely? :)

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Detecting redundant commits
  2016-01-05  4:00 ` Jeff King
@ 2016-01-05 16:31   ` David Greene
  2016-01-08  3:14     ` David A. Greene
  0 siblings, 1 reply; 4+ messages in thread
From: David Greene @ 2016-01-05 16:31 UTC (permalink / raw)
  To: Jeff King; +Cc: git



On January 4, 2016 10:00:26 PM CST, Jeff King <peff@peff.net> wrote:

>Or do you mean commits that, when applied, we find turn out to have
>empty changes (e.g., because we have a set of commits that have
>different patch-ids, but do roughly the same thing)? I don't think you
>can find that with a straight end-to-end diff. You have try to apply
>and
>then look at the result. I think we already catch that case (see
>--allow-empty), though I think the only options are "preserve" or
>"abort", not "silently skip" (and it sounds like the latter is what you
>would want).

This.  I see where --allow-empty is handled in prepare_to_commit but it is not so easy to skip the commit at that point due to state changes.  I was trying to avoid going into commit at all by determining ahead of time whether the commit would become empty.  Any ideas?

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Detecting redundant commits
  2016-01-05 16:31   ` David Greene
@ 2016-01-08  3:14     ` David A. Greene
  0 siblings, 0 replies; 4+ messages in thread
From: David A. Greene @ 2016-01-08  3:14 UTC (permalink / raw)
  To: Jeff King; +Cc: git

David Greene <greened@obbligato.org> writes:

> On January 4, 2016 10:00:26 PM CST, Jeff King <peff@peff.net> wrote:
>
>>Or do you mean commits that, when applied, we find turn out to have
>>empty changes (e.g., because we have a set of commits that have
>>different patch-ids, but do roughly the same thing)? I don't think you
>>can find that with a straight end-to-end diff. You have try to apply
>>and then look at the result. I think we already catch that case (see
>>--allow-empty), though I think the only options are "preserve" or
>>"abort", not "silently skip" (and it sounds like the latter is what
>>you would want).
>
> This.  I see where --allow-empty is handled in prepare_to_commit but
> it is not so easy to skip the commit at that point due to state
> changes.  I was trying to avoid going into commit at all by
> determining ahead of time whether the commit would become empty.  Any
> ideas?

I ended up trying index_differs_from("HEAD", 0) and that actually seems
to work.  Unfortunately, it caused a regression and I'm having trouble
figuring out why.  The code should not even activate without a new
option specified.  If I get it working I'll send a patchset for comment.
Point me another direction if I'm way off track.  :)

                       -David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-08  3:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-04 15:59 Detecting redundant commits greened
2016-01-05  4:00 ` Jeff King
2016-01-05 16:31   ` David Greene
2016-01-08  3:14     ` David A. Greene

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).