git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/4] format-patch: introduce --base=auto option

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 23, 2016, 18:25 UTC
Message-ID
<xmqqbn65caqi.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1458723147-7335-4-git-send-email-xiaolong.ye@intel.com>
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).

Show 13 quoted lines
> +	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.
Previous: Xiaolong YeNext: Ye Xiaolong
Message 7 of 12 in “Add an option to git-format-patch to record base tree info”
  1. 0/4 Add an option to git-format-patch to record base tree infoXiaolong Ye, Mar 23, 2016
  2. 1/4 patch-ids: make commit_patch_id() a public helper functionXiaolong Ye, Mar 23, 2016
  3. 2/4 format-patch: add '--base' option to record base tree infoXiaolong Ye, Mar 23, 2016
  4. Junio C HamanoMar 23, 2016
  5. Ye XiaolongMar 24, 2016
  6. 3/4 format-patch: introduce --base=auto optionXiaolong Ye, Mar 23, 2016
  7. Junio C HamanoMar 23, 2016
  8. Ye XiaolongMar 24, 2016
  9. Junio C HamanoMar 24, 2016
  10. Ye XiaolongApr 1, 2016
  11. Junio C HamanoApr 1, 2016
  12. 4/4 format-patch: introduce format.base configurationXiaolong Ye, Mar 23, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.