commit - 4b4fd6aa67065da8141a7a08bda84b95bc6ae060
commit + 7e6fcaa81371396b915c5382bb6f05175313bc8a
blob - eedba272792e095dfe5a62504a47e88c579c69c8
blob + a81121f951a231375922221fe3702b4f48c0d214
--- got/got.c
+++ got/got.c
if (error)
goto done;
- if (author == NULL)
+ if (author == NULL) {
+ /* got_worktree_commit() treats committer as the optional one */
author = committer;
+ committer = NULL; /* => author timestamp is ignored */
+ }
if (logmsg == NULL || strlen(logmsg) == 0) {
error = get_editor(&editor);
cl_arg.branch_name += 11;
}
cl_arg.repo_path = got_repo_get_path(repo);
- error = got_worktree_commit(&id, worktree, &paths, author, committer,
- allow_bad_symlinks, show_diff, commit_conflicts,
+ error = got_worktree_commit(&id, worktree, &paths, author, time(NULL),
+ committer, allow_bad_symlinks, show_diff, commit_conflicts,
collect_commit_logmsg, &cl_arg, print_status, NULL, repo);
if (error) {
if (error->code != GOT_ERR_COMMIT_MSG_EMPTY &&
goto done;
} else {
error = got_worktree_merge_commit(&merge_commit_id, worktree,
- fileindex, author, NULL, 1, branch_tip, branch_name,
+ fileindex, author, 0, NULL, 1, branch_tip, branch_name,
allow_conflict, repo, continue_merge ? print_status : NULL,
NULL);
if (error)
blob - 4ad750063163bd75fcdbccf958d5b7b7a72278fb
blob + 01bbc9dc9ef3289c00fa880bba8f79aa56f756af
--- include/got_worktree.h
+++ include/got_worktree.h
* current base commit.
* An author and a non-empty log message must be specified.
* The name of the committer is optional (may be NULL).
+ * If a committer is given, a separate author timestamp can be specified
+ * which is ignored otherwise.
* If a path to be committed contains a symlink which points outside
* of the path space under version control, raise an error unless
* committing of such paths is being forced by the caller.
*/
const struct got_error *got_worktree_commit(struct got_object_id **,
- struct got_worktree *, struct got_pathlist_head *, const char *,
+ struct got_worktree *, struct got_pathlist_head *, const char *, time_t,
const char *, int, int, int, got_worktree_commit_msg_cb, void *,
got_worktree_status_cb, void *, struct got_repository *);
const struct got_error *
got_worktree_merge_commit(struct got_object_id **new_commit_id,
struct got_worktree *worktree, struct got_fileindex *fileindex,
- const char *author, const char *committer, int allow_bad_symlinks,
- struct got_object_id *branch_tip, const char *branch_name,
- int allow_conflict, struct got_repository *repo,
+ const char *author, time_t author_ts, const char *committer,
+ int allow_bad_symlinks, struct got_object_id *branch_tip,
+ const char *branch_name, int allow_conflict, struct got_repository *repo,
got_worktree_status_cb status_cb, void *status_arg);
/*
blob - 94cb5018eb8bd148ea52e237479e027fabca1b14
blob + 5b9a648289b2a600c3cfeccfd20bff90c83e6b10
--- lib/worktree.c
+++ lib/worktree.c
struct got_object_id *head_commit_id,
struct got_object_id *parent_id2,
struct got_worktree *worktree,
- const char *author, const char *committer, char *diff_path,
- got_worktree_commit_msg_cb commit_msg_cb, void *commit_arg,
+ const char *author, time_t author_time, const char *committer,
+ char *diff_path, got_worktree_commit_msg_cb commit_msg_cb, void *commit_arg,
got_worktree_status_cb status_cb, void *status_arg,
struct got_repository *repo)
{
nparents++;
}
timestamp = time(NULL);
+ if (committer == NULL)
+ author_time = timestamp;
err = got_object_commit_create(new_commit_id, new_tree_id, &parent_ids,
- nparents, author, timestamp, committer, timestamp, logmsg, repo);
+ nparents, author, author_time, committer, timestamp, logmsg, repo);
if (logmsg != NULL)
free(logmsg);
if (err)
const struct got_error *
got_worktree_commit(struct got_object_id **new_commit_id,
struct got_worktree *worktree, struct got_pathlist_head *paths,
- const char *author, const char *committer, int allow_bad_symlinks,
- int show_diff, int commit_conflicts,
+ const char *author, time_t author_time, const char *committer,
+ int allow_bad_symlinks, int show_diff, int commit_conflicts,
got_worktree_commit_msg_cb commit_msg_cb, void *commit_arg,
got_worktree_status_cb status_cb, void *status_arg,
struct got_repository *repo)
}
err = commit_worktree(new_commit_id, &commitable_paths,
- head_commit_id, NULL, worktree, author, committer,
+ head_commit_id, NULL, worktree, author, author_time, committer,
(diff_path && cc_arg.diff_header_shown) ? diff_path : NULL,
commit_msg_cb, commit_arg, status_cb, status_arg, repo);
if (err)
/* 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),
+ got_object_commit_get_author_time(orig_commit),
committer ? committer :
got_object_commit_get_committer(orig_commit), NULL,
collect_rebase_commit_msg, logmsg, rebase_status, NULL, repo);
const struct got_error *
got_worktree_merge_commit(struct got_object_id **new_commit_id,
struct got_worktree *worktree, struct got_fileindex *fileindex,
- const char *author, const char *committer, int allow_bad_symlinks,
- struct got_object_id *branch_tip, const char *branch_name,
- int allow_conflict, struct got_repository *repo,
+ const char *author, time_t author_time, const char *committer,
+ int allow_bad_symlinks, struct got_object_id *branch_tip,
+ const char *branch_name, int allow_conflict, struct got_repository *repo,
got_worktree_status_cb status_cb, void *status_arg)
-
{
const struct got_error *err = NULL, *sync_err;
struct got_pathlist_head commitable_paths;
mcm_arg.worktree = worktree;
mcm_arg.branch_name = branch_name;
err = commit_worktree(new_commit_id, &commitable_paths,
- head_commit_id, branch_tip, worktree, author, committer, NULL,
- merge_commit_msg_cb, &mcm_arg, status_cb, status_arg, repo);
+ head_commit_id, branch_tip, worktree, author, author_time,
+ committer, NULL, merge_commit_msg_cb, &mcm_arg, status_cb,
+ status_arg, repo);
if (err)
goto done;