dorawyy / git-merge-conflicts-test

This repo is for testing of git functionalities / different merging conflict scenarios, and CI tools usage
2 stars 4 forks source link

[testcase notes] #22: Pull request, different branches inside one repo, both commits, no conflict #38

Open dorawyy opened 6 years ago

dorawyy commented 6 years ago

PR2 branch was derived from PR1

Scenario abstract

--> Different branches inside one repo, both Alice and Bob commit (to different files)

Results:

Data could be explored:


Detailed steps:

Step0: prep

git checkout PR1
touch test22
vim test22
git add test22
git commit -m "testcase22: startpoint (create file test22 on PR1 branch)"
git push origin PR1

git checkout PR2
git merge PR1
git push origin PR2

##### Now both PR1 and PR2 are set, at the same commit, we can start the test case

Content of test22:

screen shot 2017-10-21 at 7 11 47 pm

Startpoint - project tree:

screen shot 2017-10-21 at 7 13 06 pm

Step1: Alice committed on PR2 , pushed back to remote

git checkout PR2
vim test22
# edit test22, line 14

git add test22
git commit -m "PR2: edited the file test 22, line 14"

git push origin PR2

The edit on the file test22 is:

screen shot 2017-10-21 at 7 14 20 pm

After git push origin PR2, here is the project status:

screen shot 2017-10-21 at 7 14 49 pm

Step2: Bob committed on PR1 , pushed back to remote

git checkout PR1
touch test22-PR1
# edit test22-PR1

git add test22-PR1
git commit -m "PR1: edited the file test22-PR1"

git push origin PR1

The edit on the file test22-PR1 from PR1 is:

screen shot 2017-10-21 at 7 17 30 pm

After git push origin PR1, the two branches diverge, here is the status of PR1:

screen shot 2017-10-21 at 7 18 00 pm

Here is the status of the whole project:

screen shot 2017-10-21 at 7 19 07 pm

Step3: Alice made a pull request to merge PR1(base) and PR2 (head)

This is the page that Alice will see when she create a new pull request:

screen shot 2017-10-21 at 7 23 04 pm

Here are details of the pull request, created by Alice ( pull request: #37 ):

screen shot 2017-10-21 at 7 30 17 pm screen shot 2017-10-21 at 7 30 28 pm

Step4: Alice work is done, now Bob's turn. He needs to decide what to do with the pull request.


Option1: Create a merge commit

All commits from this branch (PR2 in this case) will be added to the base branch via a merge commit.

Bob chose to merge pull request

screen shot 2017-10-21 at 7 32 39 pm

Bob filled in info when merge pull request

screen shot 2017-10-21 at 7 34 17 pm

Then the pull request is done

screen shot 2017-10-21 at 7 34 53 pm

Check PR1 and PR2 commit history

History of PR1 branch:

screen shot 2017-10-21 at 7 36 04 pm

History of PR2 branch:

screen shot 2017-10-21 at 7 41 11 pm

Observations:

Details of the merge commit is:

screen shot 2017-10-21 at 7 42 57 pm

Pull PR1 and PR2 to local again, merge, then push back to remote

git checkout PR1
git pull origin PR1

git checkout PR2
git pull origin PR2
git merge PR1
git push origin PR2

The project status becomes:

screen shot 2017-10-21 at 7 46 50 pm


Exploring question: Does commit order matters?

Answer: no, commit order not matter.

Scenario abstract

--> Different branches inside one repo, both Alice and Bob commit (to different files)

Results:

Data could be explored:


Detailed steps:

Step0: prep

git checkout PR1
touch test22_order_test
vim test22_order_test
git add test22_order_test
git commit -m "testcase22-order-test: startpoint (create file test22_order_test on PR1 branch)"
git push origin PR1

git checkout PR2
git merge PR1
git push origin PR2

##### Now both PR1 and PR2 are set, at the same commit, we can start the test case

Content of test22_order_test:

screen shot 2017-10-21 at 8 01 51 pm

Startpoint - project tree:

screen shot 2017-10-21 at 8 02 43 pm

Step1: Bob committed on PR1 , pushed back to remote

git checkout PR1
touch test22_order_test-PR1
# edit test22_order_test-PR1

git add test22_order_test-PR1
git commit -m "PR1: edited the file test22_order_test-PR1"

git push origin PR1

The edit on the file test22_order_test-PR1 from PR1 is:

screen shot 2017-10-21 at 8 03 31 pm

After git push origin PR1, the project status is:

screen shot 2017-10-21 at 8 04 06 pm

Step2: Alice committed on PR2 , pushed back to remote

git checkout PR2
vim test22_order_test
# edit test22_order_test, line 16

git add test22_order_test
git commit -m "PR2: edited the file test22_order_test, line 16"

git push origin PR2

The edit on the file test22 is:

screen shot 2017-10-21 at 8 04 59 pm

After git push origin PR2, the two branches diverge, here is the status of PR2:

screen shot 2017-10-21 at 8 05 42 pm

Here is the status of the whole project:

screen shot 2017-10-21 at 8 05 56 pm

Step3: Alice made a pull request to merge PR1(base) and PR2 (head)

This is the page that Alice will see when she create a new pull request:

screen shot 2017-10-21 at 8 06 51 pm

Here are details of the pull request, created by Alice ( pull request: # ):

screen shot 2017-10-21 at 8 09 15 pm screen shot 2017-10-21 at 8 09 40 pm

Step4: Alice work is done, now Bob's turn. He needs to decide what to do with the pull request.


Option1: Create a merge commit

All commits from this branch (PR2 in this case) will be added to the base branch via a merge commit.

Bob chose to merge pull request

screen shot 2017-10-21 at 8 10 31 pm

Bob filled in info when merge pull request

screen shot 2017-10-21 at 8 11 27 pm

Then the pull request is done

screen shot 2017-10-21 at 8 11 53 pm

Check PR1 and PR2 commit history

History of PR1 branch:

screen shot 2017-10-21 at 8 12 22 pm

History of PR2 branch:

screen shot 2017-10-21 at 8 15 41 pm

Observations:

Details of the merge commit is:

screen shot 2017-10-21 at 8 16 28 pm

Make a pull request the other way round

git checkout PR1
git pull origin PR1

git checkout PR2
git pull origin PR2
git merge PR1

git push origin PR2

The project status becomes:

screen shot 2017-10-21 at 9 52 24 pm
dorawyy commented 6 years ago

PR2 branch was derived from PR1

Option2: squash commits then merge

Scenario abstract

--> Different branches inside one repo, both Alice and Bob commit (to different files)

Results:

Data could be explored:


Detailed steps:

Step0: prep

git checkout PR1
touch test22_option2
vim test22_option2
git add test22_option2
git commit -m "testcase22_option2: startpoint (create file test22_option2 on PR1 branch)"
git push origin PR1

git checkout PR2
git merge PR1
git push origin PR2

##### Now both PR1 and PR2 are set, at the same commit, we can start the test case

Content of test22_option2:

screen shot 2017-10-21 at 10 00 38 pm

Startpoint - project tree:

screen shot 2017-10-21 at 10 01 36 pm

Step1: Alice committed on PR2 , pushed back to remote

git checkout PR2
vim test22_option2
# edit test22_option2, line 14

git add test22_option2
git commit -m "PR2: edited the file test22_option2, line 14"

git push origin PR2

The edit on the file test22_option2 is:

screen shot 2017-10-21 at 10 02 17 pm

After git push origin PR2, here is the project status:

screen shot 2017-10-21 at 10 02 50 pm

Step2: Bob committed on PR1 , pushed back to remote

git checkout PR1
touch test22_option2-PR1
# edit test22_option2-PR1

git add test22_option2-PR1
git commit -m "PR1: edited the file test22_option2-PR1"

git push origin PR1

The edit on the file test22_option2-PR1 from PR1 is:

screen shot 2017-10-21 at 10 04 16 pm

After git push origin PR1, the two branches diverge, here is the status of PR1:

screen shot 2017-10-21 at 10 04 58 pm

Here is the status of the whole project:

screen shot 2017-10-21 at 10 05 09 pm

Step3: Alice made a pull request to merge PR1(base) and PR2 (head)

This is the page that Alice will see when she create a new pull request:

screen shot 2017-10-21 at 10 06 04 pm

Here are details of the pull request, created by Alice (pull request #43 ):

screen shot 2017-10-21 at 10 10 03 pm screen shot 2017-10-21 at 10 10 14 pm

Step4: Alice work is done, now Bob's turn. He needs to decide what to do with the pull request.


Option2: Squash commits and merge

step1: Bob chose to squash commits and merge

screen shot 2017-10-21 at 10 10 41 pm

step2: Bob filled in info when squash commits and merge

screen shot 2017-10-21 at 10 12 58 pm

Then the pull request is done

screen shot 2017-10-21 at 10 13 16 pm

step3: Check PR1 and PR2 commit history

History of PR1 branch:

screen shot 2017-10-21 at 10 14 09 pm

History of PR2 branch:

screen shot 2017-10-21 at 10 15 32 pm

Observations:

Here is the details of the squashed commit on the base branch (PR1 in this case)

screen shot 2017-10-21 at 10 16 36 pm

step4: Pull PR1 and PR2 to local again, merge, then push back to remote

git checkout PR1
git pull origin PR1

git checkout PR2
git pull origin PR2

# check tree first 

The two branch still diverge ( according to the project status):

screen shot 2017-10-21 at 10 22 59 pm

step5: Create a pull request (PR1 --> PR2 vs. PR2 --> PR1 )

( try option3 - rebase and merge) --> to see if enabled or any conflicts?

(1) create a pull request: PR1(head) --> PR2(base) (pull request: #44 )
screen shot 2017-10-21 at 10 28 00 pm

Details of the content is: (include two commits on PR1)

screen shot 2017-10-21 at 10 31 19 pm

Rebasing is enabled

screen shot 2017-10-21 at 10 32 59 pm
(2) create a pull request: PR2(head) --> PR1(base) (pull request: #45 )
screen shot 2017-10-21 at 10 34 51 pm

Details of the content is: (include two commits on PR1)

screen shot 2017-10-21 at 10 36 37 pm

Rebasing is enabled

screen shot 2017-10-21 at 10 36 52 pm

step6: Try the pull request PR1(head) --> PR2(base) (pull request: #44 ), choose to rebasing

( suppose PR2 has new commits)

screen shot 2017-10-21 at 10 40 39 pm screen shot 2017-10-21 at 10 40 48 pm screen shot 2017-10-21 at 10 40 59 pm

step7: Check commits of PR1 and PR2

PR1 ( no change) :

screen shot 2017-10-21 at 10 46 28 pm screen shot 2017-10-21 at 10 47 42 pm

The rebase commit (on PR2) details are ( a normal commit):

screen shot 2017-10-21 at 10 45 31 pm

step8: Pull changes to local to check project status

Still diverge, but pull changes to local to check project status;

# pull PR1
git checkout PR1
git pull origin PR1

After fetching all commits from PR1, the PR1 branch status becomes:

screen shot 2017-10-21 at 10 55 08 pm
# pull PR2
git checkout PR2
git pull origin PR2

After fetching all commits from PR2, the PR2 branch status becomes:

screen shot 2017-10-21 at 10 57 52 pm

The project status is:

screen shot 2017-10-21 at 11 00 10 pm

step9: Manually fixing the divergence

git checkout PR1
git merge PR2
# should be a three-way merge, while no conflict

git push origin PR1

Automatic three-way merging:

screen shot 2017-10-21 at 11 02 11 pm

Now the project status becomes:

screen shot 2017-10-21 at 11 03 27 pm
git checkout PR2
git merge PR1
# should be a fast-forward merge

git push origin PR2

Fast-forward merging:

screen shot 2017-10-21 at 11 04 25 pm

Now the project status becomes, all synced:

screen shot 2017-10-21 at 11 04 05 pm
dorawyy commented 6 years ago

,PR2 branch was derived from PR1

Option3: rebase and merge

Scenario abstract

--> Different branches inside one repo, both Alice and Bob commit (to different files)

Results:

Data could be explored:


Detailed steps:

Step0: prep

git checkout PR1
touch test22_option3
vim test22_option3
git add test22_option3
git commit -m "testcase22_option3: startpoint (create file test22_option3 on PR1 branch)"
git push origin PR1

git checkout PR2
git merge PR1
git push origin PR2

##### Now both PR1 and PR2 are set, at the same commit, we can start the test case

Content of test22_option3:

screen shot 2017-10-21 at 11 16 05 pm

Startpoint - project tree:

screen shot 2017-10-21 at 11 17 20 pm

Step1: Alice committed on PR2 , pushed back to remote

git checkout PR2
vim test22_option3
# edit test22_option3, line 14

git add test22_option3
git commit -m "PR2: edited the file test22_option3, line 14"

git push origin PR2

The edit on the file test22_option3 is:

screen shot 2017-10-21 at 11 17 58 pm

After git push origin PR2, here is the project status:

screen shot 2017-10-21 at 11 18 30 pm

Step2: Bob committed on PR1 , pushed back to remote

git checkout PR1
touch test22_option3-PR1
# edit test22_option3-PR1

git add test22_option3-PR1
git commit -m "PR1: edited the file test22_option3-PR1"

git push origin PR1

The edit on the file test22_option3-PR1 from PR1 is:

screen shot 2017-10-21 at 11 19 45 pm

After git push origin PR1, the two branches diverge, here is the status of PR1:

screen shot 2017-10-21 at 11 20 20 pm

Here is the status of the whole project:

screen shot 2017-10-21 at 11 20 37 pm

Step3: Alice made a pull request to merge PR1(base) and PR2 (head)

This is the page that Alice will see when she create a new pull request:

screen shot 2017-10-21 at 11 21 13 pm

Here are details of the pull request, created by Alice (pull request ):

screen shot 2017-10-21 at 11 23 31 pm screen shot 2017-10-21 at 11 23 43 pm screen shot 2017-10-21 at 11 23 54 pm

Step4: Alice work is done, now Bob's turn. He needs to decide what to do with the pull request.


Option3: Rebase then merge

step1: Bob chose to rebase then merge

screen shot 2017-10-21 at 11 24 37 pm screen shot 2017-10-21 at 11 24 54 pm

When rebasing is done:

screen shot 2017-10-21 at 11 25 54 pm

step3: Check PR1 and PR2 commit history

History of PR1 branch:

screen shot 2017-10-21 at 11 26 35 pm

History of PR2 branch:

screen shot 2017-10-21 at 11 26 51 pm

Observations:

Here is the details of the rebase commit on the base branch (PR2 in this case)

screen shot 2017-10-21 at 11 32 47 pm

step4: Pull PR1 and PR2 to local. check project status

git checkout PR1
git pull origin PR1

git checkout PR2
git pull origin PR2

# check tree first 

The two branch still diverge ( according to the project status):

screen shot 2017-10-21 at 11 34 09 pm

step5: Create a pull request (PR1 --> PR2 vs. PR2 --> PR1 ) again

( try option3 - rebase and merge) --> to see if enabled or any conflicts?

(1) create a pull request: PR1(head) --> PR2(base) (pull request: #50 )
screen shot 2017-10-21 at 11 37 56 pm

Details of the pull request is: (include two commits on PR1):

screen shot 2017-10-21 at 11 46 01 pm

Rebasing is enabled

screen shot 2017-10-21 at 11 42 08 pm
(2) create a pull request: PR2(head) --> PR1(base) (pull request: #52 )
screen shot 2017-10-21 at 11 43 37 pm

Details of the content is: (include one commit on PR2)

screen shot 2017-10-21 at 11 48 24 pm

Rebasing is enabled

screen shot 2017-10-21 at 11 50 03 pm

step6: Try the pull request (2) PR2(head) --> PR1(base) (pull request: #52 ), choose to rebasing

( suppose PR1 will have new commits)

screen shot 2017-10-21 at 11 51 39 pm screen shot 2017-10-21 at 11 51 45 pm screen shot 2017-10-21 at 11 51 57 pm

The details about the merge commit is ( actually no new commit is created, this is the last rebase commit) :

screen shot 2017-10-21 at 11 52 08 pm

step7: Try the pull request (1) PR1(head) --> PR2(base) (pull request: #50 ), choose to rebasing

( suppose PR2 will have new commits)

screen shot 2017-10-22 at 12 02 04 am screen shot 2017-10-22 at 12 05 20 am screen shot 2017-10-22 at 12 05 28 am

step8: Check commits of PR1 and PR2

screen shot 2017-10-22 at 12 06 58 am screen shot 2017-10-22 at 12 08 23 am

The rebase commit (on PR1) details are ( a normal commit):

screen shot 2017-10-22 at 12 13 15 am

step8: Pull changes to local to check project status

Still diverge, but pull changes to local to check project status;

# pull PR1
git checkout PR1
git pull origin PR1

After fetching all commits from PR1, the PR1 branch status becomes:

screen shot 2017-10-22 at 12 14 25 am
# pull PR2
git checkout PR2
git pull origin PR2

After fetching all commits from PR2, the PR2 branch status becomes:

screen shot 2017-10-22 at 12 15 00 am

The project status is (divergence goes further and further):

screen shot 2017-10-22 at 12 15 19 am

step9: Manually fixing the divergence

git checkout PR1
git merge PR2
# should be a three-way merge, while no conflict

git push origin PR1

Automatic three-way merging:

screen shot 2017-10-22 at 12 16 00 am

Now the project status becomes:

screen shot 2017-10-22 at 12 16 36 am
git checkout PR2
git merge PR1
# should be a fast-forward merge

git push origin PR2

Fast-forward merging:

screen shot 2017-10-22 at 12 17 06 am

Now the project status becomes, all synced:

screen shot 2017-10-22 at 12 17 28 am