Thread (5 messages) flat view 5 messages, 4 authors, 2021-11-13

Re: Possible merge bug

From: Michael Schiff <hidden>
Date: 2021-11-13 03:50:02

This script includes an extra new-line, turing the final change into a
2 line diff, which is caught correctly.  Modified to:
--- 8< ---
git --version --build-options

rm -rf sample
mkdir sample
cd sample
git init
echo -e "a\nb\nc" > test
git add .
git commit -m "abc"

git branch b1
git switch b1

echo -e "b\na\nc" > test
git add .
git commit -m "bac"

git switch master
git branch b2
git switch b2

echo -e "b\nc\na" > test
git add .
git commit -m "bca"

git switch master
echo "----- Merging b1 -----"
git merge b1
cat test
echo "----- Merging b2 -----"
git merge b2
echo "----- Content of test -----"
cat test
--- 8< ---
The only meaningful difference being the removal of the trailing \n
from the first echo.  Running it produces the output:

git version 2.34.0.rc0.377.g6d82a21a3b
cpu: x86_64
built from commit: 6d82a21a3b699caf378cb0f89b6b0e803fc58480
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
hint: Using 'master' as the name for the initial branch. This default
branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /Users/michaelschiff/Desktop/sample/.git/
[master (root-commit) 8d6bc12] abc
 1 file changed, 3 insertions(+)
 create mode 100644 test
Switched to branch 'b1'
[b1 b5328d8] bac
 1 file changed, 1 insertion(+), 1 deletion(-)
Switched to branch 'master'
Switched to branch 'b2'
[b2 98603f6] bca
 1 file changed, 1 insertion(+), 1 deletion(-)
Switched to branch 'master'
----- Merging b1 -----
Updating 8d6bc12..b5328d8
Fast-forward
 test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
b
a
c
----- Merging b2 -----
Auto-merging test
Merge made by the 'ort' strategy.
 test | 1 +
 1 file changed, 1 insertion(+)
----- Content of test -----
b
a
c
a



Happy to provide any other info that helps

On Thu, Nov 11, 2021 at 6:28 AM Philippe Blain
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
Hi Michael,

Le 2021-11-11 à 06:20, Saksham Mittal a écrit :
quoted
Hello there,

I wrote a small script as well that automates testing this use case as well, but I don't really know what the policy is on attachments in git, seeing as how it's my first time contributing to git.
I used the script from Saksham (slightly modified to not depend on any Git configuration)
and could not reproduce either with Git built from the same commit as you.
Maybe some setting in your ~/.gitconfig is at play ?

For the record, my edited version of the reproducer:
--- 8< ---
#!/bin/sh

export PATH="/path/to/built/git/bin-wrappers:$PATH"
export GIT_AUTHOR_NAME=J
export GIT_AUTHOR_EMAIL=j@l.com
export GIT_COMMITTER_NAME=J
export GIT_COMMITTER_EMAIL=j@l.com
export HOME=

git --version --build-options

rm -rf sample
mkdir sample
cd sample
git init
echo -e "a\nb\nc\n" > test
git add .
git commit -m "abc"

git branch b1
git switch b1

echo -e "b\na\nc" > test
git add .
git commit -m "bac"

git switch master
git branch b2
git switch b2

echo -e "b\nc\na" > test
git add .
git commit -m "bca"

git switch master
echo "----- Merging b1 -----"
git merge b1
cat test
echo "----- Merging b2 -----"
git merge b2
echo "----- Content of test -----"
cat test
--- 8< ---

Running it ends with this output:


----- Merging b1 -----
Updating 5e00de3..02910cf
Fast-forward
  test | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
b
a
c
----- Merging b2 -----
Auto-merging test
CONFLICT (content): Merge conflict in test
Automatic merge failed; fix conflicts and then commit the result.
----- Content of test -----
b
a
c
<<<<<<< HEAD
=======
a
quoted
quoted
quoted
quoted
quoted
quoted
quoted
b2

Cheers,
Philippe.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help