commit 9c4b8182fcfabf42c6dc904dfccd3c4aa9bb4bcf from: Stefan Sperling date: Wed Jan 02 15:11:39 2019 UTC print new base commit ID when update is done commit - 0fbd721f10df717372951e1ea217faef10b4cfb0 commit + 9c4b8182fcfabf42c6dc904dfccd3c4aa9bb4bcf blob - 746cf514efa8f22407e5ff7839677223a535a8a1 blob + 74fa300abb148f521b2bc42cb04ce259732327c3 --- got/got.c +++ got/got.c @@ -394,13 +394,15 @@ cmd_update(int argc, char *argv[]) struct got_worktree *worktree = NULL; char *worktree_path = NULL; struct got_object_id *commit_id = NULL; - const char *commit_id_str = NULL; + char *commit_id_str = NULL; int ch; while ((ch = getopt(argc, argv, "c:")) != -1) { switch (ch) { case 'c': - commit_id_str = optarg; + commit_id_str = strdup(optarg); + if (commit_id_str == NULL) + return got_error_from_errno(); break; default: usage(); @@ -445,6 +447,9 @@ cmd_update(int argc, char *argv[]) if (error != NULL) goto done; error = got_ref_resolve(&commit_id, repo, head_ref); + if (error != NULL) + goto done; + error = got_object_id_str(&commit_id_str, commit_id); if (error != NULL) goto done; } else { @@ -470,9 +475,12 @@ cmd_update(int argc, char *argv[]) update_progress, NULL, checkout_cancel, NULL); if (error != NULL) goto done; + + printf("Updated to commit %s\n", commit_id_str); done: free(worktree_path); free(commit_id); + free(commit_id_str); return error; } blob - 4fb24d61a698847ebfe40cb77aed98a0c3f92799 blob + d585d9b49ff2ad547568fa364a31746e807e66bf --- regress/cmdline/common.sh +++ regress/cmdline/common.sh @@ -26,6 +26,12 @@ function git_commit (cd $repo && git commit -q -a "$@") } +function git_show_head +{ + local repo="$1" + (cd $repo && git show --no-patch --pretty='format:%H') +} + function make_test_tree { repo="$1" blob - 416b75e596b98a2a99f5166940a851d6f9647589 blob + 736d20ef92439eec6ec53ed167e5b6461df3395d --- regress/cmdline/update.sh +++ regress/cmdline/update.sh @@ -29,6 +29,9 @@ function test_update_basic { git_commit $testroot/repo -m "modified alpha" echo "U alpha" > $testroot/stdout.expected + echo -n "Updated to commit " >> $testroot/stdout.expected + git_show_head $testroot/repo >> $testroot/stdout.expected + echo >> $testroot/stdout.expected (cd $testroot/wt && got update > $testroot/stdout)