Page MenuHomeFreeBSD

git-arc: Add patch -b option
Needs ReviewPublic

Authored by jrm on Tue, Dec 2, 12:42 AM.

Details

Reviewers
jhb
markj
Summary

The new -b option is used to create a new branch for each Differential
revision, rather than the default behavior of applying changes to the
currently checked-out branch.

While here, fix a check to determine whether arc patch ran
successfully.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69019
Build 65902: arc lint + arc unit

Event Timeline

jrm requested review of this revision.Tue, Dec 2, 12:42 AM
tools/tools/git/git-arc.sh
652

To elaborate on why this was changed, the $? was referring to the echo line above.

Another tweak to the usage text.

tools/tools/git/git-arc.sh
685–687

What happens if I specify multiple revisions which are linked together in a stack, such that each patch must be applied on top of the previous patch?

tools/tools/git/git-arc.sh
685–687

A branch is created for each revision. An example can be found in the stack at https://reviews.freebsd.org/D53679.

% git branch -l
  admin
* main

% git arc patch -bc D53679 D53788 D53680 D53789 D53681
Created and checked out branch arcpatch-D53679.
Checking patch net/wifi-firmware-kmod/Makefile.inc...
Applied patch net/wifi-firmware-kmod/Makefile.inc cleanly.
 APPLIED  Successfully applied patch.
Applying D53679...
[arcpatch-D53679 c84ee4d33081] net/wifi-firmware-kmod: remove obsolete kernel module build code
 Author: Bjoern A. Zeeb <bz@FreeBSD.org>
 1 file changed, 13 insertions(+), 43 deletions(-)
 INFO  Base commit is not in local repository; trying to fetch.
Created and checked out branch arcpatch-D53788.
Checking patch net/wifi-firmware-mt7601u-kmod/Makefile...
Checking patch net/wifi-firmware-kmod/Makefile.inc...
Applied patch net/wifi-firmware-mt7601u-kmod/Makefile cleanly.
Applied patch net/wifi-firmware-kmod/Makefile.inc cleanly.
 APPLIED  Successfully applied patch.
Applying D53788...
[arcpatch-D53788 c3309905f0d1] net/wifi-firmware-kmod: allow ONLY_FOR_ARCHS to be set by child ports
 Author: Bjoern A. Zeeb <bz@FreeBSD.org>
 2 files changed, 5 insertions(+), 1 deletion(-)
 INFO  Base commit is not in local repository; trying to fetch.
Created and checked out branch arcpatch-D53680.
Checking patch net/wifi-firmware-kmod/Makefile.inc...
Applied patch net/wifi-firmware-kmod/Makefile.inc cleanly.
 APPLIED  Successfully applied patch.
Applying D53680...
[arcpatch-D53680 140c5edea207] net/wifi-firmware-kmod: add STRIP_FWSUBDIR logic
 Author: Bjoern A. Zeeb <bz@FreeBSD.org>
 1 file changed, 3 insertions(+), 3 deletions(-)
 INFO  Base commit is not in local repository; trying to fetch.
Created and checked out branch arcpatch-D53789.
Checking patch net/wifi-firmware-kmod/Makefile.inc...
Checking patch net/wifi-firmware-iwlwifi-kmod/Makefile...
Applied patch net/wifi-firmware-kmod/Makefile.inc cleanly.
Applied patch net/wifi-firmware-iwlwifi-kmod/Makefile cleanly.
 APPLIED  Successfully applied patch.
Applying D53789...
[arcpatch-D53789 3ef215e1e23f] net/wifi-firmware-kmod: generalize iwlwifi specific tunable writing
 Author: Bjoern A. Zeeb <bz@FreeBSD.org>
 2 files changed, 11 insertions(+), 8 deletions(-)
 INFO  Base commit is not in local repository; trying to fetch.
Created and checked out branch arcpatch-D53681.
Checking patch net/wifi-firmware-iwlwifi-kmod/pkg-descr...
Checking patch net/wifi-firmware-iwlwifi-kmod/files/extract-fw-list.sh...
Checking patch net/wifi-firmware-iwlwifi-kmod/distinfo...
Checking patch net/wifi-firmware-iwlwifi-kmod/Makefile...
Applied patch net/wifi-firmware-iwlwifi-kmod/pkg-descr cleanly.
Applied patch net/wifi-firmware-iwlwifi-kmod/files/extract-fw-list.sh cleanly.
Applied patch net/wifi-firmware-iwlwifi-kmod/distinfo cleanly.
Applied patch net/wifi-firmware-iwlwifi-kmod/Makefile cleanly.
 APPLIED  Successfully applied patch.
Applying D53681...
[arcpatch-D53681 fc5b780e310d] net/wifi-firmware-iwlwifi-kmod: update firmware to 20251021
 Author: Bjoern A. Zeeb <bz@FreeBSD.org>
 4 files changed, 404 insertions(+), 144 deletions(-)
 create mode 100644 net/wifi-firmware-iwlwifi-kmod/files/extract-fw-list.sh

jrm@asn /usr/ports [arcpatch-D53681|✔] % git log --oneline -n6
fc5b780e310d (HEAD -> arcpatch-D53681) net/wifi-firmware-iwlwifi-kmod: update firmware to 20251021
3ef215e1e23f (arcpatch-D53789) net/wifi-firmware-kmod: generalize iwlwifi specific tunable writing
140c5edea207 (arcpatch-D53680) net/wifi-firmware-kmod: add STRIP_FWSUBDIR logic
c3309905f0d1 (arcpatch-D53788) net/wifi-firmware-kmod: allow ONLY_FOR_ARCHS to be set by child ports
c84ee4d33081 (arcpatch-D53679) net/wifi-firmware-kmod: remove obsolete kernel module build code
4f313c8fd2f4 archivers/zstd: remove lz4, fix manpages

% git checkout arcpatch-D53679
Switched to branch 'arcpatch-D53679'

% git log --oneline -n2
c84ee4d33081 (HEAD -> arcpatch-D53679) net/wifi-firmware-kmod: remove obsolete kernel module build code
4f313c8fd2f4 archivers/zstd: remove lz4, fix manpages

To be explicit, the arcpatch-D53679 has one new commit, and the arcpatch-D53681 branch has five new commits.

Notes:

  • The order of the revisions supplied on the command line matches the order they are applied by git.
  • If -b is supplied without -c, all the changes will be staged, and there will still be a branch for each revision. This probably isn't what anyone would want, so we could error out if -b is supplied but -c is not.
This revision is now accepted and ready to land.Tue, Dec 2, 8:37 PM

Is it possible to create a branch for the whole chain somehow?

In D54024#1234618, @imp wrote:

Is it possible to create a branch for the whole chain somehow?

I assume by "chain" you mean a stack where each revision depends on the next (D2 -> D3 -> D4...). With arc patch, you can pull the whole stack into one branch by specifying only the last revision (as long as --skip-dependencies isn't supplied).

We have a couple of ways to handle this in git arc:

  • Let arc patch do the work: The user gives the last revision, and it applies the entire stack. The downside is we can't use our patch_commit function, which gives nicer commit logs.
  • Create the branch ourselves: We handle branch creation manually. The downside here is the user would have to specify every revision, because we can't rely on arc patch's dependency logic.

So it's possible, but it's a trade-off between convenience (one command) and nicer logs / more control.

My conclusions were based on reading the arcanist documentation for arc patch. I could dig more deeply to see if there is a way to retrieve, e.g., dependency data from acranist/Phabricator a different way.

Address @imp's request.

% git branch -l
    admin
  * main

% git arc patch -bc D53679 D53788
Switched to a new branch 'gitarc-D53679-D53788'
Checking patch net/wifi-firmware-kmod/Makefile.inc...
Applied patch net/wifi-firmware-kmod/Makefile.inc cleanly.
 APPLIED  Successfully applied patch.
Applying D53679...
[gitarc-D53679-D53788 44f85c22b048] net/wifi-firmware-kmod: remove obsolete kernel module build code
 Author: Bjoern A. Zeeb <bz@FreeBSD.org>
 1 file changed, 13 insertions(+), 43 deletions(-)
 INFO  Base commit is not in local repository; trying to fetch.
Checking patch net/wifi-firmware-mt7601u-kmod/Makefile...
Checking patch net/wifi-firmware-kmod/Makefile.inc...
Applied patch net/wifi-firmware-mt7601u-kmod/Makefile cleanly.
Applied patch net/wifi-firmware-kmod/Makefile.inc cleanly.
 APPLIED  Successfully applied patch.
Applying D53788...
[gitarc-D53679-D53788 97204dede883] net/wifi-firmware-kmod: allow ONLY_FOR_ARCHS to be set by child ports
 Author: Bjoern A. Zeeb <bz@FreeBSD.org>
 2 files changed, 5 insertions(+), 1 deletion(-)

% git branch -l
  admin
* gitarc-D53679-D53788
  main
This revision now requires review to proceed.Wed, Dec 3, 6:38 PM