Skip to content

Commit 2925414

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

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
@@ -373,17 +373,15 @@ do_next () {
373373
pick_one -n $sha1 || failed=t
374374
case "$(peek_next_command)" in
375375
squash|s)
376-
EDIT_COMMIT=
377376
USE_OUTPUT=output
378377
MSG_OPT=-F
379-
MSG_FILE="$MSG"
378+
EDIT_OR_FILE="$MSG"
380379
cp "$MSG" "$SQUASH_MSG"
381380
;;
382381
*)
383-
EDIT_COMMIT=-e
384382
USE_OUTPUT=
385383
MSG_OPT=
386-
MSG_FILE=
384+
EDIT_OR_FILE=-e
387385
rm -f "$SQUASH_MSG" || exit
388386
cp "$MSG" "$GIT_DIR"/SQUASH_MSG
389387
rm -f "$GIT_DIR"/MERGE_MSG || exit
@@ -397,7 +395,8 @@ do_next () {
397395
GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
398396
GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
399397
GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
400-
$USE_OUTPUT git commit --no-verify $MSG_OPT "$MSG_FILE" $EDIT_COMMIT || failed=t
398+
$USE_OUTPUT git commit --no-verify \
399+
$MSG_OPT "$EDIT_OR_FILE" || failed=t
401400
fi
402401
if test $failed = t
403402
then

t/t3404-rebase-interactive.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,30 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' '
433433
434434
'
435435

436+
test_expect_success 'submodule rebase setup' '
437+
git checkout A &&
438+
mkdir sub &&
439+
(
440+
cd sub && git init && >elif &&
441+
git add elif && git commit -m "submodule initial"
442+
) &&
443+
echo 1 >file1 &&
444+
git add file1 sub
445+
test_tick &&
446+
git commit -m "One" &&
447+
echo 2 >file1 &&
448+
test_tick &&
449+
git commit -a -m "Two" &&
450+
(
451+
cd sub && echo 3 >elif &&
452+
git commit -a -m "submodule second"
453+
) &&
454+
test_tick &&
455+
git commit -a -m "Three changes submodule"
456+
'
457+
458+
test_expect_success 'submodule rebase -i' '
459+
FAKE_LINES="1 squash 2 3" git rebase -i A
460+
'
461+
436462
test_done

0 commit comments

Comments
 (0)