{"thread":{"id":"69","subject":"[PATCH] checkout-cache -a should not extract unmerged stages","startedAt":"2005-04-17T05:30:43Z","lastAt":"2005-04-17T22:00:14Z","messageCount":2,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"441","messageId":"7vy8bi0y2k.fsf@assigned-by-dhcp.cox.net","threadId":"69","inReplyTo":null,"subject":"[PATCH] checkout-cache -a should not extract unmerged stages","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-17T05:30:43Z","receivedAt":"2005-04-17T05:30:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When checkout-cache -a is run, currently it attempts to extract\neach existing unmerged stage to the same destination and\ncomplains to what it itself has done.  This is nonsensical.\n\nPresumably, the user is running checkout-cache -a in order to\nverify the result of the part that has cleanly been merged.  So\ncheck out only stage 0 entries and give warnings for paths that\nare unmerged.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n checkout-cache.c |   11 +++++++++++\n 1 files changed, 11 insertions(+)\n\ncheckout-cache.c: 431b7032576f40d93a08be801e26f76c168ed57b\n--- checkout-cache.c\n+++ checkout-cache.c\t2005-04-16 22:23:15.000000000 -0700\n@@ -121,10 +121,21 @@\n \n static int checkout_all(void)\n {\n+\tstruct cache_entry *unmerge_skipping = NULL;\n \tint i;\n \n \tfor (i = 0; i < active_nr ; i++) {\n \t\tstruct cache_entry *ce = active_cache[i];\n+\t\tif (ce_stage(ce)) {\n+\t\t\tif (!unmerge_skipping ||\n+\t\t\t    strcmp(unmerge_skipping->name, ce->name))\n+\t\t\t\tfprintf(stderr,\n+\t\t\t\t\t\"checkout-cache: needs merge %s\\n\",\n+\t\t\t\t\tce->name);\n+\t\t\tunmerge_skipping = ce;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tunmerge_skipping = NULL;\n \t\tif (checkout_entry(ce) < 0)\n \t\t\treturn -1;\n \t}\n\n"},{"id":"548","messageId":"7vis2lvzbl.fsf@assigned-by-dhcp.cox.net","threadId":"69","inReplyTo":"7vy8bi0y2k.fsf@assigned-by-dhcp.cox.net","subject":"(Resend) [PATCH] checkout-cache -a should not extract unmerged stages","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-17T22:00:14Z","receivedAt":"2005-04-17T22:00:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus,\n\n    do you have any particular reason you did not want the patch\nto skip unmerged ones when \"checkout-cache -a\" is done, and if\nso could you let me know?\n\nHere is what happens before the patch:\n\n    $ ls -al\n    total 16\n    drwxrwsr-x  3 junio src 4096 Apr 17 14:30 ./\n    drwxrwsr-x  8 junio src 4096 Apr 17 14:17 ../\n    drwxr-sr-x  3 junio src 4096 Apr 17 14:30 .git/\n    -rw-rw-r--  1 junio src   29 Apr 17 14:30 SS\n    $ show-files --stage\n    100644 9e26851b98ab7dd3a3b9653a2efb9b4de0465310 0 SS\n    100644 e14bafaadce6c34768ba2ff8b3c6419e8839e7d2 1 TT\n    100644 99ef1b30fc6d6ea186d6eac62619e1afd65ad64e 2 TT\n    100644 033b9385f7a29882a6b4b34f67b20e2304d3489d 3 TT\n    $ ../++linus/checkout-cache -a\n    checkout-cache: SS already exists\n    checkout-cache: TT already exists\n    checkout-cache: TT already exists\n    $ ls -al\n    total 20\n    drwxrwsr-x  3 junio src 4096 Apr 17 14:31 ./\n    drwxrwsr-x  8 junio src 4096 Apr 17 14:17 ../\n    drwxr-sr-x  3 junio src 4096 Apr 17 14:30 .git/\n    -rw-rw-r--  1 junio src   29 Apr 17 14:30 SS\n    -rw-rw-r--  1 junio src  363 Apr 17 14:31 TT\n\nSee those two warning for TT?  It has extracted stage 1 and\ncomplaining about what it has done when it goes on to extract\nstage 2 and 3.\n\nAt this point what is in TT is from the stage 1.\n\nThis behaviour is somewhat defensible, in that you are giving\nthe user a ready access to the \"original\" (from stage 1), and he\ncan continue cat-file blob other stages to decide what to do.\nBut I think that the way the user wants to resolve the unmerged\nstate is not our business and it is not particulary useful for\nthe plumbing layer to assume that he would always need stage 1\ncontents to arrive the merged result (e.g. sdiff between stage 2\nand stage 3 would not require stage 1).\n\nWith the patch, you get this:\n\n    $ checkout-cache -a\n    checkout-cache: SS already exists\n    checkout-cache: needs merge TT\n    $ ls -al\n    total 16\n    drwxrwsr-x  3 junio src 4096 Apr 17 14:32 ./\n    drwxrwsr-x  8 junio src 4096 Apr 17 14:17 ../\n    drwxr-sr-x  3 junio src 4096 Apr 17 14:30 .git/\n    -rw-rw-r--  1 junio src   29 Apr 17 14:30 SS\n\nI think it is consistent with this behaviour you already have\nmerged:\n\n    $ ../++linus/checkout-cache SS TT\n    checkout-cache: SS already exists\n    checkout-cache: TT is unmerged.\n    $ ls -al\n    total 16\n    drwxrwsr-x  3 junio src 4096 Apr 17 14:32 ./\n    drwxrwsr-x  8 junio src 4096 Apr 17 14:17 ../\n    drwxr-sr-x  3 junio src 4096 Apr 17 14:30 .git/\n    -rw-rw-r--  1 junio src   29 Apr 17 14:30 SS\n\nAttached is a re-diff with an updated message.  \n\nI could also send you a patch that implements an alternative\nstrategy.  With or without \"-a\", checkout of unmerged files can\nresult in something like this:\n\n    $ checkout-cache -a\n    checkout-cache: SS already exists\n    checkout-cache: storing stage 1 for TT in TT~1~\n    checkout-cache: storing stage 2 for TT in TT~2~\n    checkout-cache: storing stage 3 for TT in TT~3~\n    $ ls -al\n    total 28\n    drwxrwsr-x  3 junio src 4096 Apr 17 14:55 ./\n    drwxrwsr-x  8 junio src 4096 Apr 17 14:17 ../\n    drwxr-sr-x  3 junio src 4096 Apr 17 14:30 .git/\n    -rw-rw-r--  1 junio src   29 Apr 17 14:30 SS\n    -rw-rw-r--  1 junio src  363 Apr 17 14:55 TT~1\n    -rw-rw-r--  1 junio src  363 Apr 17 14:55 TT~2\n    -rw-rw-r--  1 junio src  363 Apr 17 14:55 TT~3\n\nMaybe these two behaviours can be controlled with another\noption (say, -m).\n\nPetr, do you think this alternative behaviour would be useful\nfor Cogito when it starts using \"read-tree -m\"?\n\n----------------------------------------------------------------\nWhen checkout-cache -a is run, currently it attempts to extract\nall existing unmerged stages to the same destination and\ncomplains to what it itself has done for the first stage when it\ntries to extract the later stages.  This is nonsensical.  Just\nreport the unmerged state and let the user sort the mess out\nusing \"show-files --unmerged\" and \"cat-file blob\".\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n checkout-cache.c |   11 +++++++++++\n 1 files changed, 11 insertions(+)\n\n--- ++linus/checkout-cache.c\t2005-04-17 13:57:04.000000000 -0700\n+++ ++junio/checkout-cache.c\t2005-04-17 14:35:11.000000000 -0700\n@@ -137,10 +137,21 @@\n \n static int checkout_all(void)\n {\n+\tstruct cache_entry *unmerge_skipping = NULL;\n \tint i;\n \n \tfor (i = 0; i < active_nr ; i++) {\n \t\tstruct cache_entry *ce = active_cache[i];\n+\t\tif (ce_stage(ce)) {\n+\t\t\tif (!unmerge_skipping ||\n+\t\t\t    strcmp(unmerge_skipping->name, ce->name))\n+\t\t\t\tfprintf(stderr,\n+\t\t\t\t\t\"checkout-cache: needs merge %s\\n\",\n+\t\t\t\t\tce->name);\n+\t\t\tunmerge_skipping = ce;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tunmerge_skipping = NULL;\n \t\tif (checkout_entry(ce) < 0)\n \t\t\treturn -1;\n \t}\n\n\n"}]}