{"thread":{"id":"4169","subject":"Merge with local conflicts in new files","startedAt":"2006-05-16T22:00:10Z","lastAt":"2006-05-17T08:50:41Z","messageCount":10,"participants":["Santi","Junio C Hamano","Pavel Roskin","Jakub Narebski","Martin Langhoff"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"20081","messageId":"8aa486160605161500m1dd8428cj@mail.gmail.com","threadId":"4169","inReplyTo":null,"subject":"Merge with local conflicts in new files","fromName":"Santi","fromEmail":"sbejar@gmail.com","sentAt":"2006-05-16T22:00:10Z","receivedAt":"2006-05-16T22:00:10Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Hi *,\n\n       In the case of:\n\n- You merge from a branch with new files\n- You have these files in the working directory\n- You do not have these files in the HEAD.\n\n   The end result is that you lose the content of these files.\n\n   So an additional check for the merge is to check for these dirty\nbut not in HEAD files.\n\n   Here is a test that reproduce it. I expect the merge to fail and\nwith the content of foo being bar.\n\ntest_description='Test merge with local conflicts in new files'\n. ./test-lib.sh\n\ntest_expect_success 'prepare repository' \\\n'echo \"Hello\" > init &&\ngit add init &&\ngit commit -m \"Initial commit\" &&\ngit branch B &&\necho \"foo\" > foo &&\ngit add foo &&\ngit commit -m \"File: foo\" &&\ngit checkout B &&\necho \"bar\" > foo '\n\ntest_expect_code 1 'Merge with local conflicts in new files' 'git\nmerge \"merge msg\" B master'\n\ntest_done\n\nThanks.\n"},{"id":"20083","messageId":"8aa486160605161512g4d38b7f0y@mail.gmail.com","threadId":"4169","inReplyTo":"8aa486160605161500m1dd8428cj@mail.gmail.com","subject":"Re: Merge with local conflicts in new files","fromName":"Santi","fromEmail":"sbejar@gmail.com","sentAt":"2006-05-16T22:12:31Z","receivedAt":"2006-05-16T22:12:31Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Sorry, the test is wrong. Use this:\n\ntest_description='Test merge with local conflicts in new files'\n. ./test-lib.sh\n\ntest_expect_success 'prepare repository' \\\n'echo \"Hello\" > init &&\ngit add init &&\ngit commit -m \"Initial commit\" &&\ngit checkout -b B &&\necho \"foo\" > foo &&\ngit add foo &&\ngit commit -m \"File: foo\" &&\ngit checkout master &&\necho \"bar\" > foo &&\n'\n\ntest_expect_code 1 'Merge with local conflicts in new files' 'git\nmerge \"merge msg\" HEAD B'\n\ntest_done\n"},{"id":"20086","messageId":"7v1wut61aj.fsf@assigned-by-dhcp.cox.net","threadId":"4169","inReplyTo":"8aa486160605161500m1dd8428cj@mail.gmail.com","subject":"Re: Merge with local conflicts in new files","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-16T22:40:52Z","receivedAt":"2006-05-16T22:40:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santi <sbejar@gmail.com> writes:\n\n>       In the case of:\n>\n> - You merge from a branch with new files\n> - You have these files in the working directory\n> - You do not have these files in the HEAD.\n\nand\n\n - You have not told git that these files matter.\n\n>...\n> test_expect_success 'prepare repository' \\\n> 'echo \"Hello\" > init &&\n> git add init &&\n> git commit -m \"Initial commit\" &&\n> git branch B &&\n> echo \"foo\" > foo &&\n> git add foo &&\n> git commit -m \"File: foo\" &&\n> git checkout B &&\n> echo \"bar\" > foo '\n\nAt this point, you have not told git that foo is a file that is\nrelevant on branch B, so git considers it a fair game to\noverwrite.\n\nAt least, that was the original reasoning.\n\nIt happens not just during the ordinary \"git-merge\", by the way.\nIf you are on branch B that did not have 'foo', created 'foo'\nand switched to branch A (which has 'foo') before telling the\nindex that you care about your version of 'foo' on branch B,\n'foo' from branch A will overwrite your throwaway copy in the\nworking tree:\n\n\t$ git branch\n\t* master\n        $ git branch another\n\t$ echo 'New file' >afile\n        $ git add afile\n        $ git commit -m 'Add afile'\n        $ git checkout another\n        $ ls afile\n\tls: afile: No such file or directory\n        $ echo 'Lost file' >afile\n        $ git checkout master\n        $ cat afile\n        New file\n\nWe acquired \"git apply\" which does take notice when you have\nsuch an untracked file in the working tree that conflicts with\nwhat it does to the index, and I think its behaviour sometimes\nis more user friendly and safer than what the merge does\ncurrently (but it irritates people some other times).\n\nThis is totally untested, but on top of \"next\" you could do\nsomething like this, perhaps.\n\nWe _might_ want to do this conditionally, only when the user\nasks, though.  I dunno.  Being able to blow away irrelevant\nfiles is sometimes a good thing, so we _might_ want to have a\nreverse logic to \"git apply\" that makes it blow away untracked\nworking tree files under \"--index\" option.\n\n-- >8 --\n\ndiff --git a/read-tree.c b/read-tree.c\nindex aa6172b..185a73f 100644\n--- a/read-tree.c\n+++ b/read-tree.c\n@@ -453,8 +453,18 @@ static int merged_entry(struct cache_ent\n \t\t\tinvalidate_ce_path(old);\n \t\t}\n \t}\n-\telse\n+\telse {\n+\t\t/*\n+\t\t * Originally we did not have a cache entry here but\n+\t\t * are creating a new file as a result of the merge.\n+\t\t * Do we want to lose the untracked working tree files?\n+\t\t */\n+\t\tstruct stat st;\n+\n+\t\tif (!lstat(merge->name, &st))\n+\t\t\tdie(\"Untracked working tree file '%s' would be overwritten by merge.\", merge->name);\n \t\tinvalidate_ce_path(merge);\n+\t}\n \tmerge->ce_flags &= ~htons(CE_STAGEMASK);\n \tadd_cache_entry(merge, ADD_CACHE_OK_TO_ADD);\n \treturn 1;\n@@ -701,7 +711,7 @@ static int bind_merge(struct cache_entry\n \t\treturn error(\"Cannot do a bind merge of %d trees\\n\",\n \t\t\t     merge_size);\n \tif (!a)\n-\t\treturn merged_entry(old, NULL);\n+\t\treturn merged_entry(old, old);\n \tif (old)\n \t\tdie(\"Entry '%s' overlaps.  Cannot bind.\", a->name);\n \n@@ -736,7 +746,7 @@ static int oneway_merge(struct cache_ent\n \t\t}\n \t\treturn keep_entry(old);\n \t}\n-\treturn merged_entry(a, NULL);\n+\treturn merged_entry(a, old);\n }\n \n static int read_cache_unmerged(void)\n"},{"id":"20090","messageId":"8aa486160605161611p4c9ddbc0v@mail.gmail.com","threadId":"4169","inReplyTo":"7v1wut61aj.fsf@assigned-by-dhcp.cox.net","subject":"Re: Merge with local conflicts in new files","fromName":"Santi","fromEmail":"sbejar@gmail.com","sentAt":"2006-05-16T23:11:29Z","receivedAt":"2006-05-16T23:11:29Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2006/5/17, Junio C Hamano <junkio@cox.net>:\n> Santi <sbejar@gmail.com> writes:\n>\n> >       In the case of:\n> >\n> > - You merge from a branch with new files\n> > - You have these files in the working directory\n> > - You do not have these files in the HEAD.\n>\n> and\n>\n>  - You have not told git that these files matter.\n\nFor me it is the other way, all my files matter but git can do\nwhatever it wants with the ones it controls.\n\n>\n> This is totally untested, but on top of \"next\" you could do\n> something like this, perhaps.\n\nThanks, it works here.\n\nSanti\n"},{"id":"20092","messageId":"7vu07p35xn.fsf@assigned-by-dhcp.cox.net","threadId":"4169","inReplyTo":"8aa486160605161611p4c9ddbc0v@mail.gmail.com","subject":"Re: Merge with local conflicts in new files","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-16T23:28:52Z","receivedAt":"2006-05-16T23:28:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Santi <sbejar@gmail.com> writes:\n\n> 2006/5/17, Junio C Hamano <junkio@cox.net>:\n>> Santi <sbejar@gmail.com> writes:\n>>\n>> >       In the case of:\n>> >\n>> > - You merge from a branch with new files\n>> > - You have these files in the working directory\n>> > - You do not have these files in the HEAD.\n>>\n>> and\n>>\n>>  - You have not told git that these files matter.\n>\n> For me it is the other way, all my files matter but git can do\n> whatever it wants with the ones it controls.\n\nYou really do not mean that.\n\nIf you told git a file matters, and have local modifications to\nthe file in the working tree that you have not run update-index\nyet, merge and apply should be careful not to overwrite your\nchanges that is not ready while doing whatever thing they have\nto do.  And they are careful, because you have told git that\nthey matter, and the way you tell git that they matter is to\nhave entries for them in the index.\n"},{"id":"20108","messageId":"1147852052.31879.50.camel@dv","threadId":"4169","inReplyTo":"7vu07p35xn.fsf@assigned-by-dhcp.cox.net","subject":"Re: Merge with local conflicts in new files","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2006-05-17T07:47:32Z","receivedAt":"2006-05-17T07:47:32Z","isPatch":false,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello, Junio!\n\nOn Tue, 2006-05-16 at 16:28 -0700, Junio C Hamano wrote:\n> Santi <sbejar@gmail.com> writes:\n> \n> > 2006/5/17, Junio C Hamano <junkio@cox.net>:\n> >>  - You have not told git that these files matter.\n> >\n> > For me it is the other way, all my files matter but git can do\n> > whatever it wants with the ones it controls.\n> \n> You really do not mean that.\n> \n> If you told git a file matters, and have local modifications to\n> the file in the working tree that you have not run update-index\n> yet, merge and apply should be careful not to overwrite your\n> changes that is not ready while doing whatever thing they have\n> to do.  And they are careful, because you have told git that\n> they matter, and the way you tell git that they matter is to\n> have entries for them in the index.\n\nI'm afraid this approach, while understandable from the technical\nstandpoint, could prevent git from ever becoming a version control\nsystem that \"just works\" without any porcelains.\n\nI know a person who refuses to use any version control.  If he\nencountered this situation, he would never try any version control\nagain.\n\nAfter all, we are talking about files in the _working_ directory.  It's\nnot merely a transient appendix to the repository.  git is not the only\nplayer here.  If a file doesn't \"belong\" to git, it belongs to its\n\"supreme commander\", i.e. the user, and should be approached with utmost\ncare.\n\nMerging a branch should not cause an irreparable loss of user data.  The\nsame applies to other commands.  Exceptions can be made for commands\nthat are specifically meant to clean user data, for commands with\nspecial options (e.g. --force or --hard), and for the files explicitly\nmarked as transient (e.g. in .gitignore).\n\n-- \nRegards,\nPavel Roskin\n"},{"id":"20110","messageId":"7v8xp1jc9h.fsf_-_@assigned-by-dhcp.cox.net","threadId":"4169","inReplyTo":"8aa486160605161611p4c9ddbc0v@mail.gmail.com","subject":"[PATCH/RFC] read-tree -m -u: do not overwrite or remove untracked working tree files.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-17T08:17:46Z","receivedAt":"2006-05-17T08:17:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When a merge results in a creation of a path that did not exist\nin HEAD, and if you already have that path on the working tree,\nbecause the index has not been told about the working tree file,\nread-tree happily removes it.  The issue was brought up by Santi\nBéjar on the list.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n>> This is totally untested, but on top of \"next\" you could do\n>> something like this, perhaps.\n>\n> Thanks, it works here.\n\n  This is an updated version, applicable to the \"master\" branch.\n  The earlier one only dealt with very limited cases, and I\n  suspect it did not do the right thing when \"--reset\" is\n  involved (it would probably had broken \"git reset --hard\").\n\n  This is an RFC patch that I consider of somewhat dubious value.\n  Not the implementation quality, but the semantic change it\n  implies.  Before, we could freely work in a working tree, which\n  is just a scratch area to build the index, littered with\n  throw-away files, knowing they would not prevent merge between\n  our HEAD and other branch from happenning even if a merge needs\n  to blow them away.  With this change, it is not a case anymore.\n  Your merge will fail to proceed and you have to remove those\n  throw-away files yourself and retry the merge.  The extent of\n  the damage can be seen by the change to t1002 test this commit\n  contains.  It arguably is making things much safer by refusing to\n  proceed, so this might be a desirable change.  I am still\n  undecided.\n\n435ac2bfd2ef29c584531cd4a29c1f018f9aea13\n read-tree.c                   |   43 ++++++++++++++++++++++++---\n t/t1002-read-tree-m-u-2way.sh |   66 +++++++++++++++++++++++++++--------------\n t/t3500-cherry.sh             |    1 +\n t/t4002-diff-basic.sh         |    6 ++--\n t/t6022-merge-rename.sh       |    1 +\n 5 files changed, 87 insertions(+), 30 deletions(-)\n\n435ac2bfd2ef29c584531cd4a29c1f018f9aea13\ndiff --git a/read-tree.c b/read-tree.c\nindex e16e91b..6dc95a3 100644\n--- a/read-tree.c\n+++ b/read-tree.c\n@@ -408,7 +408,7 @@ static void verify_uptodate(struct cache\n {\n \tstruct stat st;\n \n-\tif (index_only)\n+\tif (index_only || reset)\n \t\treturn;\n \n \tif (!lstat(ce->name, &st)) {\n@@ -426,6 +426,21 @@ static void verify_uptodate(struct cache\n \tdie(\"Entry '%s' not uptodate. Cannot merge.\", ce->name);\n }\n \n+/*\n+ * We do not want to remove or overwrite a working tree file that\n+ * is not tracked.\n+ */\n+static void verify_absent(const char *path, const char *action)\n+{\n+\tstruct stat st;\n+\n+\tif (index_only || reset || !update)\n+\t\treturn;\n+\tif (!lstat(path, &st))\n+\t\tdie(\"Untracked working tree file '%s' \"\n+\t\t    \"would be %s by merge.\", path, action);\n+}\n+\n static int merged_entry(struct cache_entry *merge, struct cache_entry *old)\n {\n \tmerge->ce_flags |= htons(CE_UPDATE);\n@@ -443,6 +458,9 @@ static int merged_entry(struct cache_ent\n \t\t\tverify_uptodate(old);\n \t\t}\n \t}\n+\telse\n+\t\tverify_absent(merge->name, \"overwritten\");\n+\n \tmerge->ce_flags &= ~htons(CE_STAGEMASK);\n \tadd_cache_entry(merge, ADD_CACHE_OK_TO_ADD);\n \treturn 1;\n@@ -452,6 +470,8 @@ static int deleted_entry(struct cache_en\n {\n \tif (old)\n \t\tverify_uptodate(old);\n+\telse\n+\t\tverify_absent(ce->name, \"removed\");\n \tce->ce_mode = 0;\n \tadd_cache_entry(ce, ADD_CACHE_OK_TO_ADD);\n \treturn 1;\n@@ -487,6 +507,7 @@ static int threeway_merge(struct cache_e\n \tint count;\n \tint head_match = 0;\n \tint remote_match = 0;\n+\tconst char *path = NULL;\n \n \tint df_conflict_head = 0;\n \tint df_conflict_remote = 0;\n@@ -498,8 +519,11 @@ static int threeway_merge(struct cache_e\n \tfor (i = 1; i < head_idx; i++) {\n \t\tif (!stages[i])\n \t\t\tany_anc_missing = 1;\n-\t\telse\n+\t\telse {\n+\t\t\tif (!path)\n+\t\t\t\tpath = stages[i]->name;\n \t\t\tno_anc_exists = 0;\n+\t\t}\n \t}\n \n \tindex = stages[0];\n@@ -515,6 +539,13 @@ static int threeway_merge(struct cache_e\n \t\tremote = NULL;\n \t}\n \n+\tif (!path && index)\n+\t\tpath = index->name;\n+\tif (!path && head)\n+\t\tpath = head->name;\n+\tif (!path && remote)\n+\t\tpath = remote->name;\n+\n \t/* First, if there's a #16 situation, note that to prevent #13\n \t * and #14. \n \t */\n@@ -575,6 +606,8 @@ static int threeway_merge(struct cache_e\n \t\t    (remote_deleted && head && head_match)) {\n \t\t\tif (index)\n \t\t\t\treturn deleted_entry(index, index);\n+\t\t\telse if (path)\n+\t\t\t\tverify_absent(path, \"removed\");\n \t\t\treturn 0;\n \t\t}\n \t\t/*\n@@ -592,6 +625,8 @@ static int threeway_merge(struct cache_e\n \tif (index) {\n \t\tverify_uptodate(index);\n \t}\n+\telse if (path)\n+\t\tverify_absent(path, \"overwritten\");\n \n \tnontrivial_merge = 1;\n \n@@ -689,7 +724,7 @@ static int oneway_merge(struct cache_ent\n \t\t\t     merge_size);\n \n \tif (!a)\n-\t\treturn deleted_entry(old, NULL);\n+\t\treturn deleted_entry(old, old);\n \tif (old && same(old, a)) {\n \t\tif (reset) {\n \t\t\tstruct stat st;\n@@ -699,7 +734,7 @@ static int oneway_merge(struct cache_ent\n \t\t}\n \t\treturn keep_entry(old);\n \t}\n-\treturn merged_entry(a, NULL);\n+\treturn merged_entry(a, old);\n }\n \n static int read_cache_unmerged(void)\ndiff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh\nindex 4d175d8..8335a63 100755\n--- a/t/t1002-read-tree-m-u-2way.sh\n+++ b/t/t1002-read-tree-m-u-2way.sh\n@@ -39,7 +39,6 @@ test_expect_success \\\n      echo nitfol >nitfol &&\n      echo bozbar >bozbar &&\n      echo rezrov >rezrov &&\n-     echo yomin >yomin &&\n      git-update-index --add nitfol bozbar rezrov &&\n      treeH=`git-write-tree` &&\n      echo treeH $treeH &&\n@@ -56,7 +55,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '1, 2, 3 - no carry forward' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      git-read-tree -m -u $treeH $treeM &&\n      git-ls-files --stage >1-3.out &&\n      cmp M.out 1-3.out &&\n@@ -66,11 +66,12 @@ test_expect_success \\\n      check_cache_at frotz clean &&\n      check_cache_at nitfol clean'\n \n-echo '+100644 X 0\tyomin' >expected\n-\n test_expect_success \\\n     '4 - carry forward local addition.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n+     echo \"+100644 X 0\tyomin\" >expected &&\n+     echo yomin >yomin &&\n      git-update-index --add yomin &&\n      git-read-tree -m -u $treeH $treeM &&\n      git-ls-files --stage >4.out || return 1\n@@ -85,7 +86,9 @@ test_expect_success \\\n \n test_expect_success \\\n     '5 - carry forward local addition.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n+     git-read-tree -m -u $treeH &&\n      echo yomin >yomin &&\n      git-update-index --add yomin &&\n      echo yomin yomin >yomin &&\n@@ -103,7 +106,9 @@ test_expect_success \\\n \n test_expect_success \\\n     '6 - local addition already has the same.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n+     echo frotz >frotz &&\n      git-update-index --add frotz &&\n      git-read-tree -m -u $treeH $treeM &&\n      git-ls-files --stage >6.out &&\n@@ -117,7 +122,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '7 - local addition already has the same.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo frotz >frotz &&\n      git-update-index --add frotz &&\n      echo frotz frotz >frotz &&\n@@ -134,14 +140,16 @@ test_expect_success \\\n \n test_expect_success \\\n     '8 - conflicting addition.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo frotz frotz >frotz &&\n      git-update-index --add frotz &&\n      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'\n \n test_expect_success \\\n     '9 - conflicting addition.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo frotz frotz >frotz &&\n      git-update-index --add frotz &&\n      echo frotz >frotz &&\n@@ -149,7 +157,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '10 - path removed.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo rezrov >rezrov &&\n      git-update-index --add rezrov &&\n      git-read-tree -m -u $treeH $treeM &&\n@@ -160,7 +169,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '11 - dirty path removed.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo rezrov >rezrov &&\n      git-update-index --add rezrov &&\n      echo rezrov rezrov >rezrov &&\n@@ -168,14 +178,16 @@ test_expect_success \\\n \n test_expect_success \\\n     '12 - unmatching local changes being removed.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo rezrov rezrov >rezrov &&\n      git-update-index --add rezrov &&\n      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'\n \n test_expect_success \\\n     '13 - unmatching local changes being removed.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo rezrov rezrov >rezrov &&\n      git-update-index --add rezrov &&\n      echo rezrov >rezrov &&\n@@ -188,7 +200,8 @@ EOF\n \n test_expect_success \\\n     '14 - unchanged in two heads.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo nitfol nitfol >nitfol &&\n      git-update-index --add nitfol &&\n      git-read-tree -m -u $treeH $treeM &&\n@@ -207,7 +220,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '15 - unchanged in two heads.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo nitfol nitfol >nitfol &&\n      git-update-index --add nitfol &&\n      echo nitfol nitfol nitfol >nitfol &&\n@@ -227,14 +241,16 @@ test_expect_success \\\n \n test_expect_success \\\n     '16 - conflicting local change.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo bozbar bozbar >bozbar &&\n      git-update-index --add bozbar &&\n      if git-read-tree -m -u $treeH $treeM; then false; else :; fi'\n \n test_expect_success \\\n     '17 - conflicting local change.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo bozbar bozbar >bozbar &&\n      git-update-index --add bozbar &&\n      echo bozbar bozbar bozbar >bozbar &&\n@@ -242,7 +258,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '18 - local change already having a good result.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo gnusto >bozbar &&\n      git-update-index --add bozbar &&\n      git-read-tree -m -u $treeH $treeM &&\n@@ -254,7 +271,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '19 - local change already having a good result, further modified.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo gnusto >bozbar &&\n      git-update-index --add bozbar &&\n      echo gnusto gnusto >bozbar &&\n@@ -273,7 +291,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '20 - no local change, use new tree.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo bozbar >bozbar &&\n      git-update-index --add bozbar &&\n      git-read-tree -m -u $treeH $treeM &&\n@@ -285,7 +304,8 @@ test_expect_success \\\n \n test_expect_success \\\n     '21 - no local change, dirty cache.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index nitfol bozbar rezrov frotz &&\n+     git-read-tree --reset -u $treeH &&\n      echo bozbar >bozbar &&\n      git-update-index --add bozbar &&\n      echo gnusto gnusto >bozbar &&\n@@ -294,7 +314,7 @@ test_expect_success \\\n # Also make sure we did not break DF vs DF/DF case.\n test_expect_success \\\n     'DF vs DF/DF case setup.' \\\n-    'rm -f .git/index &&\n+    'rm -f .git/index\n      echo DF >DF &&\n      git-update-index --add DF &&\n      treeDF=`git-write-tree` &&\ndiff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh\nindex b141f89..e83bbee 100755\n--- a/t/t3500-cherry.sh\n+++ b/t/t3500-cherry.sh\n@@ -30,6 +30,7 @@ test_expect_success \\\n      git-commit -m \"Add C.\" &&\n \n      git-checkout -f master &&\n+     rm -f B C &&\n \n      echo Third >> A &&\n      git-update-index A &&\ndiff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh\nindex 769274a..56eda63 100755\n--- a/t/t4002-diff-basic.sh\n+++ b/t/t4002-diff-basic.sh\n@@ -191,7 +191,7 @@ test_expect_success \\\n     'rm -fr Z [A-Z][A-Z] &&\n      git-read-tree $tree_A &&\n      git-checkout-index -f -a &&\n-     git-read-tree -m $tree_O || return 1\n+     git-read-tree --reset $tree_O || return 1\n      git-update-index --refresh >/dev/null ;# this can exit non-zero\n      git-diff-files >.test-a &&\n      cmp_diff_files_output .test-a .test-recursive-OA'\n@@ -201,7 +201,7 @@ test_expect_success \\\n     'rm -fr Z [A-Z][A-Z] &&\n      git-read-tree $tree_B &&\n      git-checkout-index -f -a &&\n-     git-read-tree -m $tree_O || return 1\n+     git-read-tree --reset $tree_O || return 1\n      git-update-index --refresh >/dev/null ;# this can exit non-zero\n      git-diff-files >.test-a &&\n      cmp_diff_files_output .test-a .test-recursive-OB'\n@@ -211,7 +211,7 @@ test_expect_success \\\n     'rm -fr Z [A-Z][A-Z] &&\n      git-read-tree $tree_B &&\n      git-checkout-index -f -a &&\n-     git-read-tree -m $tree_A || return 1\n+     git-read-tree --reset $tree_A || return 1\n      git-update-index --refresh >/dev/null ;# this can exit non-zero\n      git-diff-files >.test-a &&\n      cmp_diff_files_output .test-a .test-recursive-AB'\ndiff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh\nindex a2d24b5..5ac2564 100755\n--- a/t/t6022-merge-rename.sh\n+++ b/t/t6022-merge-rename.sh\n@@ -111,6 +111,7 @@ test_expect_success 'pull renaming branc\n \n test_expect_success 'pull renaming branch into another renaming one' \\\n '\n+\trm -f B\n \tgit reset --hard\n \tgit checkout red\n \tgit pull . white && {\n-- \n1.3.3.g8a24\n"},{"id":"20111","messageId":"7v4pzpjc55.fsf@assigned-by-dhcp.cox.net","threadId":"4169","inReplyTo":"1147852052.31879.50.camel@dv","subject":"Re: Merge with local conflicts in new files","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-17T08:20:22Z","receivedAt":"2006-05-17T08:20:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pavel Roskin <proski@gnu.org> writes:\n\n> I'm afraid this approach, while understandable from the technical\n> standpoint, could prevent git from ever becoming a version control\n> system that \"just works\" without any porcelains.\n>\n> I know a person who refuses to use any version control.  If he\n> encountered this situation, he would never try any version control\n> again.\n>\n> After all, we are talking about files in the _working_ directory.  It's\n> not merely a transient appendix to the repository.  git is not the only\n> player here.  If a file doesn't \"belong\" to git, it belongs to its\n> \"supreme commander\", i.e. the user, and should be approached with utmost\n> care.\n\nI am biased ;-) and appreciate corrections like this.  How does\nthe updated patch I just sent out look?\n"},{"id":"20113","messageId":"e4emjq$73g$1@sea.gmane.org","threadId":"4169","inReplyTo":"7v8xp1jc9h.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH/RFC] read-tree -m -u: do not overwrite or remove untracked working tree files.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-05-17T08:24:30Z","receivedAt":"2006-05-17T08:24:30Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n>   This is an RFC patch that I consider of somewhat dubious value.\n>   Not the implementation quality, but the semantic change it\n>   implies.  Before, we could freely work in a working tree, which\n>   is just a scratch area to build the index, littered with\n>   throw-away files, knowing they would not prevent merge between\n>   our HEAD and other branch from happenning even if a merge needs\n>   to blow them away.  With this change, it is not a case anymore.\n>   Your merge will fail to proceed and you have to remove those\n>   throw-away files yourself and retry the merge.  The extent of\n>   the damage can be seen by the change to t1002 test this commit\n>   contains.  It arguably is making things much safer by refusing to\n>   proceed, so this might be a desirable change.  I am still\n>   undecided.\n\nPerhaps the behavior should be decided by the config option, e.g.\ncore.preserveWorkingTree; of course that leave us with the problem what\nvalue should be the default: the one preserving backward compatibility, or\nthe more safe one.\n\nAnd of course --force to blow away changes anyway...\n\n-- \nJakub Narebski\nWarsaw, Poland\n"},{"id":"20116","messageId":"46a038f90605170150x361892abv8df226aa899f1a95@mail.gmail.com","threadId":"4169","inReplyTo":"1147852052.31879.50.camel@dv","subject":"Re: Merge with local conflicts in new files","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2006-05-17T08:50:41Z","receivedAt":"2006-05-17T08:50:41Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 5/17/06, Pavel Roskin <proski@gnu.org> wrote:\n> If a file doesn't \"belong\" to git, it belongs to its\n> \"supreme commander\", i.e. the user, and should be approached with utmost\n> care.\n\n+1 here. Unknown files are precious (to take an Arch term) until git\nis told otherwise.\n\n> special options (e.g. --force or --hard), and for the files explicitly\n> marked as transient (e.g. in .gitignore).\n\nI think that if we turn into clobbering files listed in .gitignore\nusers will probably be screaming bloody murder. No git op should\nclobber untracked files...\n\nArch has this strange concept of allowing you to list 'junk' files. I\ncould never figure out why it would want my authorization to remove\nfiles randomly. For all its faults, cvs does the right thing -- it\nwill say 'checkout/update of foo.c blocked by foo.c in directory'. And\nif you force it with -C it will rename the local file to\n.#originalname-local or something like that.\n\nEven the files I think of as junk are actually useful and should not\nbe messed up with. Editor temp files, for instance, are often listed\nin .gitignore, and if you ask me, they are junk. Except while I am\nworking with my editor! ;-)\n\nAnother case is .project files from IDEs like Eclipse. People list\nthem in .cvsignore so that they are not committed, and yet preserved.\nThe user probably has a lot of personal settings there.\n\ncheers,\n\n\nmartin\n"}]}