{"thread":{"id":"66429","subject":"[BUG] sparse-checkout: checkout clobbers untracked in-cone file","startedAt":"2026-09-30T20:21:01Z","lastAt":"2026-09-30T20:21:01Z","messageCount":1,"participants":["Webstrand"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"553752","messageId":"CACm1TQd5b9tX368LrsD26Q6tm_mzdi1nwGtGd2V1jwYW+r2c1A@mail.gmail.com","threadId":"66429","inReplyTo":null,"subject":"[BUG] sparse-checkout: checkout clobbers untracked in-cone file","fromName":"Webstrand","fromEmail":"webstrand@gmail.com","sentAt":"2026-09-30T20:20:48Z","receivedAt":"2026-09-30T20:21:01Z","isPatch":false,"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n\n    git init --initial-branch=locus repo\n    cd repo\n    mkdir src docs\n    echo \"tracked\" >src/tracked.txt\n    echo \"tracked\" >docs/tracked.txt\n    git add .\n    git commit --message=\"initial\"\n    git sparse-checkout set src\n    git branch some-feature-branch\n    git checkout some-feature-branch\n    echo \"incoming\" >src/new.txt\n    git add src/new.txt\n    git commit --message=\"add src/new.txt\"\n    git checkout locus\n    echo \"local\" >src/new.txt # conflicting untracked file\n    git checkout some-feature-branch\n    echo $?\n    cat src/new.txt\n\nWhat did you expect to happen? (Expected behavior)\n\nThe checkout operation should be aborted as a whole:\n\n 1. No files in the working tree should be updated.\n 2. HEAD should not be moved and should continue to reference locus.\n 3. src/new.txt must be unmodified, preserving the untracked content\n    \"local\".\n 4. git should exit with status 1 and print the following error:\n\n    error: The following untracked working tree files would be\noverwritten by checkout:\n        src/new.txt\n    Please move or remove them before you switch branches.\n    Aborting\n\nSparse checkouts should have the same behavior as non-sparse checkouts\nof the same commits.\n\nWhat happened instead? (Actual behavior)\n\nThe checkout operation clobbered untracked files:\n\n 1. Files in the working tree were updated.\n 2. HEAD was moved to reference some-feature-branch.\n 3. src/new.txt was overwritten with the content \"incoming\", clobbering\n    it.\n 4. git exited with status 0 and printed the following warning:\n\n    warning: The following paths were already present and thus not\nupdated despite sparse patterns:\n        src/new.txt\n\n    After fixing the above paths, you may want to run `git\nsparse-checkout reapply`.\n    Switched to branch 'some-feature-branch'\n\nAdditionally, the produced warning is incorrect and misleading.\n\nWhat's different between what you expected and what actually happened?\n\nThe checkout completed instead of being aborted, src/new.txt was\nclobbered instead of preserved, and the conflict was reported as a\nwarning instead of an error, and the warning was incorrect and\nmisleading. As a result, the untracked content of src/new.txt was\ndestroyed.\n\nAnything else you want to add:\n\nThe behavior is present from v2.27.0, the first release to contain\n681c637b4a, through the tip of master (a018953688).\n\nThe behavior was introduced by\n\n681c637b4a unpack-trees: failure to set SKIP_WORKTREE bits always just a warning\n\nPrior to 681c6, git refused the sparse checkout, producing the same\nerror as the non-sparse checkout, with the same behavior as in \"Expected\nbehavior\". src/new.txt was not clobbered. Starting with 681c6, git\ncompletes the sparse checkout with the warning shown in \"Actual\nbehavior\", and src/new.txt is clobbered.\n\n[System Info]\ngit version 2.56.0\ncpu: x86_64\nbuilt from commit: a018953688f1b10bddf91bff8747068f5f4746a4\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nrust: enabled\nfeature: fsmonitor--daemon\ngettext: enabled\nlibcurl: 8.22.0\nOpenSSL: OpenSSL 3.5.3 16 Sep 2025\nzlib: 1.3.1\nSHA-1: SHA1_DC\nSHA-256: SHA256_BLK\ndefault-ref-format: files\ndefault-hash: sha1\nuname: Linux 7.2.7-1-default #1 SMP PREEMPT_DYNAMIC Tue Sep 22\n08:00:24 UTC 2026 (e601a2d) x86_64\ncompiler info: gnuc: 16.2\nlibc info: glibc: 2.44\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n"}]}