Skip to contentSkip to conversation

small b4 feature request

DISCUSSION Jeff Layton 3 participants 4 messages Dec 9, 2024 – Dec 11, 2024

lore
Share & tools
lore
#0 lore raw

First, let me say that I love b4. It's great for managing a patch series over time.

I often carry around the b4 commit at the base of my patch pile and end up having to rebase on top of it. It would be great to have a way to specify the b4 tracking commit symbolically to git so I could do this without having to lookup the commit ID of the b4 head:

    $ git rebase -i B4_HEAD

git recognizes HEAD, FETCH_HEAD, ORIG_HEAD, that are specified as files in the .git/ directory. Is there a way we could keep a B4_HEAD reference in there that always points to the b4 tracking commit (if there is one)?

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>
#1 lore raw
Quoted 8 lines · Jeff Layton

First, let me say that I love b4. It's great for managing a patch series over time.

I often carry around the b4 commit at the base of my patch pile and end up having to rebase on top of it. It would be great to have a way to specify the b4 tracking commit symbolically to git so I could do this without having to lookup the commit ID of the b4 head:

Quoted 7 lines
    $ git rebase -i B4_HEAD

git recognizes HEAD, FETCH_HEAD, ORIG_HEAD, that are specified as files in the .git/ directory. Is there a way we could keep a B4_HEAD reference in there that always points to the b4 tracking commit (if there is one)?

I second this idea. I've been scripting around this problem (of rebasing my b4-prep managed series) using a script - so I just call 'git reb4'.

$ cat ~/bin/git-reb4
#!/bin/bash
# git-reb4 - rebase -i --autosquash to the base commit of a patch series
# Determine the base commit using preferred methods for b4, stg, and fall
# back to the git @{upstream} as a last resort.
# try b4 first
if command -v b4 > /dev/null; then
	base="$(b4 prep --show-info 2>/dev/null | grep "^start-commit" | cut -d' ' -f2)"
	if [[ ! $base ]]; then
		# try the stg way
		if command -v stg > /dev/null; then
			base="$(stg id $(stg ser --noprefix | head -n 1)^)"
			if [[ ! $base ]]; then
				# try the git upstream
				base="$(git rev-parse "@{u}")"
			fi
		fi
	fi
fi

if [[ ! $base ]]; then
echo "couldn't determine base commit"
exit 1
fi

git rebase -i --autosquash "$base" "$@"

#2 lore raw
In reply to Jeff Layton
Quoted 2 lines · Jeff Layton

First, let me say that I love b4. It's great for managing a patch series over time.

Great to hear, thanks!

Quoted 6 lines

I often carry around the b4 commit at the base of my patch pile and end up having to rebase on top of it. It would be great to have a way to specify the b4 tracking commit symbolically to git so I could do this without having to lookup the commit ID of the b4 head:

    $ git rebase -i B4_HEAD

I'm having a hard time wrapping my head around this (pun not intended). Is the commit in question the tip of the b4 branch, or the base commit?

In either case there is already a way to obtain this information with b4, e.g.:

    b4 prep --show-info base-commit
    b4 prep --show-info end-commit
    b4 prep --show-info series-range

So, e.g. if you want to rebase one prep-managed branch on top of another, you could do [1]:

    git rebase -i $(b4 prep --show-info b4/some-branch:end-commit)

Does this do what you need, or am I misunderstanding the situation?

[1]: apparently, show-info for a non-current branch was broken in master and 0.14.y, so you'll need the latest master or stable-0.14.y.

-K

#3 lore raw
Quoted 26 lines · Konstantin Ryabitsev
Quoted 2 lines · Jeff Layton

First, let me say that I love b4. It's great for managing a patch series over time.

Great to hear, thanks!

Quoted 6 lines

I often carry around the b4 commit at the base of my patch pile and end up having to rebase on top of it. It would be great to have a way to specify the b4 tracking commit symbolically to git so I could do this without having to lookup the commit ID of the b4 head:

    $ git rebase -i B4_HEAD

I'm having a hard time wrapping my head around this (pun not intended). Is the commit in question the tip of the b4 branch, or the base commit?

In either case there is already a way to obtain this information with b4, e.g.:

    b4 prep --show-info base-commit
    b4 prep --show-info end-commit
    b4 prep --show-info series-range

So, e.g. if you want to rebase one prep-managed branch on top of another, you could do [1]:

Quoted 7 lines
    git rebase -i $(b4 prep --show-info b4/some-branch:end-commit)

Does this do what you need, or am I misunderstanding the situation?

[1]: apparently, show-info for a non-current branch was broken in master and 0.14.y, so you'll need the latest master or stable-0.14.y.

That does help.

I was thinking that B4_HEAD to be the empty commit at the bottom of the series-range that b4 uses to track the series. IOW:

    b4 prep --show-info series-range | cut -d'.' -f1

...but now that I look at the b4 innards, I see that there are different cover-letter tracking strategies. Maybe just using "base- commit" would be simplest. So I guess I can do what I need with:

    $ git rebase -i $(b4 prep --show-info base-commit)

It has the empty tracking commit in my setup, but I can live with that.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>