{"thread":{"id":"61867","subject":"Tracked file cannot be added, mentions to sparse checkout that I don't have.","startedAt":"2024-07-30T10:29:46Z","lastAt":"2024-07-30T22:40:06Z","messageCount":2,"participants":["Nathan Teodosio","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"499592","messageId":"20240730122926.638a9263@canonical","threadId":"61867","inReplyTo":null,"subject":"Tracked file cannot be added, mentions to sparse checkout that I don't have.","fromName":"Nathan Teodosio","fromEmail":"nathan.teodosio@canonical.com","sentAt":"2024-07-30T10:29:26Z","receivedAt":"2024-07-30T10:29:46Z","isPatch":false,"sender":{"key":"nathan.teodosio@canonical.com","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n\nI modified a tracked file.\n\nWhat did you expect to happen? (Expected behavior)\n\nThe file is listed as modified in git status and added with git add etc.,\ni.e. the usual commit routine.\n\nWhat happened instead? (Actual behavior)\n\nI cannot add or commit the changes done to that file.\n\n--->\n% echo 1 >> snapcraft.yaml\n% tail -n1 snapcraft.yaml\n1\n# I expected snapcraft.yaml to show here:\n% git status -s\n?? git-bugreport-2024-07-30-1212.txt\n# I expected snapcraft.yaml to be added here:\n% git add snapcraft.yaml\nThe following paths and/or pathspecs matched paths that exist\noutside of your sparse-checkout definition, so will not be\nupdated in the index:\nsnapcraft.yaml\nhint: If you intend to update such entries, try one of the following:\nhint: * Use the --sparse option.\nhint: * Disable or modify the sparsity rules.\nhint: Disable this message with \"git config advice.updateSparsePath false\"\n<---\n\nWhat's different between what you expected and what actually happened?\n\nThe difference is that the file cannot be added or commited, as if no changes\nhad been made to it.\n\nAnything else you want to add:\n\n--->\n% git branch --show-current\ndev\n% git ls-tree -r dev --name-only|grep snapcraft\nsnapcraft.yaml\n% git sparse-checkout list\nfatal: this worktree is not sparse\n<---\n\nGit was yesterday in my system updated and I never encountered\nanything similar to this issue before.\n\n--->\n% grep ' installed git:' /var/log/dpkg.log\n2024-07-29 10:37:19 status installed git:amd64 1:2.45.2-1ubuntu1\n<---\n\nGit does recognize modifications to another file in the same directory,\nso I am completely stumped what is special about this snapcraft.yaml.\n\n\n[System Info]\ngit version:\ngit version 2.45.2\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20\n00:40:06 UTC 2024 x86_64 compiler info: gnuc: 13.2\nlibc info: glibc: 2.39\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n"},{"id":"499649","messageId":"ZqlrxFrzuC2lGyTU@tapette.crustytoothpaste.net","threadId":"61867","inReplyTo":"20240730122926.638a9263@canonical","subject":"Re: Tracked file cannot be added, mentions to sparse checkout that I don't have.","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-07-30T22:40:04Z","receivedAt":"2024-07-30T22:40:06Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-07-30 at 10:29:26, Nathan Teodosio wrote:\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> \n> I modified a tracked file.\n> \n> What did you expect to happen? (Expected behavior)\n> \n> The file is listed as modified in git status and added with git add etc.,\n> i.e. the usual commit routine.\n> \n> What happened instead? (Actual behavior)\n> \n> I cannot add or commit the changes done to that file.\n> \n> --->\n> % echo 1 >> snapcraft.yaml\n> % tail -n1 snapcraft.yaml\n> 1\n> # I expected snapcraft.yaml to show here:\n> % git status -s\n> ?? git-bugreport-2024-07-30-1212.txt\n> # I expected snapcraft.yaml to be added here:\n> % git add snapcraft.yaml\n> The following paths and/or pathspecs matched paths that exist\n> outside of your sparse-checkout definition, so will not be\n> updated in the index:\n> snapcraft.yaml\n> hint: If you intend to update such entries, try one of the following:\n> hint: * Use the --sparse option.\n> hint: * Disable or modify the sparsity rules.\n> hint: Disable this message with \"git config advice.updateSparsePath false\"\n> <---\n\nHave you perhaps done `git update-index --skip-worktree snapcraft.yaml`?\nHere's how you can find out:\n\n  % git ls-files -t | grep snapcraft.yaml\n  S snapcraft.yaml\n\nThat \"S\" means it's skip-worktree.  Otherwise, we'd normally expect to\nsee an \"H\" or maybe another letter there.\n\nIf so, that might be because you've received some information\n(unfortunately erroneous) that `git update-index --skip-worktree` or\n`git update-index --assume-unchanged` are good ways to ignore changes to\na tracked file.  The Git FAQ[0] is pretty clear that Git doesn't allow\nignoring tracked files and explains why.  The skip-worktree bit is\ndesigned to implement sparse checkout, so that's why you typically get\nthat message if that bit is set and you try to add the file.\n\nYou can unset that bit with `git update-index --no-skip-worktree\nsnapcraft.yaml`, which should fix the problem.  As for ignoring files,\nthe Git FAQ outlines an alternative which we recommend instead:\n\n  If your goal is to modify a configuration file, it can often be\n  helpful to have a file checked into the repository which is a template\n  or set of defaults which can then be copied alongside and modified as\n  appropriate. This second, modified file is usually ignored to prevent\n  accidentally committing it.\n\nHopefully that's helpful.  If I'm incorrect and that bit hasn't been set\nin the index, please do let us know, because that would be unexpected.\n\n[0] https://git-scm.com/docs/gitfaq#ignore-tracked-files\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"}]}