commit 614433e1dca199fc027506a6b9148f54677ca1280aec030e062dbd4bd8ca7133 from: "Sven M. Hallberg" via: Stefan Sperling date: Thu Jun 12 08:52:54 2025 UTC cvg: add author_time argument to got_worktree_cvg_commit() No functional change, but keeps the code in sync with got. Patch by Sven M. Hallberg commit - 62a7ef4c4ea8474887483bfe49caece355c3600d1d473791953b4688487d8d3c commit + 614433e1dca199fc027506a6b9148f54677ca1280aec030e062dbd4bd8ca7133 blob - 3d7ab8fcb712b0916d1d8d0a477ef49bd8556ed0da120bf905eca4b230b42f4b blob + b393f090b9fc9dffffc7d15bbe8fe9e3ee8b5cf639860e8eaf358d67303e3c58 --- cvg/cvg.c +++ cvg/cvg.c @@ -7936,8 +7936,11 @@ cmd_commit(int argc, char *argv[]) if (error) goto done; - if (author == NULL) + if (author == NULL) { + /* got_worktree_cvg_commit() treats committer as optional */ author = committer; + committer = NULL; /* => author timestamp is ignored */ + } remote_name = GOT_SEND_DEFAULT_REMOTE_NAME; worktree_conf = got_worktree_get_gotconfig(worktree); @@ -8050,10 +8053,10 @@ cmd_commit(int argc, char *argv[]) cl_arg.repo_path = got_repo_get_path(repo); cl_arg.dial_proto = proto; error = got_worktree_cvg_commit(&id, worktree, &paths, author, - committer, allow_bad_symlinks, show_diff, commit_conflicts, - collect_commit_logmsg, &cl_arg, print_status, NULL, proto, host, - port, server_path, jumphost, identity_file, verbosity, remote, - check_cancelled, repo); + time(NULL), committer, allow_bad_symlinks, show_diff, + commit_conflicts, collect_commit_logmsg, &cl_arg, print_status, + NULL, proto, host, port, server_path, jumphost, identity_file, + verbosity, remote, check_cancelled, repo); if (error) { if (error->code != GOT_ERR_COMMIT_MSG_EMPTY && cl_arg.logmsg_path != NULL) blob - 7936f8523580812628ced145856719bff4c644544ea807da9722dd27e0d99ea2 blob + fee4852672cae1893d2f5d7cd37e28663db4ffa714a76aaaff93a216cac7b1e0 --- include/got_worktree_cvg.h +++ include/got_worktree_cvg.h @@ -23,12 +23,14 @@ * 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_cvg_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 *, const char *, const char *, const char *, const char *, const char *, const char *, int, blob - c137a07ec94f14b31a6750f734248c95eaaa533d557653ebcaba02eab14a7442 blob + 36c1e727a34e12f3cc02cd1054e4761713d1a4b85b6ecf6b52cfdc36d17378f0 --- lib/worktree_cvg.c +++ lib/worktree_cvg.c @@ -2229,8 +2229,8 @@ commit_worktree(struct got_object_id **new_commit_id, 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) { @@ -2315,8 +2315,10 @@ commit_worktree(struct got_object_id **new_commit_id, 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) @@ -2905,8 +2907,8 @@ done: const struct got_error * got_worktree_cvg_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, const char *proto, const char *host, const char *port, @@ -3047,7 +3049,7 @@ got_worktree_cvg_commit(struct got_object_id **new_com } 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)