{"thread":{"id":"3282","subject":"Resetting paths","startedAt":"2006-02-10T04:40:15Z","lastAt":"2006-02-11T05:18:23Z","messageCount":3,"participants":["Junio C Hamano","Andreas Ericsson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15841","messageId":"7vlkwjzv0w.fsf@assigned-by-dhcp.cox.net","threadId":"3282","inReplyTo":null,"subject":"Resetting paths","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-10T04:40:15Z","receivedAt":"2006-02-10T04:40:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"While working on \"assume unchanged\" git series, I found one\nthing missing from the current set of tools.\n\nWhile I worked on parts of the system that deals with the cached\nlstat() information, I needed a way to debug that, so I hacked\nls-files -t option to show entries marked as \"always matches the\nindex\" with lowercase tag letters.  This was primarily debugging\naid hack.\n\nThen I committed the whole thing with \"git commit -a\" by\nmistake.  In order to rewind the HEAD to pre-commit state, I can\nsay \"git reset --soft HEAD^\", but after doing that, now I want\nto unupdate the index so that ls-files.c matches the pre-commit\nHEAD.\n\n\"git reset --mixed\" is a heavy-handed tool for that.  It reads\nthe entier index from the HEAD commit without touching the\nworking tree, so I would need to add the modified paths back\nwith \"git update-index\".\n\nThe low-level voodoo to do so for this particular case is this\nsingle liner:\n\n\tgit ls-tree HEAD ls-files.c | git update-index --index-info\n\nHave people found themselves in similar need like this?  This\ncould take different forms.\n\n * you did \"git update-index\" on a wrong path.  This is my\n   example and the above voodoo is a recipe for recovery.\n\n * you did \"git add\" on a wrong path and you want to remove it.\n   This is easier than the above:\n\n\tgit update-index --force-remove path\n\n * you did the above recovery from \"git add\" on a wrong path,\n   and you want to add it again.  The same voodoo would work in\n   this case as well.\n\n\tgit ls-tree HEAD path | git update-index --index-info\n\nWe could add \"git reset path...\" to reduce typing for the above,\nbut I am wondering if it is worth it.\n\nBTW, this shows how \"index centric\" git is.  With other SCM that\nhas only the last commit and the working tree files, you do not\nhave to worry any of these things, so it might appear that index\nis just a nuisance.  But if you do not have any \"registry of\npaths to be committed\", you cannot do a partial commit like what\nI did above (\"commit changes to all files other than\nls-files.c\") without listing all the paths to be committed, or\nfall back on CVS style \"one path at a time\", breaking an atomic\ncommit, so there is a drawback for not having an index as well.\n"},{"id":"15850","messageId":"43EC7CB0.5040804@op5.se","threadId":"3282","inReplyTo":"7vlkwjzv0w.fsf@assigned-by-dhcp.cox.net","subject":"Re: Resetting paths","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-02-10T11:44:48Z","receivedAt":"2006-02-10T11:44:48Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> \n> While I worked on parts of the system that deals with the cached\n> lstat() information, I needed a way to debug that, so I hacked\n> ls-files -t option to show entries marked as \"always matches the\n> index\" with lowercase tag letters.  This was primarily debugging\n> aid hack.\n> \n> Then I committed the whole thing with \"git commit -a\" by\n> mistake.  In order to rewind the HEAD to pre-commit state, I can\n> say \"git reset --soft HEAD^\", but after doing that, now I want\n> to unupdate the index so that ls-files.c matches the pre-commit\n> HEAD.\n> \n> \n> Have people found themselves in similar need like this?  This\n> could take different forms.\n> \n\nSometimes, yes.\n\n>  * you did \"git update-index\" on a wrong path.  This is my\n>    example and the above voodoo is a recipe for recovery.\n> \n>  * you did \"git add\" on a wrong path and you want to remove it.\n>    This is easier than the above:\n> \n> \tgit update-index --force-remove path\n> \n>  * you did the above recovery from \"git add\" on a wrong path,\n>    and you want to add it again.  The same voodoo would work in\n>    this case as well.\n> \n> \tgit ls-tree HEAD path | git update-index --index-info\n> \n> We could add \"git reset path...\" to reduce typing for the above,\n> but I am wondering if it is worth it.\n> \n\nHow about \"git update-index --undo path...\", possibly with \"git reset \npath...\" as a shorthand. Support for temporary indexes already exist, so \nit should be a simple (and atomic) operation of copying it out with the \npaths mentioned skipped, and then overwriting the current index. I'm not \nsure how well it would perform on very large repositories, but having a \nsnappish command to undo a blunder is usually welcome even if it takes \nhalf a minute or more to run.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"15904","messageId":"7vpslupj6o.fsf@assigned-by-dhcp.cox.net","threadId":"3282","inReplyTo":"43EC7CB0.5040804@op5.se","subject":"Re: Resetting paths","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-11T05:18:23Z","receivedAt":"2006-02-11T05:18:23Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n> How about \"git update-index --undo path...\", possibly with \"git reset\n> path...\" as a shorthand.\n\nWhile \"git reset path...\" may make sense, \"update-index --undo\"\ndoes not make any sense from the core point of view.  That\ncommand is about interaction between index and working tree file\nand does not know anything about \"the last commit\", \"the current\nhead commit\", nor tree objects in general, so it does not know\nwhere to get the undo information from.\n\nI'll find time to code a prototype for \"git reset path...\" up\nunless somebody beats me to it.\n"}]}