{"thread":{"id":"10470","subject":"Re: [PATCH] fast-import: Add ability to copy a path from an arbitrary commit","startedAt":"2007-10-26T07:01:57Z","lastAt":"2007-10-26T07:01:57Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57260","messageId":"20071026070157.GM14735@spearce.org","threadId":"10470","inReplyTo":"20071020155749.29528.9258.julian@quantumfyre.co.uk","subject":"Re: [PATCH] fast-import: Add ability to copy a path from an arbitrary commit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-26T07:01:57Z","receivedAt":"2007-10-26T07:01:57Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Julian Phillips <julian@quantumfyre.co.uk> wrote:\n> This adds the ability to copy a path from an arbitrary commit instead\n> of just from the current commit.  This is done using the 'K' version\n> of the filecopy sub-command.\n\nSo the reason I didn't apply this earlier when I was playing the role\nof \"interim maintainer\" was four fold:\n\n- There's no test cases for this new 'K' command.  Everything else\n  in fast-import has at least one test case for it, this should\n  as well.\n\n- There's a huge memory leak every time you use the 'K' command.\n  See below in the code for where.\n\n- The documentation doesn't talk about the special \"/\" source path.\n\n- I was really busy and just forgot to reply to this email.\n\nOther than that I think this is good.  I've just been too busy\nto do it myself, and I'm glad that you took it upon yourself to\nremedy that.\n \n> diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt\n> index d511967..89aefea 100644\n> --- a/Documentation/git-fast-import.txt\n> +++ b/Documentation/git-fast-import.txt\n> @@ -534,6 +534,17 @@ location has been copied to the destination any future commands\n>  applied to the source location will not impact the destination of\n>  the copy.\n>  \n> +It is also possible to copy a file or directory from a commit other\n> +than the current one.\n> +\n> +....\n> +\t'K' <dataref> SP <path> SP <path> LF\n> +....\n> +\n> +where `<dataref>` is a reference (see `filemodify` above) to the\n> +commit that the first (source) `<path>` is located in, the second\n> +`<path>` is the destination.\n> +\n\nThis should talk about the special case of the first (src) <path>\nbeing able to be \"/\" to copy the entire tree.  If I follow your\nimplementation right a src_path of \"/\" also causes the destination\npath to be ignored entirely.  Which means you cannot copy another\nbranch into a subdirectory of this branch (aka one direction of\nthe subtree merge strategy).\n\n> diff --git a/fast-import.c b/fast-import.c\n> index e9c80be..9537c63 100644\n> --- a/fast-import.c\n> +++ b/fast-import.c\n...\n> +static void copy_from_commit(\n> +\tunsigned char *src_commit, const char *src_path,\n> +        struct branch *dest_br, const char *dest_path)\n...\n> +\tload_tree(&src_br.branch_tree);\n\nThis is a huge memory leak.  You never unload this tree and return\nits data onto the freelists so we'll leak everything that wasn't\nmoved into the destination tree.\n\n-- \nShawn.\n"}]}