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

Re: [PATCH] merge: allow fast-forward when merging a tracked tag

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Feb 15, 2018, 23:34 UTC
Message-ID
<CAPig+cSJKDH=_-hGZLpZUjC4WEyjMRAd2VPgo-Vd+sHpa4jQ-Q@mail.gmail.com>
In-Reply-To
<xmqqy3jt7ty8.fsf_-_@gitster-ct.c.googlers.com>
On Thu, Feb 15, 2018 at 5:45 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 31 quoted lines
> [...]
> Update the default (again) for "git merge" that merges a tag object
> to (1) --no-ff (i.e. create a merge commit even when side branch
> fast forwards) if the tag being merged is not at its expected place
> in refs/tags/ hierarchy and (2) --ff (i.e. allow fast-forward update
> when able) otherwise.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff --git a/builtin/merge.c b/builtin/merge.c
> @@ -1125,6 +1126,42 @@ static struct commit_list *collect_parents(struct commit *head_commit,
> +static int merging_a_throwaway_tag(struct commit *commit)
> +{
> +       const char *tag_ref;
> +       struct object_id oid;
> +
> +       /* Are we merging a tag? */
> +       if (!merge_remote_util(commit) ||
> +           !merge_remote_util(commit)->obj ||
> +           merge_remote_util(commit)->obj->type != OBJ_TAG)
> +               return 0;
> +
> +       /*
> +        * Now we know we are merging a tag object.  Are we downstream
> +        * and following the tags from upstream?  If so, we must have
> +        * the tag object pointed at by "refs/tags/$T" where $T is the
> +        * tagname recorded in the tag object.  We want to allow such
> +        * a "just to catch up" merge to fast-forward.
> +        */
> +       tag_ref = xstrfmt("refs/tags/%s",
> +                         ((struct tag *)merge_remote_util(commit)->obj)->tag);
xstrfmt() allocates a new string...
> +       if (!read_ref(tag_ref, &oid) &&
> +           !oidcmp(&oid, &merge_remote_util(commit)->obj->oid))
> +               return 0;
...which is leaked here...
Show 10 quoted lines
> +
> +       /*
> +        * Otherwise, we are playing an integrator's role, making a
> +        * merge with a throw-away tag from a contributor with
> +        * something like "git pull $contributor $signed_tag".
> +        * We want to forbid such a merge from fast-forwarding
> +        * by default; otherwise we would not keep the signature
> +        * anywhere.
> +        */
> +       return 1;
...and here.
> +}
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 15 in “Re: linux-next: unnecessary merge in the v4l-dvb tree”
  1. Linus TorvaldsFeb 12, 2018
  2. Mauro Carvalho ChehabFeb 12, 2018
  3. Junio C HamanoFeb 12, 2018
  4. Linus TorvaldsFeb 12, 2018
  5. Junio C HamanoFeb 12, 2018
  6. Linus TorvaldsFeb 12, 2018
  7. Junio C HamanoFeb 12, 2018
  8. Mauro Carvalho ChehabFeb 13, 2018
  9. Junio C HamanoFeb 13, 2018
  10. Linus TorvaldsFeb 13, 2018
  11. Junio C HamanoFeb 14, 2018
  12. merge: allow fast-forward when merging a tracked tagJunio C Hamano, Feb 15, 2018
  13. Eric SunshineFeb 15, 2018
  14. Junio C HamanoFeb 16, 2018
  15. merge: allow fast-forward when merging a tracked tagJunio C Hamano, Feb 16, 2018

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.