<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ro">
	<id>http://wiki.dcae.pub.ro/index.php?action=history&amp;feed=atom&amp;title=SDPT_Lab_2</id>
	<title>SDPT Lab 2 - Revizia istoricului</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.dcae.pub.ro/index.php?action=history&amp;feed=atom&amp;title=SDPT_Lab_2"/>
	<link rel="alternate" type="text/html" href="http://wiki.dcae.pub.ro/index.php?title=SDPT_Lab_2&amp;action=history"/>
	<updated>2026-04-24T07:55:05Z</updated>
	<subtitle>Istoricul versiunilor pentru această pagină din wiki</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>http://wiki.dcae.pub.ro/index.php?title=SDPT_Lab_2&amp;diff=8282&amp;oldid=prev</id>
		<title>Rhobincu la 2 martie 2026 14:11</title>
		<link rel="alternate" type="text/html" href="http://wiki.dcae.pub.ro/index.php?title=SDPT_Lab_2&amp;diff=8282&amp;oldid=prev"/>
		<updated>2026-03-02T14:11:50Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;http://wiki.dcae.pub.ro/index.php?title=SDPT_Lab_2&amp;amp;diff=8282&amp;amp;oldid=8281&quot;&gt;Afișare diferențe&lt;/a&gt;</summary>
		<author><name>Rhobincu</name></author>
	</entry>
	<entry>
		<id>http://wiki.dcae.pub.ro/index.php?title=SDPT_Lab_2&amp;diff=8281&amp;oldid=prev</id>
		<title>Rhobincu: Pagină nouă: = Lab 2: Multi-Player Git, Merge Requests, and Conflict Resolution =  == Introduction == In Week 1, you learned how to drive Git in &quot;single-player mode.&quot; You initialized a reposito...</title>
		<link rel="alternate" type="text/html" href="http://wiki.dcae.pub.ro/index.php?title=SDPT_Lab_2&amp;diff=8281&amp;oldid=prev"/>
		<updated>2026-03-02T14:04:49Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: = Lab 2: Multi-Player Git, Merge Requests, and Conflict Resolution =  == Introduction == In Week 1, you learned how to drive Git in &amp;quot;single-player mode.&amp;quot; You initialized a reposito...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pagină nouă&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Lab 2: Multi-Player Git, Merge Requests, and Conflict Resolution =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
In Week 1, you learned how to drive Git in &amp;quot;single-player mode.&amp;quot; You initialized a repository, staged files, and pushed to your own remote server. &lt;br /&gt;
&lt;br /&gt;
Today, we switch to &amp;quot;multi-player mode.&amp;quot; Software engineering is a team sport. When multiple engineers edit the same codebase simultaneously, collisions are inevitable. By the end of this 2-hour lab, you and a partner will have:&lt;br /&gt;
# Configured a shared team repository.&lt;br /&gt;
# Enforced Trunk-Based Development by locking down the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; branch.&lt;br /&gt;
# Worked in parallel on feature branches.&lt;br /&gt;
# Intentionally caused a Git Merge Conflict.&lt;br /&gt;
# Resolved the conflict using Git commands and GitLab Merge Requests (MRs).&lt;br /&gt;
# Conducted a formal Code Review.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Requirement:&amp;#039;&amp;#039;&amp;#039; Find a partner. Decide who will be &amp;#039;&amp;#039;&amp;#039;Student A (The Maintainer)&amp;#039;&amp;#039;&amp;#039; and who will be &amp;#039;&amp;#039;&amp;#039;Student B (The Developer)&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Part 1: Team Setup and Branch Protection (20 Minutes) ==&lt;br /&gt;
We must first create a shared workspace and establish our &amp;quot;Traffic Laws&amp;quot; (Branch Protection).&lt;br /&gt;
&lt;br /&gt;
=== 1. Create the Shared Repository (Student A) ===&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Student A:&amp;#039;&amp;#039;&amp;#039; Log into GitLab and create a new blank project named &amp;lt;code&amp;gt;sdpt-lab2-collaboration&amp;lt;/code&amp;gt;. &lt;br /&gt;
* Uncheck &amp;quot;Initialize repository with a README&amp;quot;.&lt;br /&gt;
* On the left sidebar, go to &amp;#039;&amp;#039;&amp;#039;Manage&amp;#039;&amp;#039;&amp;#039; -&amp;gt; &amp;#039;&amp;#039;&amp;#039;Members&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
* Click &amp;#039;&amp;#039;&amp;#039;Invite members&amp;#039;&amp;#039;&amp;#039;. Search for &amp;#039;&amp;#039;&amp;#039;Student B&amp;#039;&amp;#039;&amp;#039; by their university email or username.&lt;br /&gt;
* Assign Student B the role of &amp;#039;&amp;#039;&amp;#039;Developer&amp;#039;&amp;#039;&amp;#039; and click Invite.&lt;br /&gt;
&lt;br /&gt;
=== 2. Enforce Branch Protection (Student A) ===&lt;br /&gt;
We are using Trunk-Based Development. The &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; branch is sacred. No one should be allowed to push broken code directly to it.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Student A:&amp;#039;&amp;#039;&amp;#039; In the project sidebar, go to &amp;#039;&amp;#039;&amp;#039;Settings&amp;#039;&amp;#039;&amp;#039; -&amp;gt; &amp;#039;&amp;#039;&amp;#039;Repository&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
* Expand the &amp;#039;&amp;#039;&amp;#039;Protected branches&amp;#039;&amp;#039;&amp;#039; section.&lt;br /&gt;
* Ensure the branch is set to &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;master&amp;lt;/code&amp;gt;).&lt;br /&gt;
* Set &amp;#039;&amp;#039;&amp;#039;Allowed to merge&amp;#039;&amp;#039;&amp;#039; to: &amp;lt;code&amp;gt;Developers + Maintainers&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Set &amp;#039;&amp;#039;&amp;#039;Allowed to push and merge&amp;#039;&amp;#039;&amp;#039; to: &amp;lt;code&amp;gt;No one&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Click &amp;#039;&amp;#039;&amp;#039;Protect&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&amp;#039;&amp;#039;(Now, the ONLY way code gets into main is through a Merge Request!)&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=== 3. Initialize the Baseline (Student A) ===&lt;br /&gt;
Student A will push the initial skeleton code so you both have a starting point.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Student A&amp;#039;s Terminal:&lt;br /&gt;
mkdir sdpt-lab2-collaboration&lt;br /&gt;
cd sdpt-lab2-collaboration&lt;br /&gt;
git init&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a file named &amp;lt;code&amp;gt;main.cpp&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void init_hardware() {&lt;br /&gt;
    // TODO: Initialize communication protocol&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;System Booting...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    init_hardware();&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commit and push:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git add main.cpp&lt;br /&gt;
git commit -m &amp;quot;Initial baseline code&amp;quot;&lt;br /&gt;
git remote add origin git@gitlab.com:&amp;lt;Student-A-Username&amp;gt;/sdpt-lab2-collaboration.git&lt;br /&gt;
git push -u origin main&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 4. Clone the Repository (Student B) ===&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Student B:&amp;#039;&amp;#039;&amp;#039; Go to Student A&amp;#039;s GitLab project page. Copy the SSH clone URL.&lt;br /&gt;
* Open your terminal and clone the shared repository to your machine:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git clone git@gitlab.com:&amp;lt;Student-A-Username&amp;gt;/sdpt-lab2-collaboration.git&lt;br /&gt;
cd sdpt-lab2-collaboration&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Part 2: Parallel Realities (30 Minutes) ==&lt;br /&gt;
Both students will now create isolated branches and attempt to implement the hardware initialization logic at the exact same time.&lt;br /&gt;
&lt;br /&gt;
=== 1. Branching Out (Both Students) ===&lt;br /&gt;
Both students must run the following commands on their own machines:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Student A runs:&lt;br /&gt;
git checkout -b feature-spi-init&lt;br /&gt;
&lt;br /&gt;
# Student B runs:&lt;br /&gt;
git checkout -b feature-i2c-init&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. Writing the Code (Both Students) ===&lt;br /&gt;
Open &amp;lt;code&amp;gt;main.cpp&amp;lt;/code&amp;gt; in your text editor. Find the &amp;lt;code&amp;gt;init_hardware()&amp;lt;/code&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Student A (SPI Logic):&amp;#039;&amp;#039;&amp;#039; Replace the TODO comment with this exact code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void init_hardware() {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Initializing SPI Bus on Port A...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Student B (I2C Logic):&amp;#039;&amp;#039;&amp;#039; Replace the TODO comment with this exact code:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void init_hardware() {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Initializing I2C Bus on Port B...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 3. Commit and Push (Both Students) ===&lt;br /&gt;
Because you are on separate branches, you can both push to the server safely.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Student A:&lt;br /&gt;
git add main.cpp&lt;br /&gt;
git commit -m &amp;quot;Add SPI hardware initialization&amp;quot;&lt;br /&gt;
git push -u origin feature-spi-init&lt;br /&gt;
&lt;br /&gt;
# Student B:&lt;br /&gt;
git add main.cpp&lt;br /&gt;
git commit -m &amp;quot;Add I2C hardware initialization&amp;quot;&lt;br /&gt;
git push -u origin feature-i2c-init&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 4. Open Merge Requests (Both Students) ===&lt;br /&gt;
* Both students: Go to the GitLab project page. &lt;br /&gt;
* You should see a blue banner saying &amp;quot;You pushed to feature-...&amp;quot;. Click &amp;#039;&amp;#039;&amp;#039;Create merge request&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
* Assign your partner as the &amp;#039;&amp;#039;&amp;#039;Reviewer&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
* Click &amp;#039;&amp;#039;&amp;#039;Create merge request&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Part 3: The Collision &amp;amp; Code Review (30 Minutes) ==&lt;br /&gt;
Right now, both Merge Requests look green and ready to merge. Git doesn&amp;#039;t know there is a problem yet. &lt;br /&gt;
&lt;br /&gt;
=== 1. Review and Merge Student A&amp;#039;s Code ===&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Student B:&amp;#039;&amp;#039;&amp;#039; Go to the Merge Requests tab and click on Student A&amp;#039;s MR (SPI init).&lt;br /&gt;
* Go to the &amp;#039;&amp;#039;&amp;#039;Changes&amp;#039;&amp;#039;&amp;#039; tab to review the code.&lt;br /&gt;
* Leave a comment on the line of code: &amp;quot;Looks good, SPI is the correct protocol.&amp;quot;&lt;br /&gt;
* Click &amp;#039;&amp;#039;&amp;#039;Approve&amp;#039;&amp;#039;&amp;#039;, then click the green &amp;#039;&amp;#039;&amp;#039;Merge&amp;#039;&amp;#039;&amp;#039; button.&lt;br /&gt;
&lt;br /&gt;
Student A&amp;#039;s code is now officially part of the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; branch! &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== 2. The Conflict Appears ===&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Student B:&amp;#039;&amp;#039;&amp;#039; Go back to the Merge Requests list and open your own MR (I2C init).&lt;br /&gt;
* You will see a glaring error: &amp;#039;&amp;#039;&amp;#039;Merge blocked: merge conflicts must be resolved.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
* &amp;#039;&amp;#039;Why did this happen?&amp;#039;&amp;#039; Both of you edited the exact same line in &amp;lt;code&amp;gt;main.cpp&amp;lt;/code&amp;gt;. Git refuses to guess whether the SPI code or the I2C code should win. A human must intervene.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Part 4: Resolving the Conflict (30 Minutes) ==&lt;br /&gt;
Student B must pull the new changes from the server and fix the conflict locally before they can merge.&lt;br /&gt;
&lt;br /&gt;
=== 1. Update the Local Main Branch (Student B) ===&lt;br /&gt;
Student B, your local machine does not know about Student A&amp;#039;s merged code yet.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Switch back to main&lt;br /&gt;
git checkout main&lt;br /&gt;
&lt;br /&gt;
# Download the latest changes from the server&lt;br /&gt;
git pull origin main&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. Rebase or Merge? (Student B) ===&lt;br /&gt;
Switch back to your feature branch. We need to integrate the new &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; into your feature branch. We will use a merge to resolve the conflict.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git checkout feature-i2c-init&lt;br /&gt;
git merge main&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git will output: &amp;lt;code&amp;gt;CONFLICT (content): Merge conflict in main.cpp. Automatic merge failed.&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 3. Fix the Code (Student B) ===&lt;br /&gt;
Open &amp;lt;code&amp;gt;main.cpp&amp;lt;/code&amp;gt; in your text editor. Git has injected markers into your code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void init_hardware() {&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Initializing I2C Bus on Port B...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
=======&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Initializing SPI Bus on Port A...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; main&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Task:&amp;#039;&amp;#039;&amp;#039; Discuss with Student A. Decide that you actually need &amp;#039;&amp;#039;both&amp;#039;&amp;#039; protocols to initialize.&lt;br /&gt;
* Delete the Git markers (&amp;lt;code&amp;gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;=======&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;) and combine the logic so it looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void init_hardware() {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Initializing SPI Bus on Port A...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Initializing I2C Bus on Port B...&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 4. Finalize the Merge (Student B) ===&lt;br /&gt;
Now that the conflict is manually fixed, tell Git it is resolved:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git add main.cpp&lt;br /&gt;
git commit -m &amp;quot;Resolve merge conflict between SPI and I2C initialization&amp;quot;&lt;br /&gt;
git push origin feature-i2c-init&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 5. Final Approval (Student A) ===&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Student A:&amp;#039;&amp;#039;&amp;#039; Go to Student B&amp;#039;s Merge Request on GitLab. &lt;br /&gt;
* Notice the conflict warning is gone. The MR is green again!&lt;br /&gt;
* Review the Changes to ensure both SPI and I2C are initialized.&lt;br /&gt;
* Click &amp;#039;&amp;#039;&amp;#039;Approve&amp;#039;&amp;#039;&amp;#039;, then click &amp;#039;&amp;#039;&amp;#039;Merge&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Lab Deliverable ==&lt;br /&gt;
To receive full credit for this week&amp;#039;s lab, both partners must call the professor or teaching assistant over to your workstation and demonstrate:&lt;br /&gt;
# The shared GitLab repository showing the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; branch with both SPI and I2C logic combined.&lt;br /&gt;
# The &amp;#039;&amp;#039;&amp;#039;Settings -&amp;gt; Repository -&amp;gt; Protected branches&amp;#039;&amp;#039;&amp;#039; screen showing that &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; cannot be pushed to directly.&lt;br /&gt;
# The &amp;#039;&amp;#039;&amp;#039;Merge Requests&amp;#039;&amp;#039;&amp;#039; tab showing two Closed/Merged MRs with review comments visible.&lt;br /&gt;
# Run &amp;lt;code&amp;gt;git log --graph --oneline&amp;lt;/code&amp;gt; on your terminal to show the visual graph of the diverging branches and the merge commit.&lt;/div&gt;</summary>
		<author><name>Rhobincu</name></author>
	</entry>
</feed>