Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is git not complaining about merge conflict?

I have two branches in a Git repository.

* 68d0cfc (HEAD -> master) Fixed error in makefile. Command rm is now erasing main.o, too.
| * a2dcb6c (temp_branch) Temporary commit to save progress.
|/  
* c86fd55 structs trans_table_entry and trans_table created. Functions get_trans_table_available_entry, create_insert_new_trans_entry and compare_input_with_trans_key defined.
* b8ba145 structs fsm_t and state_t created. Functions create_fsm, create_new_state and set_fsm_initial_state defined

In every branch there is a main.c with different content.

This is main.c from master branch.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#include <stdio.h>
#include <stdlib.h>
#include "fsm.h"

int main(void) {    
    fsm_t *fsm = create_fsm("fsm0");
    
    state_t *q0 = create_new_state("q0", false);
    state_t *q1 = create_new_state("q1", false);
    set_fsm_initial_state(fsm, q0);
    
    printf("FSM %s\n", fsm->fsm_name);
    printf("State %s\n", q0->state_name);
    printf("State %s\n", q1->state_name);
    printf("FSM initial state %s\n", fsm->initial_state->state_name);
    
    trans_table_entry_t *trans_table_entry = create_insert_new_trans_entry(q0, "01", q1);
    printf("New trans_table_entry: \n");
    printf("    transition_key: %s\n", trans_table_entry->transition_key); 
    printf("    next_state: %s\n", trans_table_entry->next_state->state_name); 
    
    printf("trans_table_entry in fsm0's initial state: \n");
    printf("    transition_key: %s\n", STATE_ENTRY_TR_KEY(fsm->initial_state, 0));
    printf("    next_state: %s\n", STATE_ENTRY_NEXT_STATE(fsm->initial_state, 0)->state_name);
    
    char trans_key1[] = "0111";
    char trans_key2[] = "0X10";
    
    char *input = "01110010";
    printf("Comparing trans_key1(%s) with 0111: %s\n", trans_key1, compare_input_with_trans_key(input, trans_key1) == true? "Valid" : "Invalid");
    printf("Comparing trans_key2(%s) with 0111: %s\n", trans_key2, compare_input_with_trans_key(input, trans_key2) == true? "Valid" : "Invalid");
    
    input += 4;
    printf("Comparing trans_key1(%s) with 0010: %s\n", trans_key1, compare_input_with_trans_key(input, trans_key1) == true? "Valid" : "Invalid");
    printf("Comparing trans_key2(%s) with 0010: %s\n", trans_key2, compare_input_with_trans_key(input, trans_key2) == true? "Valid" : "Invalid");   

    return 0;
}

This is main from temp_branch.

#include <stdio.h>
#include <stdlib.h>
#include "fsm.h"

int main(void) {    
    fsm_t *fsm = create_fsm("0s_1s_alt");
    //Initial state. No data.
    state_t *q0 = create_new_state("q0", false);
    //Last bit received is 1. Second last is 0.
    state_t *q1 = create_new_state("q1", false);
    //Last bit received is 0. Second last is 1.
    state_t *q2 = create_new_state("q2", false);
    //Dead state.
    state_t *D = create_new_state("D", true);
    set_fsm_initial_state(fsm, q0);
    char *trans_key = "0";
    
    trans_table_entry_t *trans_table_entry = create_insert_new_trans_entry(q0, trans_key, q2);
    trans_key = "1";
    trans_table_entry = create_insert_new_trans_entry(q0, trans_key, q1);
    trans_key = "0";
    trans_table_entry = create_insert_new_trans_entry(q1, trans_key, q2);
    trans_key = "1";
    trans_table_entry = create_insert_new_trans_entry(q1, trans_key, D);
    trans_key = "0";
    trans_table_entry = create_insert_new_trans_entry(q2, trans_key, D);
    trans_key = "1";
    trans_table_entry = create_insert_new_trans_entry(q2, trans_key, q1);
    trans_key = "0";
    trans_table_entry = create_insert_new_trans_entry(D, trans_key, D);
    trans_key = "1";
    trans_table_entry = create_insert_new_trans_entry(D, trans_key, D);

    char input[] = {'0', '1', '0', '1', '0', '1', '1', '0'};
    if(execute_fsm(fsm, input) == FSM_NO_ERROR) {
        printf("%s working correctly.\n", fsm->fsm_name);
    }
    else {
        printf("An error occurred. One of the transitions was not executed.\n");
    }

    return 0;
}

I already tried using different methods

git merge temp_branch
git merge -s resolve master temp_branch

This is what I get after merging.

Merge made by the 'ort' strategy
fsm.c  | 25 +++++++++++++++++++++++++
fsm.h  |  4 ++--
main.c | 57 +++++++++++++++++++++++++++++++--------------------------
3 files changed, 58 insertions(+), 28 deletions(-)

Trying really trivial in-index merge...
fsm.c  | 25 +++++++++++++++++++++++++
fsm.h  |  4 ++--
main.c | 57 +++++++++++++++++++++++++++++++--------------------------
3 files changed, 58 insertions(+), 28 deletions(-)

But the result is the same always: Git keeps replaces the content of main.c from master with the content from temp_branch without any error.
If the contents of the two files are different, why is this happening?

>Solution :

There would be conflict only if main.c:

  • had been changed in both branches, since the temp_branch was created
  • if changes are done one common lines

If not, changes from temp_branch are reported to master.

In every branch there is a main.c with different content.

If the "different content" in main.c/master was done before temp_branch modifications, then merging temp_branch to master would simply reports those temp_branch modifications back to master.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading