git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "Jose Ivan B. Vilarouca Filho" <joseivan@lavid.ufpb.br>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH] Fixing segmentation fault when merging FETCH_HEAD
Date: Sat, 19 Mar 2016 21:23:43 -0400	[thread overview]
Message-ID: <CAPig+cRVtzLjKTW7FZ-h8thEXkTqBJtbSwpKJs3+wdRHYV1qrQ@mail.gmail.com> (raw)
In-Reply-To: <1458411460-26146-1-git-send-email-joseivan@lavid.ufpb.br>

On Sat, Mar 19, 2016 at 2:17 PM, Jose Ivan B. Vilarouca Filho
<joseivan@lavid.ufpb.br> wrote:
> From: "Jose Ivan B. Vilarouca Filho" <joseivan@lavid.ufpb.br>

You can drop this line since it is the same as the From: line in the
email envelope.

> Fixing segmentation fault when merging FETCH_HEAD

Alternate:

    merge: don't dereference NULL pointer

> A segmentaion fault is raised when trying to merge FETCH_HEAD
> formed only by "not-for-merge" refs.
>
> Ex:
>     git init .
>     git remote add origin ...
>     git fetch origin
>     git merge FETCH_HEAD

Can you add a test to ensure that some future change doesn't regress
this fix? The above recipe would make a good basis for the new test.

> Signed-off-by: Jose Ivan B. Vilarouca Filho <joseivan@lavid.ufpb.br>
> ---
> diff --git a/builtin/merge.c b/builtin/merge.c
> @@ -1270,9 +1270,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>                             "an empty head"));
>                 remoteheads = collect_parents(head_commit, &head_subsumed,
>                                               argc, argv, NULL);
> -               remote_head = remoteheads->item;
> -               if (!remote_head)
> +               if ((!remoteheads) || (!remoteheads->item))

Style: drop unnecessary parantheses

    if (!remoteheads || !remoteheads->item)

>                         die(_("%s - not something we can merge"), argv[0]);
> +               remote_head = remoteheads->item;
>                 if (remoteheads->next)
>                         die(_("Can merge only exactly one commit into empty head"));
>                 read_empty(remote_head->object.oid.hash, 0);
> --
> 1.7.10.4

  reply	other threads:[~2016-03-20  1:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-19 18:17 [PATCH] Fixing segmentation fault when merging FETCH_HEAD Jose Ivan B. Vilarouca Filho
2016-03-20  1:23 ` Eric Sunshine [this message]
2016-03-21  0:11   ` Jose Ivan B. Vilarouca Filho
2016-03-21  6:40     ` Eric Sunshine
2016-03-21 19:01     ` merge: fix NULL pointer dereference when merging nothing into void Junio C Hamano
2016-03-21 19:36       ` Eric Sunshine

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=CAPig+cRVtzLjKTW7FZ-h8thEXkTqBJtbSwpKJs3+wdRHYV1qrQ@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=joseivan@lavid.ufpb.br \
    /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).