commit - 598139dd22c7c7517a6542803c64e88acd78b162
commit + 8db00f97570360c732c5c8b9ab0f0415e74184c0
blob - 1ee2bf16b919eae46317c6699b9488d5580325f1
blob + f743d74c16b90ed6ccc26ca725759193a06afcdb
--- got/got.c
+++ got/got.c
struct got_worktree *worktree = NULL;
struct got_repository *repo = NULL;
struct got_fileindex *fileindex = NULL;
- char *cwd = NULL, *committer = NULL;
+ char *cwd = NULL, *committer = NULL, *gitconfig_path = NULL;
struct got_reference *branch = NULL;
struct got_reference *new_base_branch = NULL, *tmp_branch = NULL;
struct got_object_id *commit_id = NULL, *parent_id = NULL;
}
}
+ error = get_gitconfig_path(&gitconfig_path);
+ if (error)
+ goto done;
error = got_repo_open(&repo,
- worktree ? got_worktree_get_repo_path(worktree) : cwd, NULL,
- pack_fds);
+ worktree ? got_worktree_get_repo_path(worktree) : cwd,
+ gitconfig_path, pack_fds);
if (error != NULL)
goto done;
error = get_author(&committer, repo, worktree);
- if (error)
+ if (error && error->code != GOT_ERR_COMMIT_NO_AUTHOR)
goto done;
error = apply_unveil(got_repo_get_path(repo), 0,
done:
free(cwd);
free(committer);
+ free(gitconfig_path);
got_object_id_queue_free(&commits);
free(branch_head_commit_id);
free(resume_commit_id);
blob - 99ae93983c12038e3507c641875e7d2c48fc3e12
blob + c35eff9d90a4e362a03f90e425f1bcb1c0917632
--- lib/worktree.c
+++ lib/worktree.c
/* NB: commit_worktree will call free(logmsg) */
err = commit_worktree(new_commit_id, &commitable_paths, head_commit_id,
NULL, worktree, got_object_commit_get_author(orig_commit),
- committer, collect_rebase_commit_msg, logmsg, rebase_status, NULL,
- repo);
+ committer ? committer :
+ got_object_commit_get_committer(orig_commit),
+ collect_rebase_commit_msg, logmsg, rebase_status, NULL, repo);
if (err)
goto done;
blob - 904fdab3b1244ff95f5e647d5d32a9d0da0ba58e
blob + 49bc14114f03d5598c9603ce6725550df0f5b9dc
--- regress/cmdline/rebase.sh
+++ regress/cmdline/rebase.sh
egrep '^(from|via):' > $testroot/stdout)
echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
echo "via: $committer" >> $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+test_rebase_no_author_info() {
+ local testroot=`test_init rebase_no_author_info`
+ local commit0=`git_show_head $testroot/repo`
+ local commit0_author_time=`git_show_author_time $testroot/repo`
+ local committer="$GOT_AUTHOR"
+
+ (cd $testroot/repo && git checkout -q -b newbranch)
+ echo "modified delta on branch" > $testroot/repo/gamma/delta
+ git_commit $testroot/repo -m "committing to delta on newbranch"
+
+ echo "modified alpha on branch" > $testroot/repo/alpha
+ git_commit $testroot/repo -m "committing more changes on newbranch"
+
+ local orig_commit1=`git_show_parent_commit $testroot/repo`
+ local orig_commit2=`git_show_head $testroot/repo`
+ local orig_author_time2=`git_show_author_time $testroot/repo`
+
+ (cd $testroot/repo && git 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
+
+ unset GOT_AUTHOR
+ (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
+
+ (cd $testroot/repo && git checkout -q newbranch)
+ local new_commit1=`git_show_parent_commit $testroot/repo`
+ local new_commit2=`git_show_head $testroot/repo`
+ local new_author_time2=`git_show_author_time $testroot/repo`
+ local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
+ local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
+ local short_new_commit1=`trim_obj_id 28 $new_commit1`
+ local short_new_commit2=`trim_obj_id 28 $new_commit2`
+
+ echo "G gamma/delta" >> $testroot/stdout.expected
+ echo -n "$short_orig_commit1 -> $short_new_commit1" \
+ >> $testroot/stdout.expected
+ echo ": committing to delta on newbranch" >> $testroot/stdout.expected
+ echo "G alpha" >> $testroot/stdout.expected
+ echo -n "$short_orig_commit2 -> $short_new_commit2" \
+ >> $testroot/stdout.expected
+ echo ": committing more changes on newbranch" \
+ >> $testroot/stdout.expected
+ echo "Switching work tree to refs/heads/newbranch" \
+ >> $testroot/stdout.expected
+
cmp -s $testroot/stdout.expected $testroot/stdout
ret=$?
if [ $ret -ne 0 ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ # Original commit only had one author
+ (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
+ egrep '^(from|via):' > $testroot/stdout)
+ echo "from: $committer" > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ # Author info of rebased commit should match the original
+ (cd $testroot/repo && got log -l1 -c $new_commit2 | \
+ egrep '^(from|via):' > $testroot/stdout)
+ echo "from: $committer" > $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
test_done "$testroot" "$ret"
}
run_test test_rebase_delete_missing_file
run_test test_rebase_rm_add_rm_file
run_test test_rebase_resets_committer
+run_test test_rebase_no_author_info