{"thread":{"id":"58276","subject":"Init-add-reset bug in a fresh repo","startedAt":"2022-08-07T17:01:36Z","lastAt":"2022-08-07T17:22:29Z","messageCount":2,"participants":["Alex A. Davronov","Reto"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"460792","messageId":"CAKBAyV4XaXC=Gw5SN9So9UAMJ9ZQE=8dA7B5D8+Wn4JKuFRDeA@mail.gmail.com","threadId":"58276","inReplyTo":null,"subject":"Init-add-reset bug in a fresh repo","fromName":"Alex A. Davronov","fromEmail":"al.neodim@gmail.com","sentAt":"2022-08-07T17:01:21Z","receivedAt":"2022-08-07T17:01:36Z","isPatch":false,"sender":{"key":"al.neodim@gmail.com","avatar":null},"body":"Steps to reproduce your issue\n\nIf you have files in a folder and then initiate-add-reset git\nthen you lose everything:\n\nRun the following in your bash shell to see:\n    clear; \\\n    [[ -d /tmp/evilgit ]] && rm -rdI /tmp/evilgit; \\\n    mkdir /tmp/evilgit/; \\\n    cd /tmp/evilgit/; \\\n    echo \"----------------- Create some files:\"; \\\n    pwd; \\\n    echo -n \"ls -l: \"; \\\n    touch a.txt b.txt c.txt; \\\n    ls; \\\n    echo \"----------------- Now, init the repo:\"; \\\n    echo -n \"git init: \"; \\\n    git init 2> /dev/null; \\\n    echo \"git add: a.txt b.txt c.txt\"; \\\n    git add ./*; \\\n    echo -n \"git reset --hard: \"; \\\n    git reset --hard; \\\n    echo \"\\n----------------- Check files again:\"; \\\n    echo \"ls -l: \"; \\\n    ls; \\\n    echo \"No files! \" ; \\\n    echo \"\\n----------------- Now, all the files we have created are gone!\"; \\\n    cd .. ; \\\n    rm -rdI /tmp/evilgit\n\n\nWhat did you expect to happen? (Expected behavior)\n- Files created prior to repo aren't getting removed\n- OR\n- git user is warned that the files are going to get deleted if\nresetting hard indexed ones\n\nWhat happened instead? (Actual behavior)\n- Files are gone.\n\nWhat's different between what you expected and what actually happened?\n- Pre-existing files should be kept\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.37.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.15.0-43-generic #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC\n2022 x86_64\ncompiler info: gnuc: 11.2\nlibc info: glibc: 2.35\n$SHELL (typically, interactive shell): /usr/bin/zsh\n\n\n[Enabled Hooks]\n\n[Additional info]\nSee for reference:\n- https://gist.github.com/hinell/e023bad4652364b477decb036fc6a60a\n"},{"id":"460793","messageId":"20220807172220.z35ilb4z3xyywkor@feather","threadId":"58276","inReplyTo":"CAKBAyV4XaXC=Gw5SN9So9UAMJ9ZQE=8dA7B5D8+Wn4JKuFRDeA@mail.gmail.com","subject":"Re: Init-add-reset bug in a fresh repo","fromName":"Reto","fromEmail":"reto@labrat.space","sentAt":"2022-08-07T17:22:20Z","receivedAt":"2022-08-07T17:22:29Z","isPatch":false,"sender":{"key":"reto@labrat.space","avatar":null},"body":"> What did you expect to happen? (Expected behavior)\n> - Files created prior to repo aren't getting removed\n\n> What happened instead? (Actual behavior)\n> - Files are gone.\n\nThat's literally what you instructed git to do...\n\n--hard really means that, reset I don't care YOLO, --force, just do it\nmate.\n\n>--hard\n>   Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.\n>   Any untracked files or directories in the way of writing any tracked files are simply deleted.\n\nIn other words, the flag does exactly what it's meant to do.\n\nKind regards,\nReto\n"}]}