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

Re: [PATCH] Fixing segmentation fault when merging FETCH_HEAD

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 20, 2016, 01:23 UTC
Message-ID
<CAPig+cRVtzLjKTW7FZ-h8thEXkTqBJtbSwpKJs3+wdRHYV1qrQ@mail.gmail.com>
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
Show 8 quoted lines
> 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.

Show 10 quoted lines
> 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)
Show 7 quoted lines
>                         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
Previous: Jose Ivan B. Vilarouca FilhoNext: Jose Ivan B. Vilarouca Filho
Message 2 of 6 in “Fixing segmentation fault when merging FETCH_HEAD”
  1. Fixing segmentation fault when merging FETCH_HEADJose Ivan B. Vilarouca Filho, Mar 19, 2016
  2. Eric SunshineMar 20, 2016
  3. Jose Ivan B. Vilarouca FilhoMar 21, 2016
  4. Eric SunshineMar 21, 2016
  5. merge: fix NULL pointer dereference when merging nothing into voidJunio C Hamano, Mar 21, 2016
  6. Eric SunshineMar 21, 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.