commit 784955db0f639c53fd5aeb70d0f006cad99a815f from: Stefan Sperling date: Sat Jan 12 21:45:19 2019 UTC print a more useful message when an update had nothing to do commit - cf61d8187fe29b5d3333c3103bc73ad3ca585efc commit + 784955db0f639c53fd5aeb70d0f006cad99a815f blob - cabd57bcdcc7027bcfd2382910f6e65e30e1208f blob + 51c16a1695e0a21b815ddbead9a928ea07ae238e --- got/got.c +++ got/got.c @@ -434,9 +434,12 @@ usage_update(void) static void update_progress(void *arg, unsigned char status, const char *path) { + int *did_something = arg; + if (status == GOT_STATUS_EXISTS) return; + *did_something = 1; while (path[0] == '/') path++; printf("%c %s\n", status, path); @@ -451,7 +454,7 @@ cmd_update(int argc, char *argv[]) char *worktree_path = NULL; struct got_object_id *commit_id = NULL; char *commit_id_str = NULL; - int ch; + int ch, did_something = 0; while ((ch = getopt(argc, argv, "c:")) != -1) { switch (ch) { @@ -532,11 +535,14 @@ cmd_update(int argc, char *argv[]) } error = got_worktree_checkout_files(worktree, repo, - update_progress, NULL, checkout_cancel, NULL); + update_progress, &did_something, checkout_cancel, NULL); if (error != NULL) goto done; - printf("Updated to commit %s\n", commit_id_str); + if (did_something) + printf("Updated to commit %s\n", commit_id_str); + else + printf("Already up-to-date\n"); done: free(worktree_path); free(commit_id);