Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit e79fcfc

Browse files
committed
Merge branch 'km/avoid-non-function-return-in-rebase' into maint
"git rebase" used a POSIX shell construct FreeBSD /bin/sh does not work well with. * km/avoid-non-function-return-in-rebase: Revert "rebase: fix run_specific_rebase's use of "return" on FreeBSD" rebase: avoid non-function use of "return" on FreeBSD
2 parents e230cd8 + 8cd6596 commit e79fcfc

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

git-rebase--am.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
# Copyright (c) 2010 Junio C Hamano.
55
#
66

7+
# The whole contents of this file is run by dot-sourcing it from
8+
# inside a shell function. It used to be that "return"s we see
9+
# below were not inside any function, and expected to return
10+
# to the function that dot-sourced us.
11+
#
12+
# However, FreeBSD /bin/sh misbehaves on such a construct and
13+
# continues to run the statements that follow such a "return".
14+
# As a work-around, we introduce an extra layer of a function
15+
# here, and immediately call it after defining it.
16+
git_rebase__am () {
17+
718
case "$action" in
819
continue)
920
git am --resolved --resolvemsg="$resolvemsg" &&
@@ -73,3 +84,7 @@ then
7384
fi
7485

7586
move_to_original_branch
87+
88+
}
89+
# ... and then we call the whole thing.
90+
git_rebase__am

git-rebase--interactive.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,17 @@ add_exec_commands () {
810810
mv "$1.new" "$1"
811811
}
812812

813+
# The whole contents of this file is run by dot-sourcing it from
814+
# inside a shell function. It used to be that "return"s we see
815+
# below were not inside any function, and expected to return
816+
# to the function that dot-sourced us.
817+
#
818+
# However, FreeBSD /bin/sh misbehaves on such a construct and
819+
# continues to run the statements that follow such a "return".
820+
# As a work-around, we introduce an extra layer of a function
821+
# here, and immediately call it after defining it.
822+
git_rebase__interactive () {
823+
813824
case "$action" in
814825
continue)
815826
# do we have anything to commit?
@@ -1042,3 +1053,7 @@ GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $onto_name"
10421053
output git checkout $onto || die_abort "could not detach HEAD"
10431054
git update-ref ORIG_HEAD $orig_head
10441055
do_rest
1056+
1057+
}
1058+
# ... and then we call the whole thing.
1059+
git_rebase__interactive

git-rebase--merge.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ finish_rb_merge () {
101101
say All done.
102102
}
103103

104+
# The whole contents of this file is run by dot-sourcing it from
105+
# inside a shell function. It used to be that "return"s we see
106+
# below were not inside any function, and expected to return
107+
# to the function that dot-sourced us.
108+
#
109+
# However, FreeBSD /bin/sh misbehaves on such a construct and
110+
# continues to run the statements that follow such a "return".
111+
# As a work-around, we introduce an extra layer of a function
112+
# here, and immediately call it after defining it.
113+
git_rebase__merge () {
114+
104115
case "$action" in
105116
continue)
106117
read_state
@@ -151,3 +162,7 @@ do
151162
done
152163

153164
finish_rb_merge
165+
166+
}
167+
# ... and then we call the whole thing.
168+
git_rebase__merge

git-rebase.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,13 @@ You can run "git stash pop" or "git stash drop" at any time.
169169
rm -rf "$state_dir"
170170
}
171171

172-
run_specific_rebase_internal () {
172+
run_specific_rebase () {
173173
if [ "$interactive_rebase" = implied ]; then
174174
GIT_EDITOR=:
175175
export GIT_EDITOR
176176
autosquash=
177177
fi
178-
# On FreeBSD, the shell's "return" returns from the current
179-
# function, not from the current file inclusion.
180-
# run_specific_rebase_internal has the file inclusion as a
181-
# last statement, so POSIX and FreeBSD's return will do the
182-
# same thing.
183178
. git-rebase--$type
184-
}
185-
186-
run_specific_rebase () {
187-
run_specific_rebase_internal
188179
ret=$?
189180
if test $ret -eq 0
190181
then

0 commit comments

Comments
 (0)