commit 9eb0b171897d7e68e5082e9c1aa1725f0cbe1bf7 from: Stefan Sperling date: Thu Aug 15 12:00:16 2019 UTC add another example commit - fb32276d3a9eede1bd78e2c5b45e19c1ee0b4107 commit + 9eb0b171897d7e68e5082e9c1aa1725f0cbe1bf7 blob - 159bc4745c9b779882243571b02e971434cf9a29 blob + 420ff0884f0583e034104399aef06276acf25a09 --- examples.html +++ examples.html @@ -25,6 +25,7 @@ available both in the installed system and + Comitting changes selectively
Amending the latest commit
Using got(1) with ports tree @@ -33,6 +34,248 @@ available both in the installed system and


+

+ +

+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. + +

+Consider the following diff, which contains a workaroud (disable MIMO) +for a fictional bug in the iwm(4) driver. +This workaround sits between two temporary debug message: + +

+$ got diff
+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;
+ }
+
+ +

+Got offers several ways of committing this workaround in isolation. + +

+One possibility is to stage the desired change with got stage: + +

+$ got stage -p
+-----------------------------------------------
+@@ -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] n
+-----------------------------------------------
+@@ -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] y
+-----------------------------------------------
+@@ -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] q
+$ 
+
+ +The staged change can be seen with got status and got diff: + +
+$ got status
+MM sys/dev/pci/if_iwm.c
+$ got diff -s
+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);
+$
+
+ + +The debug message changes are no longer necessary and can reverted: +
+$ got revert sys/dev/pci/if_iwm.c
+R  sys/dev/pci/if_iwm.c
+$ got status
+ M sys/dev/pci/if_iwm.c
+
+ +To commit the staged change, run got commit as usual: + +
+$ got commit -m "disable MIMO for now to work around a crash reported on bugs@"
+
+ +

+A second possibility is to revert all debug message changes with +got revert: + +

+$ got revert -p 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");
+
+-----------------------------------------------
+M  sys/dev/pci/if_iwm.c (change 1 of 4)
+revert this change? [y/n/q] y
+-----------------------------------------------
+@@ -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] n
+-----------------------------------------------
+@@ -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] y
+-----------------------------------------------
+@@ -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] y
+$
+
+ +This leaves us with the workaround as our only local change we can commit: + +
+$ got diff
+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);
+$
+