1.5 Selecciona tu punto de partida

El libro se puede descargar aquí

1.5.1 Ejemplo 5

Desde el repo de git, hagan checkout 4a12f89865 y mezclen aaf633c2ad. 30.

Listing 1.80:Ejemplo 5 - CB en builtin/gc.c
686<<<<<<< HEAD 
687if (gc_write_commit_graph && 
688    write_commit_graph_reachable(get_object_directory(), 
689                                 !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
690                                 NULL)) 
691        return 1; 
692||||||| 9c9b961d7e 
693if (gc_write_commit_graph && 
694    write_commit_graph_reachable(get_object_directory(), 
695                                 !quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0, 
696                                 NULL)) 
697        return 1; 
698======= 
699prepare_repo_settings(the_repository); 
700if (the_repository->settings.gc_write_commit_graph == 1) 
701        write_commit_graph_reachable(get_object_directory(), 
702                                     !quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0, 
703                                     NULL); 
704>>>>>>> aaf633c2ad

31

Siguiendo la misma técnica que hemos venido utilizando, comencemos a trabajar desde el UB (con los marcadores, por claridad):

Listing 1.81:Ejemplo 5 - UB en CB
686<<<<<<< HEAD 
687if (gc_write_commit_graph && 
688    write_commit_graph_reachable(get_object_directory(), 
689                                 !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
690                                 NULL)) 
691        return 1; 
692||||||| 9c9b961d7e

Veamos el dML:

Listing 1.82:Ejemplo 5 - MB y LB en CB
692||||||| 9c9b961d7e 
693if (gc_write_commit_graph && 
694    write_commit_graph_reachable(get_object_directory(), 
695                                 !quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0, 
696                                 NULL)) 
697        return 1; 
698======= 
699prepare_repo_settings(the_repository); 
700if (the_repository->settings.gc_write_commit_graph == 1) 
701        write_commit_graph_reachable(get_object_directory(), 
702                                     !quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0, 
703                                     NULL); 
704>>>>>>> aaf633c2ad

dML: Una llamada a prepare_repo_settings() fue agregada (línea 699), el condicional fue modificado tal que modified so that la variable standalone gc_write_commit_graph de la línea 694 ahora es parte de un struct * en la línea 700. La llamada a write_commit_graph_reachable() originalmente usada como parte del condidional (línea 694) ahora es parte de la secciónif-true del condicional (línea 701) así que se ajustó el formato y finalmente el return fue removido (originalmente en la línea 697).

Repliquemos todos esos cambios en el UB.

Listing 1.83:example 5 - Paso 1 - insertar llamada
686<<<<<<< HEAD 
687prepare_repo_settings(the_repository); 
688if (gc_write_commit_graph && 
689    write_commit_graph_reachable(get_object_directory(), 
690                                 !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
691                                 NULL)) 
692        return 1; 
693||||||| 9c9b961d7e

Listing 1.84:Ejemplo 5 - Paso 2 - ajustar condicional
686<<<<<<< HEAD 
687prepare_repo_settings(the_repository); 
688if (the_repository->settings.gc_write_commit_graph == 1) 
689    write_commit_graph_reachable(get_object_directory(), 
690                                 !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
691                                 NULL); 
692        return 1; 
693||||||| 9c9b961d7e

Listing 1.85:Ejemplo 5 - Paso 3 - ajustar formato
686<<<<<<< HEAD 
687prepare_repo_settings(the_repository); 
688if (the_repository->settings.gc_write_commit_graph == 1) 
689        write_commit_graph_reachable(get_object_directory(), 
690                                     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
691                                     NULL); 
692        return 1; 
693||||||| 9c9b961d7e

Listing 1.86:Ejemplo 5 - Paso 4 - Remover return
686<<<<<<< HEAD 
687prepare_repo_settings(the_repository); 
688if (the_repository->settings.gc_write_commit_graph == 1) 
689        write_commit_graph_reachable(get_object_directory(), 
690                                     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
691                                     NULL); 
692||||||| 9c9b961d7e

Final result:

Listing 1.87:Ejemplo 5 - resultado final
681if (pack_garbage.nr > 0) { 
682        close_object_store(the_repository->objects); 
683        clean_pack_garbage(); 
684
685 
686prepare_repo_settings(the_repository); 
687if (the_repository->settings.gc_write_commit_graph == 1) 
688        write_commit_graph_reachable(get_object_directory(), 
689                                     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
690                                     NULL); 
691 
692if (auto_gc && too_many_loose_objects())

1.5.2 Ejemplo 5... desde el LB

En total, se hicieron 5 modificaciones sobre el UB para resolver el conflicto. Ahora bien, no hay ninguna obligación de trabajar desde el UB. Podemos trabajar desde el LB

Comencemos de nuevo:

Listing 1.88:Ejemplo 5 - LB en CB
698======= 
699prepare_repo_settings(the_repository); 
700if (the_repository->settings.gc_write_commit_graph == 1) 
701        write_commit_graph_reachable(get_object_directory(), 
702                                     !quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0, 
703                                     NULL); 
704>>>>>>> aaf633c2ad

Hagamos el análisis del dMU en esta oportunidad:

Listing 1.89:Ejemplo 5 - UB y MB en CB
686<<<<<<< HEAD 
687if (gc_write_commit_graph && 
688    write_commit_graph_reachable(get_object_directory(), 
689                                 !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
690                                 NULL)) 
691        return 1; 
692||||||| 9c9b961d7e 
693if (gc_write_commit_graph && 
694    write_commit_graph_reachable(get_object_directory(), 
695                                 !quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0, 
696                                 NULL)) 
697        return 1; 
698=======

dMU: El COMMIT_GRAPH_PROGRESS original en la línea 695 ahora es COMMIT_GRAPH_WRITE_PROGRESS en la línea 689. 32

Repliquemos los cambios en el LB:

Listing 1.90:Ejemplo 5 - Paso 1
698======= 
699prepare_repo_settings(the_repository); 
700if (the_repository->settings.gc_write_commit_graph == 1) 
701        write_commit_graph_reachable(get_object_directory(), 
702                                     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
703                                     NULL); 
704>>>>>>> aaf633c2ad

Y eso es todo! Resultado final:

Listing 1.91:Ejemplo 5 - Resultado final
681if (pack_garbage.nr > 0) { 
682        close_object_store(the_repository->objects); 
683        clean_pack_garbage(); 
684
685 
686prepare_repo_settings(the_repository); 
687if (the_repository->settings.gc_write_commit_graph == 1) 
688        write_commit_graph_reachable(get_object_directory(), 
689                                     !quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 
690                                     NULL); 
691 
692if (auto_gc && too_many_loose_objects())

Que es exactamente como la resolución que intentamos previamente. La única diferencia es que tuvimos que trabajar menos porque comenzamos desde el bloque que era más diferente con respecto al MB. Menos cambios que detectar y ejecutar... y por ende menos oportunidades de cometer un error.

Copyright 2020 Edmundo Carmona Antoranz