Skip to content

Commit 1a9792e

Browse files
Merge pull request #48 from michaelolbrich/distribute
umpf: distribute: provide default branch for fixup commits if possible
2 parents 726de69 + 4c0476f commit 1a9792e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

umpf

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,24 +1659,35 @@ do_diff() {
16591659
### command: distribute ###
16601660
16611661
apply_to_topic() {
1662-
local rev branch topic state
1662+
local rev branch topic state base subject match
16631663
rev="${1}"
16641664
branch=$(cat "${STATE}/distribute-branch" 2>/dev/null)
16651665
topic=$(cat "${STATE}/distribute-topic" 2>/dev/null)
16661666
state=$(cat "${STATE}/distribute-state" 2>/dev/null)
1667+
base="$(<"${STATE}/base-name")"
16671668
16681669
echo
16691670
GIT_PAGER="" ${GIT} log --oneline -1 "${rev}"
16701671
1672+
subject="$(git log --pretty="format:%s" -1 "${rev}")"
1673+
case "${subject}" in
1674+
"fixup!"*|"amend!"*|"squash!"*)
1675+
match="${subject#*\! }"
1676+
;;
1677+
esac
1678+
16711679
while [ -z "${topic}" ]; do
1672-
local i=0 ret
1680+
local i=0 ret default
16731681
for branch in "${branch_names[@]}"; do
16741682
echo "${i}) ${branch}"
1683+
if git log --pretty="format:%s" "${base}..${branches[${i}]}" | grep -q "^${match}$"; then
1684+
default="${i}"
1685+
fi
16751686
i=$((i+1))
16761687
done
16771688
echo "s) show patch"
16781689
echo "x) skip patch"
1679-
read -e -p "Branch: " ret
1690+
read -e -p "Branch: " -i "${default}" ret
16801691
case "${ret}" in
16811692
s)
16821693
${GIT} show "${rev}"

0 commit comments

Comments
 (0)