Commit a484d721b0152ab353a510e75b2aab3cd1aebee3

Stefan Sperling 2019-06-10T12:10:37

don't report base-bump-only updates as 'already up to date'

diff --git a/got/got.c b/got/got.c
index 96fece4..01f304f 100644
--- a/got/got.c
+++ b/got/got.c
@@ -285,6 +285,10 @@ checkout_progress(void *arg, unsigned char status, const char *path)
 {
 	char *worktree_path = arg;
 
+	/* Base commit bump happens silently. */
+	if (status == GOT_STATUS_BUMP_BASE)
+		return;
+
 	while (path[0] == '/')
 		path++;
 
@@ -567,6 +571,11 @@ update_progress(void *arg, unsigned char status, const char *path)
 		return;
 
 	*did_something = 1;
+
+	/* Base commit bump happens silently. */
+	if (status == GOT_STATUS_BUMP_BASE)
+		return;
+
 	while (path[0] == '/')
 		path++;
 	printf("%c  %s\n", status, path);
diff --git a/include/got_worktree.h b/include/got_worktree.h
index 6ab8418..2dd6e8c 100644
--- a/include/got_worktree.h
+++ b/include/got_worktree.h
@@ -31,6 +31,7 @@ struct got_commitable;
 #define GOT_STATUS_OBSTRUCTED	'~'
 #define GOT_STATUS_REVERT	'R'
 #define GOT_STATUS_CANNOT_DELETE 'd'
+#define GOT_STATUS_BUMP_BASE	'b'
 
 /*
  * Attempt to initialize a new work tree on disk.
diff --git a/lib/worktree.c b/lib/worktree.c
index acc38bf..d541a30 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1460,6 +1460,8 @@ struct bump_base_commit_id_arg {
 	const char *path;
 	size_t path_len;
 	const char *entry_name;
+	got_worktree_checkout_cb progress_cb;
+	void *progress_arg;
 };
 
 /* Bump base commit ID of all files within an updated part of the work tree. */
@@ -1474,6 +1476,7 @@ bump_base_commit_id(void *arg, struct got_fileindex_entry *ie)
 	} else if (!got_path_is_child(ie->path, a->path, a->path_len))
 		return NULL;
 
+	(*a->progress_cb)(a->progress_arg, GOT_STATUS_BUMP_BASE, ie->path);
 	memcpy(ie->commit_sha1, a->base_commit_id->sha1, SHA1_DIGEST_LENGTH);
 	return NULL;
 }
@@ -1644,6 +1647,8 @@ got_worktree_checkout_files(struct got_worktree *worktree, const char *path,
 	bbc_arg.entry_name = entry_name;
 	bbc_arg.path = path;
 	bbc_arg.path_len = strlen(path);
+	bbc_arg.progress_cb = progress_cb;
+	bbc_arg.progress_arg = progress_arg;
 	err = got_fileindex_for_each_entry_safe(fileindex,
 	    bump_base_commit_id, &bbc_arg);
 sync:
diff --git a/regress/cmdline/update.sh b/regress/cmdline/update.sh
index 07a2d33..ce179b0 100755
--- a/regress/cmdline/update.sh
+++ b/regress/cmdline/update.sh
@@ -1470,7 +1470,9 @@ function test_update_bumps_base_commit_id {
 
 	(cd $testroot/wt && got update > $testroot/stdout)
 
-	echo "Already up-to-date" > $testroot/stdout.expected
+	echo -n "Updated to commit " >> $testroot/stdout.expected
+	git_show_head $testroot/repo >> $testroot/stdout.expected
+	echo >> $testroot/stdout.expected
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret="$?"
 	if [ "$ret" != "0" ]; then