From be98101a6111f67a6d72dff061ea8f001bd4c6ad Mon Sep 17 00:00:00 2001 From: chillaranand Date: Thu, 8 Jan 2026 20:59:48 +0530 Subject: [PATCH] fix(output): dvc update should honor output cache flag --- dvc/output.py | 2 +- tests/func/test_update.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/dvc/output.py b/dvc/output.py index 384ba77cd8..0e44a05a7e 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -505,7 +505,7 @@ def use_scm_ignore(self): if not self.is_in_repo: return False - return self.use_cache or self.stage.is_repo_import + return self.use_cache @property def cache(self): diff --git a/tests/func/test_update.py b/tests/func/test_update.py index 7de4e641a3..04d594e651 100644 --- a/tests/func/test_update.py +++ b/tests/func/test_update.py @@ -461,3 +461,24 @@ def test_update_import_url_to_remote_directory_same_hash( "bar": {"baz": "foo"}, "same": "same", } + + +def test_update_import_cache_false_no_gitignore(tmp_dir, dvc, scm, erepo_dir): + with erepo_dir.chdir(): + erepo_dir.scm_gen({"file": "content"}, commit="add file") + + stage = dvc.imp(os.fspath(erepo_dir), "file", "imported_file") + stage.outs[0].use_cache = False + stage.dump() + + # Remove "imported_file" from .gitignore + ignore_file = tmp_dir / ".gitignore" + ignore_file.write_text("") + + with erepo_dir.chdir(): + erepo_dir.scm_gen("file", "new content", commit="update file") + + dvc.update([stage.path]) + + assert (tmp_dir / "imported_file").read_text() == "new content" + assert "imported_file" not in ignore_file.read_text()