Skip to content

Commit

Permalink
tig: add subcommand to browse an umpf and its context interactively
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rohieb committed Apr 17, 2024
1 parent 48d63ec commit 7f45282
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _umpf_completion()
"")
COMPREPLY=( $( compgen -W "${completion_cmds[*]} help" -- $cur ) )
;;
diff|show|tag|build)
diff|show|tag|tig|build)
local -a refs
refs=( $( compgen -W "$( git for-each-ref --format='%(refname:short)' refs/tags refs/heads refs/remotes)" -- $cur ) )
if [ ${#refs[@]} -eq 0 ]; then
Expand Down
52 changes: 52 additions & 0 deletions umpf
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ usage() {
diff <commit-ish> show patches not in any topic branch (not
upstream) and patches missing locally
show <commit-ish> show an useries file from an umpf
tig [umpf] browse an umpf interactively, showing state of
local, remote and remote-tracking topic branches
tag <commit-ish> generate a utag from an umerge
format-patch <utag> generate a useries file and patch stack
Expand Down Expand Up @@ -1862,6 +1864,56 @@ do_show() {
cleanup
}
### namespace: tig ###
tig_topic() {
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
}
tig_release() {
echo "${content}" >> "${STATE}/refs"
}
tig_hashinfo() {
echo "${content}" >> "${STATE}/refs"
}
### command: tig ###
do_tig () {
local refs base ranges
prepare_persistent tig "${@}"
parse_series tig "${STATE}/series"
mapfile -t refs < "${STATE}/refs"
base="$(<"${STATE}/base-name")"
ranges=
# cut off each ref at base
for ref in "${refs[@]}"; do
ranges="${ranges} ${base}^..${ref}"
done
tig ${ranges}
cleanup
}
### command: init ###
do_init() {
Expand Down

0 comments on commit 7f45282

Please sign in to comment.