Skip to content

Commit 54e7e78

Browse files
committed
Merge branch 'js/maint-1.6.1-rebase-i-submodule' into maint-1.6.1
* js/maint-1.6.1-rebase-i-submodule: Fix submodule squashing into unrelated commit rebase -i squashes submodule changes into unrelated commit
2 parents daf713d + 94c88ed commit 54e7e78

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

git-rebase--interactive.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,15 @@ do_next () {
360360
pick_one -n $sha1 || failed=t
361361
case "$(peek_next_command)" in
362362
squash|s)
363-
EDIT_COMMIT=
364363
USE_OUTPUT=output
365364
MSG_OPT=-F
366-
MSG_FILE="$MSG"
365+
EDIT_OR_FILE="$MSG"
367366
cp "$MSG" "$SQUASH_MSG"
368367
;;
369368
*)
370-
EDIT_COMMIT=-e
371369
USE_OUTPUT=
372370
MSG_OPT=
373-
MSG_FILE=
371+
EDIT_OR_FILE=-e
374372
rm -f "$SQUASH_MSG" || exit
375373
cp "$MSG" "$GIT_DIR"/SQUASH_MSG
376374
rm -f "$GIT_DIR"/MERGE_MSG || exit
@@ -384,7 +382,8 @@ do_next () {
384382
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
385383
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
386384
GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
387-
$USE_OUTPUT git commit --no-verify $MSG_OPT "$MSG_FILE" $EDIT_COMMIT || failed=t
385+
$USE_OUTPUT git commit --no-verify \
386+
$MSG_OPT "$EDIT_OR_FILE" || failed=t
388387
fi
389388
if test $failed = t
390389
then

t/t3404-rebase-interactive.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,4 +462,30 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' '
462462
463463
'
464464

465+
test_expect_success 'submodule rebase setup' '
466+
git checkout A &&
467+
mkdir sub &&
468+
(
469+
cd sub && git init && >elif &&
470+
git add elif && git commit -m "submodule initial"
471+
) &&
472+
echo 1 >file1 &&
473+
git add file1 sub
474+
test_tick &&
475+
git commit -m "One" &&
476+
echo 2 >file1 &&
477+
test_tick &&
478+
git commit -a -m "Two" &&
479+
(
480+
cd sub && echo 3 >elif &&
481+
git commit -a -m "submodule second"
482+
) &&
483+
test_tick &&
484+
git commit -a -m "Three changes submodule"
485+
'
486+
487+
test_expect_success 'submodule rebase -i' '
488+
FAKE_LINES="1 squash 2 3" git rebase -i A
489+
'
490+
465491
test_done

0 commit comments

Comments
 (0)