git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ye Xiaolong <xiaolong.ye@intel.com>
Cc: git@vger.kernel.org, fengguang.wu@intel.com,
	ying.huang@intel.com, philip.li@intel.com, julie.du@intel.com
Subject: Re: [PATCH v4 2/4] format-patch: add '--base' option to record base tree info
Date: Thu, 14 Apr 2016 09:23:17 -0700	[thread overview]
Message-ID: <xmqq37qoi2h6.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160414142333.GA31621@yexl-desktop> (Ye Xiaolong's message of "Thu, 14 Apr 2016 22:23:33 +0800")

Ye Xiaolong <xiaolong.ye@intel.com> writes:

>>> +	for (i = 0; i < total; i++) {
>>> +		if (!in_merge_bases(base, list[i]) || base == list[i])
>>> +			die(_("base commit should be the ancestor of revision list"));
>>
>>This check looks overly expensive, but I do not think of a more
>>efficient way to do this, given that "All the commits from our
>>series must reach the specified base" is what you seem to want.
>>
>>My understanding is that if base=P is given and you are doing
>>"format-patch Z..C" in this picture:
>>
>>    Q---P---Z---B---*---C
>>     \             /
>>      .-----------A
>>
>
> How about we compute the merge base of the specified rev list in
> cmdline (it should be Q in above case), then check whether specified
> base (P in this case) could be reachable from it, if it couldn't, we
> just error out.

What commits are you considering "the specified rev list in cmdline"
in the example?  Do you mean "commits in the list[], i.e. those to
be shown as patches?"

That is, you are proposing to find the topologically-youngest common
ancestors of A, B and C, which is Q?

There is no canned way to compute that (merge_bases_many() is not
that function).

You however can do repeated pair-wise merge base computations to
reduce the complexity from your O(n) loop to O(log n), I guess.  Do
a pair-wise merge base between A and B (which is Q), and do a merge
base between C (which is the remaining one) and Q to arrive at Q.

  reply	other threads:[~2016-04-14 16:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-11  2:47 [PATCH v4 0/4] Add --base option to git-format-patch to record base tree info Xiaolong Ye
2016-04-11  2:47 ` [PATCH v4 1/4] patch-ids: make commit_patch_id() a public helper function Xiaolong Ye
2016-04-11  2:47 ` [PATCH v4 2/4] format-patch: add '--base' option to record base tree info Xiaolong Ye
2016-04-12 19:08   ` Junio C Hamano
2016-04-13 14:42     ` Ye Xiaolong
2016-04-14 14:23     ` Ye Xiaolong
2016-04-14 16:23       ` Junio C Hamano [this message]
2016-04-11  2:47 ` [PATCH v4 3/4] format-patch: introduce --base=auto option Xiaolong Ye
2016-04-11  2:47 ` [PATCH v4 4/4] format-patch: introduce format.base configuration Xiaolong Ye
2016-04-12 19:47   ` Junio C Hamano
2016-04-13 15:55     ` Ye Xiaolong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq37qoi2h6.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=fengguang.wu@intel.com \
    --cc=git@vger.kernel.org \
    --cc=julie.du@intel.com \
    --cc=philip.li@intel.com \
    --cc=xiaolong.ye@intel.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).