{"thread":{"id":"35437","subject":"[PATCH/WIP] Repair DF conflicts during fetch.","startedAt":"2013-11-29T17:57:37Z","lastAt":"2013-12-01T15:03:58Z","messageCount":4,"participants":["Tom Miller","Thomas Rast","Thomas Miller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"231273","messageId":"1385747858-29343-1-git-send-email-jackerran@gmail.com","threadId":"35437","inReplyTo":null,"subject":"[PATCH/WIP] Repair DF conflicts during fetch.","fromName":"Tom Miller","fromEmail":"jackerran@gmail.com","sentAt":"2013-11-29T17:57:37Z","receivedAt":"2013-11-29T17:57:37Z","isPatch":true,"sender":{"key":"jackerran@gmail.com","avatar":null},"body":"I encountered a directory/file conflict when running `git fetch --prune\norigin`.  I figured passing --prune would automatically fix DF conflicts. After\nlooking in the code I found that prune is called after fetching. It seemed to\nbe intentional according historical commits. I made this patch to change it,\nwhich seems to work as I expected it to. This patch doesn't have any tests and\nit breaks the output when it does prune branches. I'm looking for guidance to\nhelp with fixing the broken output. I tried to figure out a way to do it on my\nown but I realize that I don't have the expertise with the codebase or C.\n\nThanks, for any help that I may recieve in advaned this is my first time\nposting. If I have submitted this wrong I applogize and look forward to any\nadvice that I may recieve in correcting my mistakes.\n\nTom Miller (1):\n  Repair DF conflicts during fetch.\n\n builtin/fetch.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\n-- \n1.8.5.rc3.dirty\n"},{"id":"231274","messageId":"1385747858-29343-2-git-send-email-jackerran@gmail.com","threadId":"35437","inReplyTo":"1385747858-29343-1-git-send-email-jackerran@gmail.com","subject":"[PATCH/WIP] Repair DF conflicts during fetch.","fromName":"Tom Miller","fromEmail":"jackerran@gmail.com","sentAt":"2013-11-29T17:57:38Z","receivedAt":"2013-11-29T17:57:38Z","isPatch":true,"sender":{"key":"jackerran@gmail.com","avatar":null},"body":"When a DF conflict occurs during a fetch, --prune should be able to fix\nit. When fetching with --prune, the fetching process happens before\npruning causing the DF conflict to persist and report an error. This\npatch prunes before fetching, thus correcting DF conflicts during a\nfetch.\n\nSigned-off-by: Tom Miller <jackerran@gmail.com>\n---\n builtin/fetch.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex bd7a101..f7959d0 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -824,11 +824,6 @@ static int do_fetch(struct transport *transport,\n \n \tif (tags == TAGS_DEFAULT && autotags)\n \t\ttransport_set_option(transport, TRANS_OPT_FOLLOWTAGS, \"1\");\n-\tif (fetch_refs(transport, ref_map)) {\n-\t\tfree_refs(ref_map);\n-\t\tretcode = 1;\n-\t\tgoto cleanup;\n-\t}\n \tif (prune) {\n \t\t/*\n \t\t * If --tags was specified, pretend that the user gave us\n@@ -857,6 +852,11 @@ static int do_fetch(struct transport *transport,\n \t\t\tprune_refs(transport->remote->fetch, transport->remote->fetch_refspec_nr, ref_map);\n \t\t}\n \t}\n+\tif (fetch_refs(transport, ref_map)) {\n+\t\tfree_refs(ref_map);\n+\t\tretcode = 1;\n+\t\tgoto cleanup;\n+\t}\n \tfree_refs(ref_map);\n \n \t/* if neither --no-tags nor --tags was specified, do automated tag\n-- \n1.8.5.rc3.dirty\n"},{"id":"231276","messageId":"871u1zf2nd.fsf@thomasrast.ch","threadId":"35437","inReplyTo":"1385747858-29343-2-git-send-email-jackerran@gmail.com","subject":"Re: [PATCH/WIP] Repair DF conflicts during fetch.","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2013-11-29T19:07:02Z","receivedAt":"2013-11-29T19:07:02Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Tom Miller <jackerran@gmail.com> writes:\n\n> When a DF conflict occurs during a fetch, --prune should be able to fix\n> it. When fetching with --prune, the fetching process happens before\n> pruning causing the DF conflict to persist and report an error. This\n> patch prunes before fetching, thus correcting DF conflicts during a\n> fetch.\n>\n> Signed-off-by: Tom Miller <jackerran@gmail.com>\n> ---\n>  builtin/fetch.c | 10 +++++-----\n>  1 file changed, 5 insertions(+), 5 deletions(-)\n\nGood catch.\n\nI can't comment on the correctness of the patch right now, but here's a\ntest you could steal.  It just reproduces what you describe, and I did\nverify that it confirms the fix ;-)\n\ndiff --git i/t/t5510-fetch.sh w/t/t5510-fetch.sh\nindex 5d4581d..a981125 100755\n--- i/t/t5510-fetch.sh\n+++ w/t/t5510-fetch.sh\n@@ -614,4 +614,18 @@ test_expect_success 'all boundary commits are excluded' '\n \ttest_bundle_object_count .git/objects/pack/pack-${pack##pack\t}.pack 3\n '\n \n+test_expect_success 'branchname D/F conflict resolved by --prune' '\n+\tgit branch dir/file &&\n+\tgit clone . prune-df-conflict &&\n+\tgit branch -D dir/file &&\n+\tgit branch dir &&\n+\t(\n+\t\tcd prune-df-conflict &&\n+\t\tgit fetch --prune &&\n+\t\tgit rev-parse origin/dir >../actual\n+\t) &&\n+\tgit rev-parse dir >expect &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n\n\n-- \nThomas Rast\ntr@thomasrast.ch\n"},{"id":"231331","messageId":"CAECD2aGaL84n01-0fuNfyy-mx8NPKz2Vbhy3LpTgdOxgWayERw@mail.gmail.com","threadId":"35437","inReplyTo":"871u1zf2nd.fsf@thomasrast.ch","subject":"Re: [PATCH/WIP] Repair DF conflicts during fetch.","fromName":"Thomas Miller","fromEmail":"jackerran@gmail.com","sentAt":"2013-12-01T15:03:58Z","receivedAt":"2013-12-01T15:03:58Z","isPatch":true,"sender":{"key":"jackerran@gmail.com","avatar":null},"body":"On Fri, Nov 29, 2013 at 1:07 PM, Thomas Rast <tr@thomasrast.ch> wrote:\n> Tom Miller <jackerran@gmail.com> writes:\n>\n>> When a DF conflict occurs during a fetch, --prune should be able to fix\n>> it. When fetching with --prune, the fetching process happens before\n>> pruning causing the DF conflict to persist and report an error. This\n>> patch prunes before fetching, thus correcting DF conflicts during a\n>> fetch.\n>>\n>> Signed-off-by: Tom Miller <jackerran@gmail.com>\n>> ---\n>>  builtin/fetch.c | 10 +++++-----\n>>  1 file changed, 5 insertions(+), 5 deletions(-)\n>\n> Good catch.\n>\n> I can't comment on the correctness of the patch right now, but here's a\n> test you could steal.  It just reproduces what you describe, and I did\n> verify that it confirms the fix ;-)\n>\n> diff --git i/t/t5510-fetch.sh w/t/t5510-fetch.sh\n> index 5d4581d..a981125 100755\n> --- i/t/t5510-fetch.sh\n> +++ w/t/t5510-fetch.sh\n> @@ -614,4 +614,18 @@ test_expect_success 'all boundary commits are excluded' '\n>         test_bundle_object_count .git/objects/pack/pack-${pack##pack    }.pack 3\n>  '\n>\n> +test_expect_success 'branchname D/F conflict resolved by --prune' '\n> +       git branch dir/file &&\n> +       git clone . prune-df-conflict &&\n> +       git branch -D dir/file &&\n> +       git branch dir &&\n> +       (\n> +               cd prune-df-conflict &&\n> +               git fetch --prune &&\n> +               git rev-parse origin/dir >../actual\n> +       ) &&\n> +       git rev-parse dir >expect &&\n> +       test_cmp expect actual\n> +'\n> +\n>  test_done\n>\n>\n> --\n> Thomas Rast\n> tr@thomasrast.ch\n\nThanks, I appreciate the test. I have added it and gave credit via a\n\"Tested-by\" section. I have been looking into adding a pruning header\nto \"fix\" the output, but that is just the first solution I've been able to\ncome up with. I believe before I have an elegant solution I'll have to\nread the code more carefully and brush up on my C.\n\nThanks,\nTom Miller\n\nPS. I apologize for the duplicate message the mailing list rejected my\nfirst for not being plaintext only.\n"}]}