commit - 848d6979f98ff53e56da96dc75ed4aee31f42c31
commit + fc66b545cb13384f19d6637645eb2a01db32f763
blob - 486e9fe57b737d0d00f4849e7530505cb0e19467
blob + 24418f17c4a8ca632bd3bb3bc4714b6f61b52d44
--- got/got.c
+++ got/got.c
parent_ids = got_object_commit_get_parent_ids(commit);
pid = SIMPLEQ_FIRST(parent_ids);
+ if (pid == NULL) {
+ if (!continue_rebase) {
+ int did_something;
+ error = got_worktree_rebase_abort(worktree, fileindex,
+ repo, new_base_branch, update_progress,
+ &did_something);
+ if (error)
+ goto done;
+ printf("Rebase of %s aborted\n",
+ got_ref_get_name(branch));
+ }
+ error = got_error(GOT_ERR_EMPTY_REBASE);
+ goto done;
+ }
error = collect_commits(&commits, commit_id, pid->id,
yca_id, got_worktree_get_path_prefix(worktree),
GOT_ERR_REBASE_PATH, repo);
blob - fb98c2fdf7c7eac7d921af01e7972e5612504657
blob + 0d64a54e87019fb4decc9861f1e2c2da67aba905
--- regress/cmdline/rebase.sh
+++ regress/cmdline/rebase.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/log.expected $testroot/log
+ fi
+
+ test_done "$testroot" "$ret"
+}
+
+function test_rebase_no_commits_to_rebase {
+ local testroot=`test_init rebase_no_commits_to_rebase`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ (cd $testroot/wt && got branch newbranch)
+
+ echo "modified alpha on master" > $testroot/wt/alpha
+ (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
+ > /dev/null)
+ (cd $testroot/wt && got update > /dev/null)
+
+ (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
+ 2> $testroot/stderr)
+
+ echo "got: no commits to rebase" > $testroot/stderr.expected
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
fi
+ echo "Rebase of refs/heads/newbranch aborted" \
+ > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+ echo "Already up-to-date" > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
test_done "$testroot" "$ret"
}
run_test test_rebase_in_progress
run_test test_rebase_path_prefix
run_test test_rebase_preserves_logmsg
+run_test test_rebase_no_commits_to_rebase