commit afa376bfb3ca51475b12811e7f07c512f6a9267e from: Stefan Sperling date: Thu May 09 19:36:10 2019 UTC report commit item status commit - 9d40349afb0c438d161315fb5751aa39e5a1a2ae commit + afa376bfb3ca51475b12811e7f07c512f6a9267e blob - a39387abda91c220d8e14e5faab47e21bc1396f4 blob + 77eeffbd54d16cdfc877092f4812ada8a39dd5f4 --- got/got.c +++ got/got.c @@ -2133,7 +2133,8 @@ cmd_commit(int argc, char *argv[]) goto done; error = got_worktree_commit(&id, worktree, path, - "Stefan Sperling ", NULL, logmsg, repo); + "Stefan Sperling ", NULL, logmsg, + print_status, NULL, repo); if (error) goto done; blob - 27d9c4b14fdad4299d1cdd8a2cf811e17f143565 blob + 50c0ae77687009bb6ce1cfbb71fb9f8beef20564 --- include/got_worktree.h +++ include/got_worktree.h @@ -177,4 +177,4 @@ const struct got_error *got_worktree_revert(struct got */ 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 @@ -2290,12 +2290,15 @@ done: 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; @@ -2310,7 +2313,7 @@ write_subtree(struct got_object_id **new_subtree_id, 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; @@ -2421,6 +2424,16 @@ insert_tree_entry(struct got_tree_entry *new_te, 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 * @@ -2469,6 +2482,7 @@ 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; @@ -2504,6 +2518,9 @@ write_tree(struct got_object_id **new_tree_id, 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; @@ -2523,7 +2540,7 @@ write_tree(struct got_object_id **new_tree_id, 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; @@ -2546,7 +2563,8 @@ write_tree(struct got_object_id **new_tree_id, 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); @@ -2568,6 +2586,9 @@ write_tree(struct got_object_id **new_tree_id, 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); @@ -2598,8 +2619,9 @@ done: 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; @@ -2669,7 +2691,8 @@ got_worktree_commit(struct got_object_id **new_commit_ 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 @@ -19,8 +19,6 @@ 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 @@ -38,12 +36,10 @@ function test_commit_basic { (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