Commit Diff


commit - b85a34968b050b10c36277d23e4cbb4a3e903a36
commit + b36a977475ba5c9bfbd69cf4e15f51c3f504435a
blob - 0e0b0feb644f21aef2762bad36f5c42d5dfb5591
blob + 3341e03568024d52e4f9c925411ae35e62e32ea3
--- lib/worktree.c
+++ lib/worktree.c
@@ -1994,6 +1994,12 @@ update_blob(struct got_worktree *worktree,
 		    memcmp(ie->blob_sha1, te->id.sha1,
 		    SHA1_DIGEST_LENGTH) == 0) {
 			/* Different commit but the same blob. */
+			if (got_fileindex_entry_has_commit(ie)) {
+				/* Update the base commit ID of this file. */
+				memcpy(ie->commit_sha1,
+				    worktree->base_commit_id->sha1,
+				    sizeof(ie->commit_sha1));
+			}
 			err = sync_timestamps(worktree->root_fd,
 			    path, status, ie, &sb);
 			if (err)
blob - 822844175d6069cb0ad59c5bd870b63d886b9990
blob + c08237c6cd1b14453b8e4f8e39789a3c6c017f1c
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
@@ -1899,12 +1899,7 @@ test_update_modified_submodules() {
 	(cd $testroot/repo && git add repo2)
 	git_commit $testroot/repo -m "modified submodule link"
 
-	# This update only records the new base commit. Otherwise it is a
-	# no-op change because Got's file index does not track submodules.
-	echo -n "Updated to refs/heads/master: " > $testroot/stdout.expected
-	git_show_head $testroot/repo >> $testroot/stdout.expected
-	echo >> $testroot/stdout.expected
-
+	echo "Already up-to-date" > $testroot/stdout.expected
 	(cd $testroot/wt && got update > $testroot/stdout)
 
 	cmp -s $testroot/stdout.expected $testroot/stdout