{"thread":{"id":"14561","subject":"[RFC PATCH] Support copy and rename detection in fast-export.","startedAt":"2008-07-21T08:16:00Z","lastAt":"2008-07-30T18:35:35Z","messageCount":9,"participants":["Alexander Gavrilov","Johannes Schindelin","Shawn O. Pearce","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"84156","messageId":"200807211216.01694.angavrilov@gmail.com","threadId":"14561","inReplyTo":null,"subject":"[RFC PATCH] Support copy and rename detection in fast-export.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-07-21T08:16:00Z","receivedAt":"2008-07-21T08:16:00Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"Although it does not matter for Git itself, tools that\nexport to systems that explicitly track copies and\nrenames can benefit from such information.\n\nThis patch makes fast-export output correct action\nlogs when -M or -C are enabled.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n\n\tI'm thinking about Git->SVN conversion, like http://repo.or.cz/w/git2svn.git\n\n\tThe trouble with this patch is that old versions of fast-export\n\taccept -M and -C, but produce garbage if they are specified.\n\tSo the only way for the users to ensure that it is supported is\n\tto check the git version (or directly test it).\n\n\tAs a somewhat related question, in which order does fast-export\n\toutput the commits, beside topological? In particular, does it order\n\tcommits on parrallel branches (i.e. not topologically dependent) by date?\n\t\n\t-- Alexander\n\n builtin-fast-export.c  |   28 ++++++++++++++++++++++++++--\n t/t9301-fast-export.sh |   46 ++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 72 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-fast-export.c b/builtin-fast-export.c\nindex 8bea269..3225e8f 100644\n--- a/builtin-fast-export.c\n+++ b/builtin-fast-export.c\n@@ -118,10 +118,27 @@ static void show_filemodify(struct diff_queue_struct *q,\n {\n \tint i;\n \tfor (i = 0; i < q->nr; i++) {\n+\t\tstruct diff_filespec *ospec = q->queue[i]->one;\n \t\tstruct diff_filespec *spec = q->queue[i]->two;\n-\t\tif (is_null_sha1(spec->sha1))\n+\n+\t\tswitch (q->queue[i]->status) {\n+\t\tcase DIFF_STATUS_DELETED:\n \t\t\tprintf(\"D %s\\n\", spec->path);\n-\t\telse {\n+\t\t\tbreak;\n+\n+\t\tcase DIFF_STATUS_COPIED:\n+\t\tcase DIFF_STATUS_RENAMED:\n+\t\t\tprintf(\"%c \\\"%s\\\" \\\"%s\\\"\\n\", q->queue[i]->status,\n+\t\t\t       ospec->path, spec->path);\n+\n+\t\t\tif (!hashcmp(ospec->sha1, spec->sha1) &&\n+\t\t\t    ospec->mode == spec->mode)\n+\t\t\t\tbreak;\n+\t\t\t/* fallthrough */\n+\n+\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_MODIFIED:\n+\t\tcase DIFF_STATUS_ADDED:\n \t\t\t/*\n \t\t\t * Links refer to objects in another repositories;\n \t\t\t * output the SHA-1 verbatim.\n@@ -134,6 +151,13 @@ static void show_filemodify(struct diff_queue_struct *q,\n \t\t\t\tprintf(\"M %06o :%d %s\\n\", spec->mode,\n \t\t\t\t       get_object_mark(object), spec->path);\n \t\t\t}\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tdie(\"Unexpected comparison status '%c' for %s, %s\",\n+\t\t\t\tq->queue[i]->status,\n+\t\t\t\tospec->path ? ospec->path : \"none\",\n+\t\t\t\tspec->path ? spec->path : \"none\");\n \t\t}\n \t}\n }\ndiff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh\nindex f18eec9..bb595b7 100755\n--- a/t/t9301-fast-export.sh\n+++ b/t/t9301-fast-export.sh\n@@ -162,4 +162,50 @@ test_expect_success 'submodule fast-export | fast-import' '\n \n '\n \n+export GIT_AUTHOR_NAME='A U Thor'\n+export GIT_COMMITTER_NAME='C O Mitter'\n+\n+test_expect_success 'setup copies' '\n+\n+\tgit config --unset i18n.commitencoding &&\n+\tgit checkout -b copy rein &&\n+\tgit mv file file3 &&\n+\tgit commit -m move1 &&\n+\ttest_tick &&\n+\tcp file2 file4 &&\n+\tgit add file4 &&\n+\tgit mv file2 file5 &&\n+\tgit commit -m copy1 &&\n+\ttest_tick &&\n+\tcp file3 file6 &&\n+\tgit add file6 &&\n+\tgit commit -m copy2 &&\n+\ttest_tick &&\n+\techo more text >> file6 &&\n+\techo even more text >> file6 &&\n+\tgit add file6 &&\n+\tgit commit -m modify &&\n+\ttest_tick &&\n+\tcp file6 file7 &&\n+\techo test >> file7 &&\n+\tgit add file7 &&\n+\tgit commit -m copy_modify\n+\n+'\n+\n+test_expect_success 'fast-export -C -C | fast-import' '\n+\n+\tENTRY=$(git rev-parse --verify copy) &&\n+\trm -rf new &&\n+\tmkdir new &&\n+\tgit --git-dir=new/.git init &&\n+\tgit fast-export -C -C --signed-tags=strip --all > output &&\n+\tgrep \"^C \\\"file6\\\" \\\"file7\\\"\\$\" output &&\n+\tcat output |\n+\t(cd new &&\n+\t git fast-import &&\n+\t test $ENTRY = $(git rev-parse --verify refs/heads/copy))\n+\n+'\n+\n test_done\n-- \n1.5.6.3.18.gfe82\n"},{"id":"84167","messageId":"alpine.DEB.1.00.0807211207470.3305@eeepc-johanness","threadId":"14561","inReplyTo":"200807211216.01694.angavrilov@gmail.com","subject":"Re: [RFC PATCH] Support copy and rename detection in fast-export.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-21T10:17:47Z","receivedAt":"2008-07-21T10:17:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 21 Jul 2008, Alexander Gavrilov wrote:\n\n> Although it does not matter for Git itself, tools that\n> export to systems that explicitly track copies and\n> renames can benefit from such information.\n> \n> This patch makes fast-export output correct action\n> logs when -M or -C are enabled.\n\nI like it.\n\n> \tI'm thinking about Git->SVN conversion, like \n> \thttp://repo.or.cz/w/git2svn.git\n> \n> \tThe trouble with this patch is that old versions of fast-export\n> \taccept -M and -C, but produce garbage if they are specified.\n> \tSo the only way for the users to ensure that it is supported is\n> \tto check the git version (or directly test it).\n\nUnfortunately, this is so.\n\n> \tAs a somewhat related question, in which order does fast-export \n> \toutput the commits, beside topological? In particular, does it order \n> \tcommits on parrallel branches (i.e. not topologically dependent) by \n> \tdate?\n\nAFAIR it obeys topological order first, and then date order, by default.  \nThis can be changed by --topo-order.\n\nBut before you go and try to support more options with fast-export:  Some \noptions do not make sense, such as --reverse, \"a...b\", --skip, etc.\n\nI do not even think we need to bother about die()ing with such options: \nthe user should know what she is doing with fast-export.\n\nCiao,\nDscho\n"},{"id":"85105","messageId":"200807262249.18005.angavrilov@gmail.com","threadId":"14561","inReplyTo":"alpine.DEB.1.00.0807211207470.3305@eeepc-johanness","subject":"[PATCH v2] Support copy and rename detection in fast-export.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-07-26T18:49:16Z","receivedAt":"2008-07-26T18:49:16Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"Although it does not matter for Git itself, tools that\nexport to systems that explicitly track copies and\nrenames can benefit from such information.\n\nThis patch makes fast-export output correct action\nlogs when -M or -C are enabled.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n\n\tAdded a note to the fast-export documentation. When this patch\n\tis merged, it probably should be updated with the exact version.\n\n\t-- Alexander \n\n Documentation/git-fast-export.txt |    9 +++++++\n builtin-fast-export.c             |   28 +++++++++++++++++++++-\n t/t9301-fast-export.sh            |   46 +++++++++++++++++++++++++++++++++++++\n 3 files changed, 81 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt\nindex 332346c..699b69e 100644\n--- a/Documentation/git-fast-export.txt\n+++ b/Documentation/git-fast-export.txt\n@@ -36,6 +36,15 @@ when encountering a signed tag.  With 'strip', the tags will be made\n unsigned, with 'verbatim', they will be silently exported\n and with 'warn', they will be exported, but you will see a warning.\n \n+-M, -C::\n+\tPerform move and/or copy detection, as described in the\n+\tlinkgit:git-diff[1] manual page, and use it to generate\n+\trename and copy commands in the output dump.\n++\n+Note that these options are always accepted by git-fast-import,\n+but before a certain version it silently produced wrong results.\n+You should always check the git version before using them.\n+\n \n EXAMPLES\n --------\ndiff --git a/builtin-fast-export.c b/builtin-fast-export.c\nindex 8bea269..3225e8f 100644\n--- a/builtin-fast-export.c\n+++ b/builtin-fast-export.c\n@@ -118,10 +118,27 @@ static void show_filemodify(struct diff_queue_struct *q,\n {\n \tint i;\n \tfor (i = 0; i < q->nr; i++) {\n+\t\tstruct diff_filespec *ospec = q->queue[i]->one;\n \t\tstruct diff_filespec *spec = q->queue[i]->two;\n-\t\tif (is_null_sha1(spec->sha1))\n+\n+\t\tswitch (q->queue[i]->status) {\n+\t\tcase DIFF_STATUS_DELETED:\n \t\t\tprintf(\"D %s\\n\", spec->path);\n-\t\telse {\n+\t\t\tbreak;\n+\n+\t\tcase DIFF_STATUS_COPIED:\n+\t\tcase DIFF_STATUS_RENAMED:\n+\t\t\tprintf(\"%c \\\"%s\\\" \\\"%s\\\"\\n\", q->queue[i]->status,\n+\t\t\t       ospec->path, spec->path);\n+\n+\t\t\tif (!hashcmp(ospec->sha1, spec->sha1) &&\n+\t\t\t    ospec->mode == spec->mode)\n+\t\t\t\tbreak;\n+\t\t\t/* fallthrough */\n+\n+\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_MODIFIED:\n+\t\tcase DIFF_STATUS_ADDED:\n \t\t\t/*\n \t\t\t * Links refer to objects in another repositories;\n \t\t\t * output the SHA-1 verbatim.\n@@ -134,6 +151,13 @@ static void show_filemodify(struct diff_queue_struct *q,\n \t\t\t\tprintf(\"M %06o :%d %s\\n\", spec->mode,\n \t\t\t\t       get_object_mark(object), spec->path);\n \t\t\t}\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tdie(\"Unexpected comparison status '%c' for %s, %s\",\n+\t\t\t\tq->queue[i]->status,\n+\t\t\t\tospec->path ? ospec->path : \"none\",\n+\t\t\t\tspec->path ? spec->path : \"none\");\n \t\t}\n \t}\n }\ndiff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh\nindex f18eec9..bb595b7 100755\n--- a/t/t9301-fast-export.sh\n+++ b/t/t9301-fast-export.sh\n@@ -162,4 +162,50 @@ test_expect_success 'submodule fast-export | fast-import' '\n \n '\n \n+export GIT_AUTHOR_NAME='A U Thor'\n+export GIT_COMMITTER_NAME='C O Mitter'\n+\n+test_expect_success 'setup copies' '\n+\n+\tgit config --unset i18n.commitencoding &&\n+\tgit checkout -b copy rein &&\n+\tgit mv file file3 &&\n+\tgit commit -m move1 &&\n+\ttest_tick &&\n+\tcp file2 file4 &&\n+\tgit add file4 &&\n+\tgit mv file2 file5 &&\n+\tgit commit -m copy1 &&\n+\ttest_tick &&\n+\tcp file3 file6 &&\n+\tgit add file6 &&\n+\tgit commit -m copy2 &&\n+\ttest_tick &&\n+\techo more text >> file6 &&\n+\techo even more text >> file6 &&\n+\tgit add file6 &&\n+\tgit commit -m modify &&\n+\ttest_tick &&\n+\tcp file6 file7 &&\n+\techo test >> file7 &&\n+\tgit add file7 &&\n+\tgit commit -m copy_modify\n+\n+'\n+\n+test_expect_success 'fast-export -C -C | fast-import' '\n+\n+\tENTRY=$(git rev-parse --verify copy) &&\n+\trm -rf new &&\n+\tmkdir new &&\n+\tgit --git-dir=new/.git init &&\n+\tgit fast-export -C -C --signed-tags=strip --all > output &&\n+\tgrep \"^C \\\"file6\\\" \\\"file7\\\"\\$\" output &&\n+\tcat output |\n+\t(cd new &&\n+\t git fast-import &&\n+\t test $ENTRY = $(git rev-parse --verify refs/heads/copy))\n+\n+'\n+\n test_done\n-- \n1.5.6.3.18.gfe82\n"},{"id":"85113","messageId":"20080726202103.GA15769@spearce.org","threadId":"14561","inReplyTo":"200807262249.18005.angavrilov@gmail.com","subject":"Re: [PATCH v2] Support copy and rename detection in fast-export.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-07-26T20:21:03Z","receivedAt":"2008-07-26T20:21:03Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alexander Gavrilov <angavrilov@gmail.com> wrote:\n> This patch makes fast-export output correct action\n> logs when -M or -C are enabled.\n...\n> +-M, -C::\n> +\tPerform move and/or copy detection, as described in the\n> +\tlinkgit:git-diff[1] manual page, and use it to generate\n> +\trename and copy commands in the output dump.\n> ++\n> +Note that these options are always accepted by git-fast-import,\n> +but before a certain version it silently produced wrong results.\n> +You should always check the git version before using them.\n\nDo you mean to say git-fast-export in the end of the first line of\nthat last paragraph?\n\n-- \nShawn.\n"},{"id":"85117","messageId":"200807270052.55370.angavrilov@gmail.com","threadId":"14561","inReplyTo":"20080726202103.GA15769@spearce.org","subject":"Re: [PATCH v2] Support copy and rename detection in fast-export.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-07-26T20:52:54Z","receivedAt":"2008-07-26T20:52:54Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"Although it does not matter for Git itself, tools that\nexport to systems that explicitly track copies and\nrenames can benefit from such information.\n\nThis patch makes fast-export output correct action\nlogs when -M or -C are enabled.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n\n\tOn Sunday 27 July 2008 00:21:03 Shawn O. Pearce wrote:\n\t> Do you mean to say git-fast-export in the end of the first line of\n\t> that last paragraph?\n\n\tYes, of course. Thank you.\n\n\tBy the way, I see that http://git.kernel.org/?p=gitk/gitk.git;a=summary\n\thasn't been updated for 2 months. Did the main gitk repository move\n\tto some other place?\n\n\t-- Alexander\n\n Documentation/git-fast-export.txt |    9 +++++++\n builtin-fast-export.c             |   28 +++++++++++++++++++++-\n t/t9301-fast-export.sh            |   46 +++++++++++++++++++++++++++++++++++++\n 3 files changed, 81 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt\nindex 332346c..bb2f9a8 100644\n--- a/Documentation/git-fast-export.txt\n+++ b/Documentation/git-fast-export.txt\n@@ -36,6 +36,15 @@ when encountering a signed tag.  With 'strip', the tags will be made\n unsigned, with 'verbatim', they will be silently exported\n and with 'warn', they will be exported, but you will see a warning.\n \n+-M, -C::\n+\tPerform move and/or copy detection, as described in the\n+\tlinkgit:git-diff[1] manual page, and use it to generate\n+\trename and copy commands in the output dump.\n++\n+Note that these options were always accepted by git-fast-export,\n+but before a certain version it silently produced wrong results.\n+You should always check the git version before using them.\n+\n \n EXAMPLES\n --------\ndiff --git a/builtin-fast-export.c b/builtin-fast-export.c\nindex 8bea269..3225e8f 100644\n--- a/builtin-fast-export.c\n+++ b/builtin-fast-export.c\n@@ -118,10 +118,27 @@ static void show_filemodify(struct diff_queue_struct *q,\n {\n \tint i;\n \tfor (i = 0; i < q->nr; i++) {\n+\t\tstruct diff_filespec *ospec = q->queue[i]->one;\n \t\tstruct diff_filespec *spec = q->queue[i]->two;\n-\t\tif (is_null_sha1(spec->sha1))\n+\n+\t\tswitch (q->queue[i]->status) {\n+\t\tcase DIFF_STATUS_DELETED:\n \t\t\tprintf(\"D %s\\n\", spec->path);\n-\t\telse {\n+\t\t\tbreak;\n+\n+\t\tcase DIFF_STATUS_COPIED:\n+\t\tcase DIFF_STATUS_RENAMED:\n+\t\t\tprintf(\"%c \\\"%s\\\" \\\"%s\\\"\\n\", q->queue[i]->status,\n+\t\t\t       ospec->path, spec->path);\n+\n+\t\t\tif (!hashcmp(ospec->sha1, spec->sha1) &&\n+\t\t\t    ospec->mode == spec->mode)\n+\t\t\t\tbreak;\n+\t\t\t/* fallthrough */\n+\n+\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\tcase DIFF_STATUS_MODIFIED:\n+\t\tcase DIFF_STATUS_ADDED:\n \t\t\t/*\n \t\t\t * Links refer to objects in another repositories;\n \t\t\t * output the SHA-1 verbatim.\n@@ -134,6 +151,13 @@ static void show_filemodify(struct diff_queue_struct *q,\n \t\t\t\tprintf(\"M %06o :%d %s\\n\", spec->mode,\n \t\t\t\t       get_object_mark(object), spec->path);\n \t\t\t}\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tdie(\"Unexpected comparison status '%c' for %s, %s\",\n+\t\t\t\tq->queue[i]->status,\n+\t\t\t\tospec->path ? ospec->path : \"none\",\n+\t\t\t\tspec->path ? spec->path : \"none\");\n \t\t}\n \t}\n }\ndiff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh\nindex f18eec9..bb595b7 100755\n--- a/t/t9301-fast-export.sh\n+++ b/t/t9301-fast-export.sh\n@@ -162,4 +162,50 @@ test_expect_success 'submodule fast-export | fast-import' '\n \n '\n \n+export GIT_AUTHOR_NAME='A U Thor'\n+export GIT_COMMITTER_NAME='C O Mitter'\n+\n+test_expect_success 'setup copies' '\n+\n+\tgit config --unset i18n.commitencoding &&\n+\tgit checkout -b copy rein &&\n+\tgit mv file file3 &&\n+\tgit commit -m move1 &&\n+\ttest_tick &&\n+\tcp file2 file4 &&\n+\tgit add file4 &&\n+\tgit mv file2 file5 &&\n+\tgit commit -m copy1 &&\n+\ttest_tick &&\n+\tcp file3 file6 &&\n+\tgit add file6 &&\n+\tgit commit -m copy2 &&\n+\ttest_tick &&\n+\techo more text >> file6 &&\n+\techo even more text >> file6 &&\n+\tgit add file6 &&\n+\tgit commit -m modify &&\n+\ttest_tick &&\n+\tcp file6 file7 &&\n+\techo test >> file7 &&\n+\tgit add file7 &&\n+\tgit commit -m copy_modify\n+\n+'\n+\n+test_expect_success 'fast-export -C -C | fast-import' '\n+\n+\tENTRY=$(git rev-parse --verify copy) &&\n+\trm -rf new &&\n+\tmkdir new &&\n+\tgit --git-dir=new/.git init &&\n+\tgit fast-export -C -C --signed-tags=strip --all > output &&\n+\tgrep \"^C \\\"file6\\\" \\\"file7\\\"\\$\" output &&\n+\tcat output |\n+\t(cd new &&\n+\t git fast-import &&\n+\t test $ENTRY = $(git rev-parse --verify refs/heads/copy))\n+\n+'\n+\n test_done\n-- \n1.5.6.3.18.gfe82\n"},{"id":"85485","messageId":"7v7ib4hdpu.fsf@gitster.siamese.dyndns.org","threadId":"14561","inReplyTo":"200807270052.55370.angavrilov@gmail.com","subject":"Re: [PATCH v2] Support copy and rename detection in fast-export.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-29T16:11:57Z","receivedAt":"2008-07-29T16:11:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexander Gavrilov <angavrilov@gmail.com> writes:\n\n> Although it does not matter for Git itself, tools that\n> export to systems that explicitly track copies and\n> renames can benefit from such information.\n>\n> This patch makes fast-export output correct action\n> logs when -M or -C are enabled.\n>\n> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n> ---\n>\n> \tOn Sunday 27 July 2008 00:21:03 Shawn O. Pearce wrote:\n> \t> Do you mean to say git-fast-export in the end of the first line of\n> \t> that last paragraph?\n>\n> \tYes, of course. Thank you.\n\nAlexander, Shawn, what is the status of this patch?  Has it been reviewed\nsufficiently and is ready for application?\n\n>  Documentation/git-fast-export.txt |    9 +++++++\n>  builtin-fast-export.c             |   28 +++++++++++++++++++++-\n>  t/t9301-fast-export.sh            |   46 +++++++++++++++++++++++++++++++++++++\n>  3 files changed, 81 insertions(+), 2 deletions(-)\n>\n> diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt\n> index 332346c..bb2f9a8 100644\n> --- a/Documentation/git-fast-export.txt\n> +++ b/Documentation/git-fast-export.txt\n> @@ -36,6 +36,15 @@ when encountering a signed tag.  With 'strip', the tags will be made\n>  unsigned, with 'verbatim', they will be silently exported\n>  and with 'warn', they will be exported, but you will see a warning.\n>  \n> +-M, -C::\n> +\tPerform move and/or copy detection, as described in the\n> +\tlinkgit:git-diff[1] manual page, and use it to generate\n> +\trename and copy commands in the output dump.\n\nI think it is more fashionable to do what 3240240 (Docs: Use\n\"-l::\\n--long\\n\" format in OPTIONS sections, 2008-06-08) did these days,\ni.e.:\n\n\t-M::\n        -C::\n        \tDescription...\n\n> ++\n> +Note that these options were always accepted by git-fast-export,\n> +but before a certain version it silently produced wrong results.\n> +You should always check the git version before using them.\n> +\n\nI do not quite follow the mention of \"before a certain version\", but I\nthink it is talking about the earlier \"fast-export\" that took any diff\noptions but did not act differently upon renamed/copied entries.  If that\nis the case, I think we can say something like this instead:\n\n\tNote that earlier versions of this command did not complain and\n\tproduced incorrect results if you gave these options.\n\nbecause docs always talk about the current version.  My reading of Dscho's\noriginal 'show_filemodify' suggests me that \"wrong results\" does not just\nmean missing rename/copy information but a renamed old entity did not get\nremoved correctly, resulting in an incorrect tree in the commit, right?\nMaybe we would want to be a bit more explicit about what kind of breakage\nyou are talking about here.\n\n> diff --git a/builtin-fast-export.c b/builtin-fast-export.c\n> index 8bea269..3225e8f 100644\n> --- a/builtin-fast-export.c\n> +++ b/builtin-fast-export.c\n> @@ -118,10 +118,27 @@ static void show_filemodify(struct diff_queue_struct *q,\n>  {\n>  \tint i;\n>  \tfor (i = 0; i < q->nr; i++) {\n> +\t\tstruct diff_filespec *ospec = q->queue[i]->one;\n>  \t\tstruct diff_filespec *spec = q->queue[i]->two;\n> -\t\tif (is_null_sha1(spec->sha1))\n> +\n> +\t\tswitch (q->queue[i]->status) {\n> +\t\tcase DIFF_STATUS_DELETED:\n>  \t\t\tprintf(\"D %s\\n\", spec->path);\n> -\t\telse {\n> +\t\t\tbreak;\n> +\n> +\t\tcase DIFF_STATUS_COPIED:\n> +\t\tcase DIFF_STATUS_RENAMED:\n> +\t\t\tprintf(\"%c \\\"%s\\\" \\\"%s\\\"\\n\", q->queue[i]->status,\n> +\t\t\t       ospec->path, spec->path);\n> +\n> +\t\t\tif (!hashcmp(ospec->sha1, spec->sha1) &&\n> +\t\t\t    ospec->mode == spec->mode)\n> +\t\t\t\tbreak;\n> +\t\t\t/* fallthrough */\n\nIf you see a copied or renamed entry, you emit \"this old path to that old\npath\" first, and then say that same path got modified.  It appears from my\nquick glance of fast-import that touching the same path more than once in\na same commit like this sequence does would work fine (it will involve two\ncalls to tree_content_set() for the same path but that is not something it\nhas to forbid, and the function doesn't).\n\n> diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh\n> index f18eec9..bb595b7 100755\n> --- a/t/t9301-fast-export.sh\n> +++ b/t/t9301-fast-export.sh\n> @@ -162,4 +162,50 @@ test_expect_success 'submodule fast-export | fast-import' '\n>  \n>  '\n>  \n> +export GIT_AUTHOR_NAME='A U Thor'\n> +export GIT_COMMITTER_NAME='C O Mitter'\n> +\n> +test_expect_success 'setup copies' '\n> +\n> +\tgit config --unset i18n.commitencoding &&\n\nThese are somewhat unusual.  Was there any reason for these exports and\nconfig?\n"},{"id":"85488","messageId":"20080729164520.GA1730@spearce.org","threadId":"14561","inReplyTo":"7v7ib4hdpu.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2] Support copy and rename detection in fast-export.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-07-29T16:45:20Z","receivedAt":"2008-07-29T16:45:20Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> Alexander Gavrilov <angavrilov@gmail.com> writes:\n> \n> > Although it does not matter for Git itself, tools that\n> > export to systems that explicitly track copies and\n> > renames can benefit from such information.\n> >\n> > This patch makes fast-export output correct action\n> > logs when -M or -C are enabled.\n> >\n> > Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n> > ---\n> >\n> > \tOn Sunday 27 July 2008 00:21:03 Shawn O. Pearce wrote:\n> > \t> Do you mean to say git-fast-export in the end of the first line of\n> > \t> that last paragraph?\n> >\n> > \tYes, of course. Thank you.\n> \n> Alexander, Shawn, what is the status of this patch?  Has it been reviewed\n> sufficiently and is ready for application?\n\nIt looked OK to me on the surface, except the one minor remark in\nthe documentation I noted above.  Other than that I am not very good\nwith the internal diff machinary so my ACK/NACK on such matters is\nworth very little, if anything.\n \n-- \nShawn.\n"},{"id":"85592","messageId":"bb6f213e0807300210r205846b4qffa9fc71d4aa6533@mail.gmail.com","threadId":"14561","inReplyTo":"7v7ib4hdpu.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2] Support copy and rename detection in fast-export.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-07-30T09:10:07Z","receivedAt":"2008-07-30T09:10:07Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"On Tue, Jul 29, 2008 at 8:11 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Alexander Gavrilov <angavrilov@gmail.com> writes:\n>> ++\n>> +Note that these options were always accepted by git-fast-export,\n>> +but before a certain version it silently produced wrong results.\n>> +You should always check the git version before using them.\n>> +\n>\n> I do not quite follow the mention of \"before a certain version\", but I\n> think it is talking about the earlier \"fast-export\" that took any diff\n> options but did not act differently upon renamed/copied entries.  If that\n> is the case, I think we can say something like this instead:\n>\n>        Note that earlier versions of this command did not complain and\n>        produced incorrect results if you gave these options.\n>\n> because docs always talk about the current version.  My reading of Dscho's\n> original 'show_filemodify' suggests me that \"wrong results\" does not just\n> mean missing rename/copy information but a renamed old entity did not get\n> removed correctly, resulting in an incorrect tree in the commit, right?\n> Maybe we would want to be a bit more explicit about what kind of breakage\n> you are talking about here.\n\nYes, broken renames is what I've been thinking of when I wrote that.\n\nAs fast-export is mainly meant to be used by third-party conversion\nscripts, which are not bundled together with git, unsuspecting users\nmight try to run them using an old git version. The main point of my\nnote is that scripts should always check the version if they want to\nuse these options. It probably should also specify the exact value to\ncompare to, e.g:\n\n        Note that before git 1.6 this command did not complain and produced\n        incorrect results if you gave these options. Your scripts should always\n        check the version before using them.\n\n\n> If you see a copied or renamed entry, you emit \"this old path to that old\n> path\" first, and then say that same path got modified.  It appears from my\n> quick glance of fast-import that touching the same path more than once in\n> a same commit like this sequence does would work fine (it will involve two\n> calls to tree_content_set() for the same path but that is not something it\n> has to forbid, and the function doesn't).\n\nI'm sorry, but I don't quite understand what are you suggesting by\nthis paragraph. Yes, fast-import understands double modification, and\nmy test includes a check for this case. Of course, conversion scripts\nfor dumber targets might need to do one-line lookahead to eliminate\nnon-100% copies.\n\n\n>> diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh\n>> index f18eec9..bb595b7 100755\n>> --- a/t/t9301-fast-export.sh\n>> +++ b/t/t9301-fast-export.sh\n>> @@ -162,4 +162,50 @@ test_expect_success 'submodule fast-export | fast-import' '\n>>\n>>  '\n>>\n>> +export GIT_AUTHOR_NAME='A U Thor'\n>> +export GIT_COMMITTER_NAME='C O Mitter'\n>> +\n>> +test_expect_success 'setup copies' '\n>> +\n>> +     git config --unset i18n.commitencoding &&\n>\n> These are somewhat unusual.  Was there any reason for these exports and\n> config?\n>\n\nt9301-fast-export.sh earlier changes these parameters to test\nautomatic conversion to utf8. I reset them back before my test, in\norder to be able to test the import by comparing SHA-1 (encoding\nconversion changes it). There may be a better way to do it, though.\n"},{"id":"85662","messageId":"7vvdyn5ifc.fsf@gitster.siamese.dyndns.org","threadId":"14561","inReplyTo":"bb6f213e0807300210r205846b4qffa9fc71d4aa6533@mail.gmail.com","subject":"Re: [PATCH v2] Support copy and rename detection in fast-export.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-30T18:35:35Z","receivedAt":"2008-07-30T18:35:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alexander Gavrilov\" <angavrilov@gmail.com> writes:\n\n>> If you see a copied or renamed entry, you emit \"this old path to that old\n>> path\" first, and then say that same path got modified.  It appears from my\n>> quick glance of fast-import that touching the same path more than once in\n>> a same commit like this sequence does would work fine (it will involve two\n>> calls to tree_content_set() for the same path but that is not something it\n>> has to forbid, and the function doesn't).\n>\n> I'm sorry, but I don't quite understand what are you suggesting by\n> this paragraph.\n\nSorry for the unmarked remark --- this was not a question, suggestion nor\ncomplaint, but just a plain observation.  I should have ended the\nparagraph with \"--- I think it's all good.\" to avoid confusion.\n\n>>> +export GIT_AUTHOR_NAME='A U Thor'\n>>> +export GIT_COMMITTER_NAME='C O Mitter'\n>>> +\n>>> +test_expect_success 'setup copies' '\n>>> +\n>>> +     git config --unset i18n.commitencoding &&\n>>\n>> These are somewhat unusual.  Was there any reason for these exports and\n>> config?\n>>\n>\n> t9301-fast-export.sh earlier changes these parameters to test\n> automatic conversion to utf8.\n\nYeah, I noticed that while looking at wider context, after I sent the\nmessage you are responding to.\n\nAnyway, thanks for the patch.  Applied and pushed out.\n"}]}