commit d106871cc560c1985e7c6fbc4a949d2d946158a0 from: Sven M. Hallberg date: Wed Aug 07 07:43:18 2024 UTC regress/cmdline: add test_rebase_preserves_author_time commit - 9a2e7ad4870891a7244450ed93be14d82bbd104b commit + d106871cc560c1985e7c6fbc4a949d2d946158a0 blob - aa8c37ce5f9af6c3b3fdf320c95dd8316334d667 blob + 61dba33b2a2784aa595f49cae1dea5dde21166fc --- regress/cmdline/rebase.sh +++ regress/cmdline/rebase.sh @@ -997,8 +997,71 @@ test_rebase_preserves_logmsg() { ret=$? if [ $ret -ne 0 ]; then diff -u $testroot/log.expected $testroot/log + fi + + test_done "$testroot" "$ret" +} + +test_rebase_preserves_author_time() { + local testroot=`test_init rebase_preserves_author_time` + + git -C $testroot/repo checkout -q -b newbranch + echo "modified delta on branch" > $testroot/repo/gamma/delta + git_commit $testroot/repo -m "modified delta on newbranch" + + sleep 1 # get a new timestamp + echo "modified alpha on branch" > $testroot/repo/alpha + git_commit $testroot/repo -m "modified alpha on newbranch" + + (cd $testroot/repo && got log -c newbranch -l2 | \ + egrep '^(commit|date:)' > $testroot/dates.expected) + + local orig_commit1=`git_show_parent_commit $testroot/repo` + local orig_commit2=`git_show_head $testroot/repo` + + git -C $testroot/repo checkout -q master + echo "modified zeta on master" > $testroot/repo/epsilon/zeta + git_commit $testroot/repo -m "committing to zeta on master" + local master_commit=`git_show_head $testroot/repo` + + got checkout $testroot/repo $testroot/wt > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + test_done "$testroot" "$ret" + return 1 + fi + + sleep 1 # get a new timestamp + (cd $testroot/wt && got rebase newbranch > /dev/null \ + 2> $testroot/stderr) + + git -C $testroot/repo checkout -q newbranch + local new_commit1=`git_show_parent_commit $testroot/repo` + local new_commit2=`git_show_head $testroot/repo` + + echo -n > $testroot/stderr.expected + cmp -s $testroot/stderr.expected $testroot/stderr + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/stderr.expected $testroot/stderr + test_done "$testroot" "$ret" + return 1 fi + (cd $testroot/wt && got log -c newbranch -l2 | \ + egrep '^(commit|orig:)' > $testroot/dates) + ed -s $testroot/dates.expected <<-EOF + ,s/$orig_commit1/$new_commit1/ + ,s/$orig_commit2/$new_commit2/ + ,s/^date:/orig:/ + w + EOF + cmp -s $testroot/dates.expected $testroot/dates + ret=$? + if [ $ret -ne 0 ]; then + diff -u $testroot/dates.expected $testroot/dates + fi + test_done "$testroot" "$ret" } @@ -2286,6 +2349,7 @@ run_test test_rebase_no_op_change run_test test_rebase_in_progress run_test test_rebase_path_prefix run_test test_rebase_preserves_logmsg +run_test test_rebase_preserves_author_time run_test test_rebase_no_commits_to_rebase run_test test_rebase_forward run_test test_rebase_forward_path_prefix