commit - 9d40349afb0c438d161315fb5751aa39e5a1a2ae
commit + afa376bfb3ca51475b12811e7f07c512f6a9267e
blob - a39387abda91c220d8e14e5faab47e21bc1396f4
blob + 77eeffbd54d16cdfc877092f4812ada8a39dd5f4
--- got/got.c
+++ got/got.c
goto done;
error = got_worktree_commit(&id, worktree, path,
- "Stefan Sperling <stsp@stsp.name>", NULL, logmsg, repo);
+ "Stefan Sperling <stsp@stsp.name>", NULL, logmsg,
+ print_status, NULL, repo);
if (error)
goto done;
blob - 27d9c4b14fdad4299d1cdd8a2cf811e17f143565
blob + 50c0ae77687009bb6ce1cfbb71fb9f8beef20564
--- include/got_worktree.h
+++ include/got_worktree.h
*/
const struct got_error *got_worktree_commit(struct got_object_id **,
struct got_worktree *, const char *, const char *, const char *,
- const char *, struct got_repository *);
+ const char *, got_worktree_status_cb, void *, struct got_repository *);
blob - a972caf931e3b00acf9788774ffac9ea11e2c772
blob + bcc5c7aa4f76642065bbbfe9080e3e5bb9110f12
--- lib/worktree.c
+++ lib/worktree.c
static const struct got_error *write_tree(struct got_object_id **,
struct got_tree_object *, const char *, struct got_pathlist_head *,
+ got_worktree_status_cb status_cb, void *status_arg,
struct got_repository *);
static const struct got_error *
write_subtree(struct got_object_id **new_subtree_id,
struct got_tree_entry *te, const char *parent_path,
- struct got_pathlist_head *commitable_paths, struct got_repository *repo)
+ struct got_pathlist_head *commitable_paths,
+ got_worktree_status_cb status_cb, void *status_arg,
+ struct got_repository *repo)
{
const struct got_error *err = NULL;
struct got_tree_object *subtree;
return err;
err = write_tree(new_subtree_id, subtree, subpath, commitable_paths,
- repo);
+ status_cb, status_arg, repo);
got_object_tree_close(subtree);
free(subpath);
return err;
if (new_pe == NULL)
return got_error(GOT_ERR_TREE_DUP_ENTRY);
return NULL;
+}
+
+static const struct got_error *
+report_ct_status(struct commitable *ct,
+ got_worktree_status_cb status_cb, void *status_arg)
+{
+ const char *ct_path = ct->path;
+ while (ct_path[0] == '/')
+ ct_path++;
+ return (*status_cb)(status_arg, ct->status, ct_path, ct->id);
}
static const struct got_error *
write_tree(struct got_object_id **new_tree_id,
struct got_tree_object *base_tree, const char *path_base_tree,
struct got_pathlist_head *commitable_paths,
+ got_worktree_status_cb status_cb, void *status_arg,
struct got_repository *repo)
{
const struct got_error *err = NULL;
err = alloc_added_blob_tree_entry(&new_te, ct);
if (err)
goto done;
+ err = report_ct_status(ct, status_cb, status_arg);
+ if (err)
+ goto done;
} else {
char *subtree_path;
goto done;
}
err = write_subtree(&new_te->id, NULL, subtree_path,
- commitable_paths, repo);
+ commitable_paths, status_cb, status_arg, repo);
free(subtree_path);
if (err)
goto done;
goto done;
free(new_te->id);
err = write_subtree(&new_te->id, te,
- path_base_tree, commitable_paths, repo);
+ path_base_tree, commitable_paths,
+ status_cb, status_arg, repo);
if (err)
goto done;
err = insert_tree_entry(new_te, &paths);
if (err)
goto done;
}
+ err = report_ct_status(ct, status_cb, status_arg);
+ if (err)
+ goto done;
} else {
/* Entry is unchanged; just copy it. */
err = got_object_tree_entry_dup(&new_te, te);
const struct got_error *
got_worktree_commit(struct got_object_id **new_commit_id,
struct got_worktree *worktree, const char *ondisk_path,
- const char *author, const char *committer,
- const char *logmsg, struct got_repository *repo)
+ const char *author, const char *committer, const char *logmsg,
+ got_worktree_status_cb status_cb, void *status_arg,
+ struct got_repository *repo)
{
const struct got_error *err = NULL, *unlockerr = NULL;
struct collect_commitables_arg cc_arg;
goto done;
/* Recursively write new tree objects. */
- err = write_tree(&new_tree_id, base_tree, "/", &commitable_paths, repo);
+ err = write_tree(&new_tree_id, base_tree, "/", &commitable_paths,
+ status_cb, status_arg, repo);
if (err)
goto done;
blob - f621ba08e8af3b84dcd1904a424886ab6ef6827b
blob + 54f8171b420b631a1444a245b17606223c0c0385
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
function test_commit_basic {
local testroot=`test_init commit_basic`
- find $testroot/repo/.git/objects > /tmp/1
-
got checkout $testroot/repo $testroot/wt > /dev/null
ret="$?"
if [ "$ret" != "0" ]; then
(cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
- find $testroot/repo/.git/objects > /tmp/2
-
local head_rev=`git_show_head $testroot/repo`
- echo "M alpha" > $testroot/stdout.expected
- echo "D beta" >> $testroot/stdout.expected
- echo "A new" >> $testroot/stdout.expected
+ echo "A new" > $testroot/stdout.expected
+ echo "M alpha" >> $testroot/stdout.expected
+ echo "D beta" >> $testroot/stdout.expected
echo "created commit $head_rev" >> $testroot/stdout.expected
cmp $testroot/stdout.expected $testroot/stdout