{"thread":{"id":"26817","subject":"\"git rm\" is not a valid merge resolution?","startedAt":"2011-03-21T18:27:14Z","lastAt":"2011-03-21T20:24:52Z","messageCount":6,"participants":["Piotr Krukowiecki","Matthieu Moy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"163948","messageId":"4D879882.4070608@gmail.com","threadId":"26817","inReplyTo":null,"subject":"\"git rm\" is not a valid merge resolution?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-21T18:27:14Z","receivedAt":"2011-03-21T18:27:14Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"Hi,\n\ngit-status shows a hint that says\n    use \"git add/rm <file>...\" as appropriate to mark resolution\n \nBut if I \"git rm file\" the file gets deleted. Is this really the \nappropriate merge resolution?\n\nI would expect \"git rm\" to maybe reset all the merge changes but\nit seems to just delete the file.\n\nI doubt that when you get merge conflicts you would like to delete\nthe file. That might be the case when in one of merge parents\nthe file was deleted, but not if both files existed.\n\nWhen deleting the file it shows a message \"needs merge\", perhaps\nthe intention was to not delete the file in such case?\n\nSo maybe:\n- don't list \"rm\" as appropriate to mark resolution, or\n- list it only if the files was deleted on one parent\n\n\nExample:\n\n$ git init\n$ echo a > a \n$ git add a\n$ git commit -a -m a\n$ echo b > a\n$ git commit -a -m b\n$ git checkout  -b topic HEAD^\n$ echo c > a\n$ git commit -a -m c\n\n$ git merge master\nAuto-merging a\nCONFLICT (content): Merge conflict in a\nAutomatic merge failed; fix conflicts and then commit the result.\n\n$ git status\n# On branch topic\n# Unmerged paths:\n#   (use \"git add/rm <file>...\" as appropriate to mark resolution)\n#\n#\tboth modified:      a\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n$ git rm a\na: needs merge\nrm 'a'\n\n$ git status\n# On branch topic\n# Changes to be committed:\n#\n#\tdeleted:    a\n#\n\n  \n-- \nPiotr Krukowiecki\n"},{"id":"163951","messageId":"vpqpqpk724l.fsf@bauges.imag.fr","threadId":"26817","inReplyTo":"4D879882.4070608@gmail.com","subject":"Re: \"git rm\" is not a valid merge resolution?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-03-21T18:35:38Z","receivedAt":"2011-03-21T18:35:38Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n\n> Hi,\n>\n> git-status shows a hint that says\n>     use \"git add/rm <file>...\" as appropriate to mark resolution\n>  \n> But if I \"git rm file\" the file gets deleted. Is this really the \n> appropriate merge resolution?\n\nIn most cases, no, but when you have a modify/delete conflict for\nexample, \"git rm\" is one of the candidates to resolve the conflict. The\nhint gives the general case.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"163959","messageId":"7vvczcp8w7.fsf@alter.siamese.dyndns.org","threadId":"26817","inReplyTo":"4D879882.4070608@gmail.com","subject":"Re: \"git rm\" is not a valid merge resolution?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-21T19:32:08Z","receivedAt":"2011-03-21T19:32:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n\n> git-status shows a hint that says\n>     use \"git add/rm <file>...\" as appropriate to mark resolution\n>  \n> But if I \"git rm file\" the file gets deleted. Is this really the \n> appropriate merge resolution?\n>\n> I would expect \"git rm\" to maybe reset all the merge changes but\n> it seems to just delete the file.\n\nYes, if your side has a commit that updates a path since branches forked\n(e.g. fixing a minor bug in an implementation of a function defined\nthere), and the other branch you are merging removed the path (e.g. fixing\na higher level callers and made that buggy function no longer necessary),\ntaking their removal can be a valid conflict resolution.\n"},{"id":"163968","messageId":"4D87AD79.5000806@gmail.com","threadId":"26817","inReplyTo":"vpqpqpk724l.fsf@bauges.imag.fr","subject":"Re: \"git rm\" is not a valid merge resolution?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-21T19:56:41Z","receivedAt":"2011-03-21T19:56:41Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"W dniu 21.03.2011 19:35, Matthieu Moy pisze:\n> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n> \n>> Hi,\n>>\n>> git-status shows a hint that says\n>>     use \"git add/rm <file>...\" as appropriate to mark resolution\n>>  \n>> But if I \"git rm file\" the file gets deleted. Is this really the \n>> appropriate merge resolution?\n> \n> In most cases, no, but when you have a modify/delete conflict for\n> example, \"git rm\" is one of the candidates to resolve the conflict. The\n> hint gives the general case.\n\nI think this is not completely true. You can stage removal of a file with\ngit add, but it's harder than use of git rm.\n\nThis is something I don't understand. Why is there a difference between\nremoving files and (adding files or removing content)?\n\nYou must use special flags to \"git add\" to remove files, while you don't\nneed such flags to add file or remove content.\n\nAll changes are tracked. You won't loose your data if you remove the\nfile by mistake. It is the same as remove some content by mistake.\n\n\nIs it caused by the name of the command (\"add\")? Some people would be\nsurprised if \"git add\" marked removed file for removal. But I think\nsome would be already surprised that you have to \"add\" your changes.\n\nOr maybe it is caused by the fact that \"git tracks content\" (if I\nremember correctly)? I don't see a problem here. The command just\ntells git what content it should track. \"git add\" does not say\n\"track this change (file path addition/file deletion)\" but\n\"track this file path content\", so if the file got deleted there\nis nothing to track.\n\n\nMaybe the command should be named \"stage\". You should stage your\nchanges. Add the file deletion is the same change as file addition.\n\nYou would do\n   \n    git stage addedfile\n    git stage deletedfile\n    git stage changedfile\n\nThis would be consistent.\n\n(For me it doesn't need to be \"stage\" name. It could be handled by\n\"add\").\n\n\nCurrently it works like this:\n\n   git add untracked # Adds untracked file \n   git add . # Adds all untracked files\n\n   rm tracked\n   git add tracked # Does not stage the delete\n   git add . # Does not stage the delete\n   git add -A tracked # This works - stages deletion of tracked file\n\n   git add -u # Stages all tracked changes, also new/deleted tracked files\n   git add -A # Stages all changes, also new/deleted untracked files\n\n   # No way to do following (without listing files explicitly):\n\n   # 1. Added several new files, but has also several tracked files changed\n   #    and want to only add new files\n\n   # 2. Removed several tracked files, but has also several other tracked\n   #    files changed and want to only remove deleted files. \n\n-- \nPiotr Krukowiecki\n"},{"id":"163970","messageId":"4D87AE83.6080008@gmail.com","threadId":"26817","inReplyTo":"7vvczcp8w7.fsf@alter.siamese.dyndns.org","subject":"Re: \"git rm\" is not a valid merge resolution?","fromName":"Piotr Krukowiecki","fromEmail":"piotr.krukowiecki@gmail.com","sentAt":"2011-03-21T20:01:07Z","receivedAt":"2011-03-21T20:01:07Z","isPatch":false,"sender":{"key":"piotr.krukowiecki@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3259959?v=4"},"body":"W dniu 21.03.2011 20:32, Junio C Hamano pisze:\n> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n> \n>> git-status shows a hint that says\n>>     use \"git add/rm <file>...\" as appropriate to mark resolution\n>>  \n>> But if I \"git rm file\" the file gets deleted. Is this really the \n>> appropriate merge resolution?\n>>\n>> I would expect \"git rm\" to maybe reset all the merge changes but\n>> it seems to just delete the file.\n> \n> Yes, if your side has a commit that updates a path since branches forked\n> (e.g. fixing a minor bug in an implementation of a function defined\n> there), and the other branch you are merging removed the path (e.g. fixing\n> a higher level callers and made that buggy function no longer necessary),\n> taking their removal can be a valid conflict resolution.\n\nPlease see my other mail - file deletion can also be done by \"git add\". \nI feel that suggesting something that is wrong in most cases is wrong :)\n\n-- \nPiotr Krukowiecki\n"},{"id":"163975","messageId":"7v1v20p6gb.fsf@alter.siamese.dyndns.org","threadId":"26817","inReplyTo":"4D87AE83.6080008@gmail.com","subject":"Re: \"git rm\" is not a valid merge resolution?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-21T20:24:52Z","receivedAt":"2011-03-21T20:24:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:\n\n> Please see my other mail - file deletion can also be done by \"git add\". \n\nSo what?\n\nWhile it technically is correct that \"git add\" can be asked to do so (and\nno, forbidding \"add -u\" from noticing deletion or renaming the command to\nstage to spread the confusion even more is out of the question), people\nfound that it is more natural to remove things with \"rm\", wished to have\nthat separate command, and the wish was granted.  We suggest its use when\nit is appropriate.\n\nWhat is your problem?\n"}]}