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

git bug - merging JS / Node.js code with "git merge --squash"

From
Alexander Mills <alexander.d.mills@gmail.com>
Date
Dec 15, 2016, 07:12 UTC
Message-ID
<CA+KyZp4HzsSOghKZnKgXEXy_gqw-9oTHveDHn1eRUY-_C6_jww@mail.gmail.com>
@git-community
I am on Git git version 2.7.4

This problem is happening on Ubuntu 16.04, but the same problem was also happening when I was running on MacOS.

I am consistently seeing merge bugs, when merging between branches of a mostly Node.js project. I am seeing fairly bad merges that mangle the code in ways that seem to clearly show some sort of Git bug. Some of these merges were for files where there was likely not even a diff between the files. TBH I am no Git expert, but maybe I will learn something from this investigation.

The latest example of a mangled file is here: https://github.com/ORESoftware/suman/blob/staging/suman.conf.js

You can see some repeat code, and also there is a dangling brace which means that the file won't even "compile" with Node.js, using "$ node -c". Notice that this file was *not* a file where I recently had to manually merge code or manually fix a conflict, so I am hoping this is not obvious operator error.

Here is the script I am using to merge between branches: https://github.com/ORESoftware/suman/blob/dev/publish-suman.sh

basically it is doing the merge with this line:
git merge --squash -Xtheirs dev -m "squashing" &&

This is obviously very concerning because I can get very strange bugs that I wouldn't expect, because I just assume that merges go well if they succeed and it's hard to check for failure after that; even in a compile statically typed language it could still prove difficult.

I am doing a check to make sure all my files compile with "node -c" after the merge, but even then Git could create mangled code that would still pass a "node -c" check.

Please let me know if this is a known bug and if there is a good strategy to avoid it.

thanks!
-- 
Alexander D. Mills
(650)269-9502
alexander.d.mills@gmail.com

www.linkedin.com/pub/alexander-mills/b/7a5/418/
Next: Junio C Hamano
Message 1 of 2 in “git bug - merging JS / Node.js code with "git merge --squash"”
  1. Alexander MillsDec 15, 2016
  2. Junio C HamanoDec 15, 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.