-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: master
Are you sure you want to change the base?
Conversation
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>
There was a problem hiding this 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.
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 |
There was a problem hiding this comment.
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.
ranges= | ||
|
||
# cut off each ref at base | ||
for ref in "${refs[@]}"; do | ||
ranges="${ranges} ${base}^..${ref}" | ||
done | ||
|
||
tig ${ranges} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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.