Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[testcase notes] (need to work on) #19: rollback after rebasing #25

Open
dorawyy opened this issue Oct 16, 2017 · 0 comments
Open

[testcase notes] (need to work on) #19: rollback after rebasing #25

dorawyy opened this issue Oct 16, 2017 · 0 comments
Labels

Comments

@dorawyy
Copy link
Owner

dorawyy commented Oct 16, 2017

Feature3 branch was derived from Feature2, also git rebase was done in #17 . Based on this, test case 18 is going to test rolling back after rebasing

Scenario abstract

  • developer1 worked on two branches (Feature2 and Feature3), Feature3 was derived from Feature2;
  • after Feature3 branch was created,
    • Feature3 made several commit ( for example, all edit lineX of fileY)
    • Feature2 edit line X of fileY, 1 commit
  • now developer1 would like to merge Feature3 back to Feature2
  • however the developer would like to rebase Feature3 branch -- git rebase Feature2
  • What would happen?

1111

Results:

  • Commits on Feature3 is reapplied to the tip of Feature2 one by one
  • In this case, resolve two conflicts ( caused by Feature3 edit1 commit, and Feature3 edit2 commit)
  • NO commits created for rebasing, and git log is modified directly.
  • NO hint for conflict rising during the process

Data could be explored:

  • rebase record:
    • no visible commit in git log
    • only local records in git reflog
  • rebase conflicts record:
    • no commit in git log
    • no hint in git reflog

Detailed steps:

Step0: prep

  • create and edit test file test15 on Feature2 branch
git checkout Feature2
touch test17

# edit test17

git add test17
git commit -m "testcase17: startpoint (create file test17)"

screen shot 2017-10-16 at 9 27 21 am

screen shot 2017-10-16 at 9 27 54 am

  • sync Feature2 and Feature3
git checkout Feature3
git merge Feature2

screen shot 2017-10-16 at 9 28 22 am

  • create two new commits on Feature2 branch
    For example, re-edit test file test17 line 12 twice
git checkout Feature2

# edit test17, line 12

git add test17
git commit -m "Feature2: edit1 the file test17, line 12"

screen shot 2017-10-16 at 9 33 59 am

screen shot 2017-10-16 at 9 33 13 am

Here is the second edit:

git checkout Feature2

# edit test17, line 12

git add test17
git commit -m "Feature2: edit2 the file test17, line 12"

screen shot 2017-10-16 at 9 35 28 am

screen shot 2017-10-16 at 9 34 47 am

  • create two new commits on Feature3 branch
    For example, edit test file test17 twice
git checkout Feature3

# edit test17, line 12

git add test17
git commit -m "Feature3: edit1 the file test17, line 12"

screen shot 2017-10-16 at 9 36 15 am

screen shot 2017-10-16 at 9 36 42 am

Here is the second edit:

git checkout Feature3

# edit test17, line 12

git add test17
git commit -m "Feature3: edit2 the file test17, line 12"

screen shot 2017-10-16 at 9 37 13 am

screen shot 2017-10-16 at 9 37 38 am

Now, preparation work is done, and the project log becomes (diverge appears):
screen shot 2017-10-16 at 9 37 57 am
wechatimg275

Step1: Rebase Feature3 branch

git checkout Feature3
git rebase Feature2

Merge conflict raised here. Looking into the file /Users/dora/git-merge-conflicts-test-1/.git/rebase-apply/patch, the content is:
screen shot 2017-10-16 at 9 41 07 am
Check current working directory and index

# As can be seen, now in process to rebase branch Feature3 on the latest commit of Feature2 branch
git status

screen shot 2017-10-16 at 9 44 09 am

``` # now not in any branch, in a detached rebase status git branch ```

screen shot 2017-10-16 at 9 44 44 am

# head is at: 
git show --oneline head

screen shot 2017-10-16 at 9 45 33 am

In next step, we need to resolve the conflict.

Step2: Resolve rebase conflict

Current project status:
screen shot 2017-10-16 at 9 54 14 am

As we can see from last step, the conflict is content conflict in the file test17. Current test17 is:
( checking out Feature3 branch)
screen shot 2017-10-16 at 9 52 05 am

Modify test17 to:
screen shot 2017-10-16 at 9 53 25 am

Then, mark the rebase conflict resolved and continue rebase:

# resolve conflict
git add test17
# check status
git status

screen shot 2017-10-16 at 9 55 04 am

``` # continue rebasing git rebase --continue ```

screen shot 2017-10-16 at 9 58 43 am

The project history becomes (the Feature3 edit1 commit is already applied on tip of Feature2):
screen shot 2017-10-16 at 10 05 15 am

However, a new conflict raised - when continue rebasing. As we can see from the log here,

  • Feature3 edit1 commit is already applied (after resolving the rebase conflict);
  • Feature3 edit2 commit now raise a rebase conflict --> need to resolve.

In the next step, the developer is going to resolve the second conflict.

Step3: Resolve the second rebase conflict

First, get more details about the second conflict.

# look into the patch file 
vim /Users/dora/git-merge-conflicts-test-1/.git/rebase-apply/patch

screen shot 2017-10-16 at 10 01 22 am

# project status
git status

screen shot 2017-10-16 at 10 01 56 am

``` # check branch git branch ```

screen shot 2017-10-16 at 10 02 17 am

The conflict file is test17, current version is:
( conflict between the newly-applied Feature3 edit1 commit on tip of Feature2, and HEAD of Feature2 branch, which is Feature2 edit1 commit)
screen shot 2017-10-16 at 10 03 28 am

Now, resolve the conflict:
screen shot 2017-10-16 at 10 09 59 am

# mark conflict2 resolved
git add test17
# check current status
git status

screen shot 2017-10-16 at 10 11 16 am

``` # continue rebasing git rebase --continue # check status again git status ```

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

Now the rebase process is done, and the project history becomes:
screen shot 2017-10-16 at 10 12 52 am

The previous two commits of Feature3 branch now is rebased to the head of Feature2 branch. ( SHA changed, the old Feature3 commits are not visible in log anymore)

Here is the comparison scratch:
wechatimg276

Step4: Merge Feature2 branch forward

git checkout Feature2
git merge Feature3

screen shot 2017-10-16 at 10 20 38 am

Step5: Check git log and git reflog to explore data

  • Feature2 branch:
git checkout Feature2
git branch
git log
git reflog

screen shot 2017-10-16 at 10 21 33 am

screen shot 2017-10-16 at 10 22 35 am

  • Feature3 branch:
git checkout Feature3
git branch
git log
git reflog

screen shot 2017-10-16 at 10 23 39 am

screen shot 2017-10-16 at 10 24 16 am

As we can see,

  • the rebase is applied one by one on the tip of the base branch
  • no extra visible commit is noted down for rebasing
    • no record in git log
    • only visible in git reflog
  • no record for rebase conflict
    • no record in git log
    • no record in git reflog about conflicts
  • fast-forward merging, thus no merge commit is created
    • no record in git log
    • only visible in git reflog
@dorawyy dorawyy changed the title [testcase notes] #19: rollback after rebasing [testcase notes] (need to work on) #19: rollback after rebasing Oct 16, 2017
@dorawyy dorawyy added the rebase label Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant