{"thread":{"id":"9814","subject":"checkout and rm","startedAt":"2007-09-07T02:59:14Z","lastAt":"2007-09-07T22:00:02Z","messageCount":2,"participants":["Jeff Jenkins","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"52840","messageId":"4F2CF06E-CCC6-4597-A1BF-663BC36B9A94@ShopWiki.com","threadId":"9814","inReplyTo":null,"subject":"checkout and rm","fromName":"Jeff Jenkins","fromEmail":"jeff@shopwiki.com","sentAt":"2007-09-07T02:59:14Z","receivedAt":"2007-09-07T02:59:14Z","isPatch":false,"sender":{"key":"jeff@shopwiki.com","avatar":null},"body":"I couldn't find a thread in the archive about this.  Here's the  \nabbreviated scenario:\n\n$ git add bar.c\n$ git-rm foo.c\nrm 'foo.c'\n$ git-status\n# On branch FOO\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       modified:   bar.c\n#       deleted:    foo.c\n#\n\n$ git-checkout master\nM       bar.c\nSwitched to branch \"master\"\n$ git-status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       modified:   bar.c\n#\n\nWhen I change branches:\n- the modified files in the index/working directory stay there  \n(that's fine)\n- the *removed* files are re-added to the working directory when the  \nbranch changes\n- the remove entries aren't in the index anymore\n\nThere was no warning about any the lost changes, and if the intent  \nwas to commit these changes to master because you were in FOO by  \naccident, then only some would be committed if you weren't paying  \nclose attention.  If working directory/index changes are going to be  \nkept when a branch switch is done, then the remove changes should be  \npropagated as well.\n\nIdeally there would be a config setting which would stop checkouts if  \nthe working directory or index were dirty (and a flag on checkout  \nwhich overrode the setting).    With stash in 1.5.3 the only reason I  \ncan think of to allow working directory changes to propagate is gone  \n(though i haven't tested how stash works with rm'd files).  At the  \nvery least, there should be a warning and a prompt if some of the  \nchanges are going to vanish by a user action\n\n-Jeff Jenkins\n"},{"id":"52952","messageId":"7v4pi62l25.fsf@gitster.siamese.dyndns.org","threadId":"9814","inReplyTo":"4F2CF06E-CCC6-4597-A1BF-663BC36B9A94@ShopWiki.com","subject":"Re: checkout and rm","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-07T22:00:02Z","receivedAt":"2007-09-07T22:00:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff Jenkins <Jeff@ShopWiki.com> writes:\n\n> With stash in 1.5.3 the only reason I\n> can think of to allow working directory changes to propagate is gone\n\nThis reasoning is utterly wrong.\n\nWe often begin exploring a solution while on one branch (perhaps\n'master'), starting with small changes in the work tree, and\nthen realize that it needs to be worked on in a separate branch:\n\n\t$ edit some work tree files\n\t$ git branch new-topic\n        $ git checkout new-topic\n\nOr maybe we would realize that the fix we started to work on\nwhile on 'master' also applies to 'maint', and do the checkout\nwithout creating a new branch:\n\n\t$ edit some work tree files\n\t$ git checkout maint\n\nIn either case, it is a _good_ thing that you can take your\nlocal changes with you when you switch branches, without extra\nstash/unstash sequence, and I do not think this is going to\nchange.\n\nAbout the \"lost remove\", I think it is related to the fact that\nwe try to be usable in a sparsely checked out work tree, and\nduring a two-way merge (aka \"switching branches\") we consider a\nmissing file equivalent to an unmodified file and this might be\na bug in the logic to implement it there.  I haven't checked\nthis conjecture and won't have time now to do the digging myself\n(you're welcome to do the digging yourself in the meantime).  It\nmay turn out to be a trivial change, but I dunno at this moment.\n"}]}