Commit Diff


commit - fb32276d3a9eede1bd78e2c5b45e19c1ee0b4107
commit + 9eb0b171897d7e68e5082e9c1aa1725f0cbe1bf7
blob - 159bc4745c9b779882243571b02e971434cf9a29
blob + 420ff0884f0583e034104399aef06276acf25a09
--- examples.html
+++ examples.html
@@ -25,6 +25,7 @@ available both in the installed system and
 
 <table>
  <tr>
+  <a href="#selective-commit"	>Comitting changes selectively</a><br>
   <a href="#amend"		>Amending the latest commit</a><br>
   <a href="#ports"		>Using got(1) with ports tree</a>
  </tr>
@@ -33,6 +34,248 @@ available both in the installed system and
 <p>
 <hr>
 
+<h2 id="selective-commit"><a class="permalink" href="#selective-commit">Committing changes selectively</a></h2>
+
+<p>
+Working on a bug fix will often leave behind unrelated local changes,
+such as temporary debug messages. This section explains how isolated parts
+of local changes in a work tree can be committed in such situations.
+
+<p>
+Consider the following diff, which contains a workaroud (disable MIMO)
+for a fictional bug in the <tt>iwm(4)</tt> driver.
+This workaround sits between two temporary debug message:
+
+<pre class="cmdbox">
+$ <b>got diff</b>
+diff a737ddea9a6b93fdcfad0176dad8d184b2e2138a /usr/src
+blob - 335033d21091a23511403804f09d1548b109b104
+file + sys/dev/pci/if_iwm.c
+--- sys/dev/pci/if_iwm.c
++++ sys/dev/pci/if_iwm.c
+@@ -4620,6 +4620,8 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
+ 	uint32_t status;
+ 	struct ieee80211com *ic = &sc->sc_ic;
+ 
++	printf("%s: adding node for STA %s\n", __func__, ether_sprintf(in->in_ni.ni_macaddr));
++
+ 	if (!update && (sc->sc_flags & IWM_FLAG_STA_ACTIVE))
+ 		panic("STA already added");
+ 
+@@ -4638,7 +4640,11 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
+ 	}
+ 	add_sta_cmd.add_modify = update ? 1 : 0;
+ 	add_sta_cmd.station_flags_msk
+-	    |= htole32(IWM_STA_FLG_FAT_EN_MSK | IWM_STA_FLG_MIMO_EN_MSK);
++	    |= htole32(IWM_STA_FLG_FAT_EN_MSK);
++#ifdef notyet /* FIXME: we are not yet ready for MIMO! */
++	add_sta_cmd.station_flags_msk
++	    |= htole32(IWM_STA_FLG_MIMO_EN_MSK);
++#endif
+ 	add_sta_cmd.tid_disable_tx = htole16(0xffff);
+ 	if (update)
+ 		add_sta_cmd.modify_mask |= (IWM_STA_MODIFY_TID_DISABLE_TX);
+@@ -4675,8 +4681,11 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
+ 	status = IWM_ADD_STA_SUCCESS;
+ 	err = iwm_send_cmd_pdu_status(sc, IWM_ADD_STA, sizeof(add_sta_cmd),
+ 	    &add_sta_cmd, &status);
+-	if (err == 0 && status != IWM_ADD_STA_SUCCESS)
++	if (err == 0 && status != IWM_ADD_STA_SUCCESS) {
+ 		err = EIO;
++		printf("ADD_STA_CMD failed: add_modify=%d flags=0x%x\n",
++		    add_sta_cmd.add_modify, add_sta_cmd.station_flags_msk);
++	}
+ 
+ 	return err;
+ }
+</pre>
+
+<p>
+Got offers several ways of committing this workaround in isolation.
+
+<p>
+One possibility is to stage the desired change with <tt>got stage</tt>:
+
+<pre class="cmdbox">
+$ <b>got stage -p</b>
+-----------------------------------------------
+@@ -4620,6 +4620,8 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        uint32_t status;
+        struct ieee80211com *ic = &sc->sc_ic;
+
++       printf("%s: adding node for STA %s\n", __func__, ether_sprintf(in->in_ni.ni_macaddr));
++
+        if (!update && (sc->sc_flags & IWM_FLAG_STA_ACTIVE))
+                panic("STA already added");
+
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 1 of 4)
+stage this change? [y/n/q] <b>n</b>
+-----------------------------------------------
+@@ -4638,7 +4640,11 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        }
+        add_sta_cmd.add_modify = update ? 1 : 0;
+        add_sta_cmd.station_flags_msk
+-           |= htole32(IWM_STA_FLG_FAT_EN_MSK | IWM_STA_FLG_MIMO_EN_MSK);
++           |= htole32(IWM_STA_FLG_FAT_EN_MSK);
++#ifdef notyet /* FIXME: we are not yet ready for MIMO! */
++       add_sta_cmd.station_flags_msk
++           |= htole32(IWM_STA_FLG_MIMO_EN_MSK);
++#endif
+        add_sta_cmd.tid_disable_tx = htole16(0xffff);
+        if (update)
+                add_sta_cmd.modify_mask |= (IWM_STA_MODIFY_TID_DISABLE_TX);
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 2 of 4)
+stage this change? [y/n/q] <b>y</b>
+-----------------------------------------------
+@@ -4675,7 +4681,7 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        status = IWM_ADD_STA_SUCCESS;
+        err = iwm_send_cmd_pdu_status(sc, IWM_ADD_STA, sizeof(add_sta_cmd),
+            &add_sta_cmd, &status);
+-       if (err == 0 && status != IWM_ADD_STA_SUCCESS)
++       if (err == 0 && status != IWM_ADD_STA_SUCCESS) {
+                err = EIO;
+                printf("ADD_STA_CMD failed: add_modify=%d flags=0x%x\n",
+                    add_sta_cmd.add_modify, add_sta_cmd.station_flags_msk);
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 3 of 4)
+stage this change? [y/n/q] <b>q</b>
+$ 
+</pre>
+
+The staged change can be seen with <tt>got status</tt> and <tt>got diff</tt>:
+
+<pre class="cmdbox">
+$ <b>got status</b>
+MM sys/dev/pci/if_iwm.c
+$ <b>got diff -s</b>
+diff a737ddea9a6b93fdcfad0176dad8d184b2e2138a /usr/src (staged changes)
+blob - 335033d21091a23511403804f09d1548b109b104
+blob + 7ad0ed87af5ef451beba1224ca5186906881aba5
+--- sys/dev/pci/if_iwm.c
++++ sys/dev/pci/if_iwm.c
+@@ -4638,7 +4638,11 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        }
+        add_sta_cmd.add_modify = update ? 1 : 0;
+        add_sta_cmd.station_flags_msk
+-           |= htole32(IWM_STA_FLG_FAT_EN_MSK | IWM_STA_FLG_MIMO_EN_MSK);
++           |= htole32(IWM_STA_FLG_FAT_EN_MSK);
++#ifdef notyet /* FIXME: we are not yet ready for MIMO! */
++       add_sta_cmd.station_flags_msk
++           |= htole32(IWM_STA_FLG_MIMO_EN_MSK);
++#endif
+        add_sta_cmd.tid_disable_tx = htole16(0xffff);
+        if (update)
+                add_sta_cmd.modify_mask |= (IWM_STA_MODIFY_TID_DISABLE_TX);
+$
+</pre>
+
+
+The debug message changes are no longer necessary and can reverted:
+<pre class="cmdbox">
+$ <b>got revert sys/dev/pci/if_iwm.c</b>
+R  sys/dev/pci/if_iwm.c
+$ <b>got status</b>
+ M sys/dev/pci/if_iwm.c
+</pre>
+
+To commit the staged change, run <tt>got commit</tt> as usual:
+
+<pre class="cmdbox">
+$ <b>got commit -m "disable MIMO for now to work around a crash reported on bugs@"</b>
+</pre>
+
+<p>
+A second possibility is to revert all debug message changes with
+<tt>got revert</tt>:
+
+<pre class="cmdbox">
+$ <b>got revert -p sys/dev/pci/if_iwm.c</b>
+-----------------------------------------------
+@@ -4620,6 +4620,8 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        uint32_t status;
+        struct ieee80211com *ic = &sc->sc_ic;
+
++       printf("%s: adding node for STA %s\n", __func__, ether_sprintf(in->in_ni.ni_macaddr));
++
+        if (!update && (sc->sc_flags & IWM_FLAG_STA_ACTIVE))
+                panic("STA already added");
+
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 1 of 4)
+revert this change? [y/n/q] <b>y</b>
+-----------------------------------------------
+@@ -4638,7 +4640,11 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        }
+        add_sta_cmd.add_modify = update ? 1 : 0;
+        add_sta_cmd.station_flags_msk
+-           |= htole32(IWM_STA_FLG_FAT_EN_MSK | IWM_STA_FLG_MIMO_EN_MSK);
++           |= htole32(IWM_STA_FLG_FAT_EN_MSK);
++#ifdef notyet /* FIXME: we are not yet ready for MIMO! */
++       add_sta_cmd.station_flags_msk
++           |= htole32(IWM_STA_FLG_MIMO_EN_MSK);
++#endif
+        add_sta_cmd.tid_disable_tx = htole16(0xffff);
+        if (update)
+                add_sta_cmd.modify_mask |= (IWM_STA_MODIFY_TID_DISABLE_TX);
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 2 of 4)
+revert this change? [y/n/q] <b>n</b>
+-----------------------------------------------
+@@ -4675,7 +4681,7 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        status = IWM_ADD_STA_SUCCESS;
+        err = iwm_send_cmd_pdu_status(sc, IWM_ADD_STA, sizeof(add_sta_cmd),
+            &add_sta_cmd, &status);
+-       if (err == 0 && status != IWM_ADD_STA_SUCCESS)
++       if (err == 0 && status != IWM_ADD_STA_SUCCESS) {
+                err = EIO;
+                printf("ADD_STA_CMD failed: add_modify=%d flags=0x%x\n",
+                    add_sta_cmd.add_modify, add_sta_cmd.station_flags_msk);
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 3 of 4)
+revert this change? [y/n/q] <b>y</b>
+-----------------------------------------------
+@@ -4677,6 +4683,9 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+            &add_sta_cmd, &status);
+        if (err == 0 && status != IWM_ADD_STA_SUCCESS) {
+                err = EIO;
++               printf("ADD_STA_CMD failed: add_modify=%d flags=0x%x\n",
++                   add_sta_cmd.add_modify, add_sta_cmd.station_flags_msk);
++       }
+
+        return err;
+ }
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 4 of 4)
+revert this change? [y/n/q] <b>y</b>
+$
+</pre>
+
+This leaves us with the workaround as our only local change we can commit:
+
+<pre class="cmdbox">
+$ <b>got diff</b>
+diff a737ddea9a6b93fdcfad0176dad8d184b2e2138a /usr/src
+blob - 335033d21091a23511403804f09d1548b109b104
+file + sys/dev/pci/if_iwm.c
+--- sys/dev/pci/if_iwm.c
++++ sys/dev/pci/if_iwm.c
+@@ -4638,7 +4638,11 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node
+        }
+        add_sta_cmd.add_modify = update ? 1 : 0;
+        add_sta_cmd.station_flags_msk
+-           |= htole32(IWM_STA_FLG_FAT_EN_MSK | IWM_STA_FLG_MIMO_EN_MSK);
++           |= htole32(IWM_STA_FLG_FAT_EN_MSK);
++#ifdef notyet /* FIXME: we are not yet ready for MIMO! */
++       add_sta_cmd.station_flags_msk
++           |= htole32(IWM_STA_FLG_MIMO_EN_MSK);
++#endif
+        add_sta_cmd.tid_disable_tx = htole16(0xffff);
+        if (update)
+                add_sta_cmd.modify_mask |= (IWM_STA_MODIFY_TID_DISABLE_TX);
+$
+</pre>
 <h2 id="amend"><a class="permalink" href="#rollback">Amending the latest commit</a></h2>
 
 <p>