From: Junio C Hamano <gitster@pobox.com>
To: Xiaolong Ye <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 v2 3/4] format-patch: introduce --base=auto option
Date: Wed, 23 Mar 2016 11:25:41 -0700 [thread overview]
Message-ID: <xmqqbn65caqi.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1458723147-7335-4-git-send-email-xiaolong.ye@intel.com> (Xiaolong Ye's message of "Wed, 23 Mar 2016 16:52:26 +0800")
Xiaolong Ye <xiaolong.ye@intel.com> writes:
> +
> + diff_setup(&diffopt);
> + DIFF_OPT_SET(&diffopt, RECURSIVE);
> + diff_setup_done(&diffopt);
It is annoying that you moved "diff" stuff here (if it can be
initialized once at the beginning and then reused over and over,
it should have been done here from the beginning at PATCH 2/4).
> + if (!strcmp(base_commit, "auto")) {
> + curr_branch = branch_get(NULL);
> + upstream = branch_get_upstream(curr_branch, NULL);
> + if (upstream) {
> + if (get_sha1(upstream, sha1))
> + die(_("Failed to resolve '%s' as a valid ref."), upstream);
> + base = lookup_commit_or_die(sha1, "upstream base");
> + oidcpy(&bases->base_commit, &base->object.oid);
> + } else {
> + commit_patch_id(prerequisite_head, &diffopt, sha1);
> + oidcpy(&bases->parent_commit, &prerequisite_head->object.oid);
> + hashcpy(bases->parent_patch_id.hash, sha1);
> + return;
What happens if you did this sequence?
$ git fetch origin
$ git checkout -b fork origin/master
$ git fetch origin
$ git format-patch --base=auto origin..
You grab the updated origin/master as base and use it here, no?
At that point the topology would look like:
1---2---3 updated upstream
/
0---X---Y---Z---A---B---C
^
old upstream
so you are basing your worn on "0" (old upstream) but setting base
to "3"
Wouldn't that trigger "base must be an ancestor of Z" check you had
in [PATCH 2/4]?
I also do not see the point of showing "parent id" which as far as I
can see is just a random commit object name and show different
output that is not even described what it is. It would be better to
* find the upstream (i.e. 3 in the picture) and then with our range
(i.e. A B and C) compute the merge base (i.e. you would find 0)
and use it as base;
* if there is no upstream, error out and tell the user that there
is no upstream. The user is intelligent enough and knows what
commit the base should be.
I suspect, but I didn't think things through.
next prev parent reply other threads:[~2016-03-23 18:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 8:52 [PATCH v2 0/4] Add an option to git-format-patch to record base tree info Xiaolong Ye
2016-03-23 8:52 ` [PATCH v2 1/4] patch-ids: make commit_patch_id() a public helper function Xiaolong Ye
2016-03-23 8:52 ` [PATCH v2 2/4] format-patch: add '--base' option to record base tree info Xiaolong Ye
2016-03-23 18:08 ` Junio C Hamano
2016-03-24 3:08 ` Ye Xiaolong
2016-03-23 8:52 ` [PATCH v2 3/4] format-patch: introduce --base=auto option Xiaolong Ye
2016-03-23 18:25 ` Junio C Hamano [this message]
2016-03-24 4:19 ` Ye Xiaolong
2016-03-24 17:01 ` Junio C Hamano
2016-04-01 5:07 ` Ye Xiaolong
2016-04-01 16:36 ` Junio C Hamano
2016-03-23 8:52 ` [PATCH v2 4/4] format-patch: introduce format.base configuration Xiaolong Ye
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqbn65caqi.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.