Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tig: add subcommand to browse an umpf and its context interactively #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rohieb
Copy link
Contributor

@rohieb rohieb commented Apr 17, 2024

The 'tig' subcommand makes it possible to browse an umpf interactively while showing the local and remote state of all topic branches. This can give an overview how the topic branches have developed before building another umpf.

For simplicity sake, also limit the range of the topics to the history leading up from the umpf-base.

The 'tig' subcommand makes it possible to browse an umpf interactively
in tig(1) while showing the local and remote state of all topic
branches. This can give a broader overview how the topic branches have
developed before building another umpf.

For simplicity sake, also limit the range of the topics to the history
leading up from the umpf-base.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
Copy link
Member

@michaelolbrich michaelolbrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but I have some suggestions on how to make this better with less code.

Comment on lines +1870 to +1885
local reply
find_branch_rev "${content}"
if [ -n "${reply}" ]; then
echo "${reply}" >> "${STATE}/refs"
fi

# possibly-existing local topic branch
if ${GIT} rev-parse --verify -q "${content}" >/dev/null 2>&1; then
echo "${content}" >> "${STATE}/refs"
fi

# possibly-existing remote-tracking topic branch
# (might be different from the remote chosen above)
if ${GIT} rev-parse --verify -q "${content}@{u}" >/dev/null 2>&1; then
echo "${content}@{u}" >> "${STATE}/refs"
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be other remotes with relevant branches, so I think it would be better to replace the whole thing with:

	${GIT} show-ref -s "${content}" >> "${STATE}/refs"

That should get you the commit-ish of all remote and local branches with that name.
This has the extra benefit, that umpf will not ask, which branch should be used, because we want so see all of them anyways.

Comment on lines +1906 to +1913
ranges=

# cut off each ref at base
for ref in "${refs[@]}"; do
ranges="${ranges} ${base}^..${ref}"
done

tig ${ranges}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this instead, much simpler:

	tig "${refs[@]}" "^${base}^"

### command: tig ###

do_tig () {
local refs base ranges
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refs is an array, so I think it should be declared as one here.

	local base
	local -a refs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants