{"thread":{"id":"27203","subject":"[PATCH 0/1] Add new --index-filter example to git-filter-branch.txt","startedAt":"2011-04-27T18:08:03Z","lastAt":"2011-04-27T20:32:00Z","messageCount":4,"participants":["Michael O'Cleirigh","Sverre Rabbelier","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"166537","messageId":"1303927684-6513-1-git-send-email-michael.ocleirigh@rivulet.ca","threadId":"27203","inReplyTo":null,"subject":"[PATCH 0/1] Add new --index-filter example to git-filter-branch.txt","fromName":"Michael O'Cleirigh","fromEmail":"michael.ocleirigh@rivulet.ca","sentAt":"2011-04-27T18:08:03Z","receivedAt":"2011-04-27T18:08:03Z","isPatch":true,"sender":{"key":"michael.ocleirigh@rivulet.ca","avatar":"https://gravatar.com/avatar/80727c318d003bd815407d8f93c2d01ce86c233b431d24de2efef3409b9415cd?d=mp&s=160"},"body":"At work I patched git with the prevously sent --egrep-filter patch that allows\nan irregular history to be retained, like where code reorganization occured and\nyou want to keep the history from the original locations.\n\nThe comments I recieved at that time was that my case was an --index-filter\nvariant.\n\nI've reworked it into an --index-filter using the $GIT_COMMIT variable, tested\nthat it works, and have added it as an example to the git-filter-branch \ndocumentation.\n\n\n\nMichael O'Cleirigh (1):\n  Documentation/git-filter-branch: add --index-filter example\n\n Documentation/git-filter-branch.txt |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\n-- \n1.7.2.3\n"},{"id":"166538","messageId":"1303927684-6513-2-git-send-email-michael.ocleirigh@rivulet.ca","threadId":"27203","inReplyTo":"1303927684-6513-1-git-send-email-michael.ocleirigh@rivulet.ca","subject":"[PATCH 1/1] Documentation/git-filter-branch: add --index-filter example","fromName":"Michael O'Cleirigh","fromEmail":"michael.ocleirigh@rivulet.ca","sentAt":"2011-04-27T18:08:04Z","receivedAt":"2011-04-27T18:08:04Z","isPatch":true,"sender":{"key":"michael.ocleirigh@rivulet.ca","avatar":"https://gravatar.com/avatar/80727c318d003bd815407d8f93c2d01ce86c233b431d24de2efef3409b9415cd?d=mp&s=160"},"body":"Added an example using git ls-tree on the $GIT_COMMIT and then filtering\nwhat should remain in the history using egrep.\n\nThis allows multiple paths accross history to be retained when filtering a branch.\n---\n Documentation/git-filter-branch.txt |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\nindex 9dc1f2a..e80bc01 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -248,6 +248,19 @@ To set a commit (which typically is at the tip of another\n history) to be the parent of the current initial commit, in\n order to paste the other history behind the current history:\n \n+-----------------------------------------------------------------------------------------------------------------------------------\n+git filter-branch --prune-empty --index-filter 'git ls-tree $GIT_COMMIT | egrep \\\n+\"(top-dir-A|top-dir-B|consolidated-dir-C)\" | git mktree | xargs git read-tree -i -m'\n+-----------------------------------------------------------------------------------------------------------------------------------\n+\n+The --subdirectory-filter works great when all commits of interest have\n+that path but sometimes you have a history that contains an irregular \n+structure. i.e. that was reorganized at some point and you would like to \n+keep the prior history.\n+\n+For each commit the top-dir-A, top-dir-B and consolidated-dir-C paths (if they exist)\n+are kept (and everything else discarded). \n+\n -------------------------------------------------------------------\n git filter-branch --parent-filter 'sed \"s/^\\$/-p <graft-id>/\"' HEAD\n -------------------------------------------------------------------\n-- \n1.7.2.3\n"},{"id":"166546","messageId":"BANLkTimPirVXdqwckoqEhU05iqvvpce-8g@mail.gmail.com","threadId":"27203","inReplyTo":"1303927684-6513-1-git-send-email-michael.ocleirigh@rivulet.ca","subject":"Re: [PATCH 0/1] Add new --index-filter example to git-filter-branch.txt","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2011-04-27T19:24:44Z","receivedAt":"2011-04-27T19:24:44Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Wed, Apr 27, 2011 at 20:08, Michael O'Cleirigh\n<michael.ocleirigh@rivulet.ca> wrote:\n> At work I patched git with the prevously sent --egrep-filter patch that allows\n> an irregular history to be retained, like where code reorganization occured and\n> you want to keep the history from the original locations.\n>\n> The comments I recieved at that time was that my case was an --index-filter\n> variant.\n>\n> I've reworked it into an --index-filter using the $GIT_COMMIT variable, tested\n> that it works, and have added it as an example to the git-filter-branch\n> documentation.\n\nMeta nit: for a 1 patch series we would usually put this kind of\nintroduction after the --- in the actual patch.\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"166552","messageId":"4DB87D40.9090302@kdbg.org","threadId":"27203","inReplyTo":"1303927684-6513-2-git-send-email-michael.ocleirigh@rivulet.ca","subject":"Re: [PATCH 1/1] Documentation/git-filter-branch: add --index-filter example","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2011-04-27T20:32:00Z","receivedAt":"2011-04-27T20:32:00Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"I like the example, particularly because it shows that it is not\nnecessary to start off with index's content in an --index-filter, and\nthat the index can be replaced with read-tree -i, i.e., GIT_INDEX_FILE\njuggling is not necessary for some tasks.\n\nAm 27.04.2011 20:08, schrieb Michael O'Cleirigh:\n> Added an example using git ls-tree on the $GIT_COMMIT and then filtering\n> what should remain in the history using egrep.\n> \n> This allows multiple paths accross history to be retained when filtering a branch.\n\nSign-off is missing. Please keep lines well below 75 characters. Write\n'Add an example...' rather than 'Added an example...'.\n\n> ---\n>  Documentation/git-filter-branch.txt |   13 +++++++++++++\n>  1 files changed, 13 insertions(+), 0 deletions(-)\n> \n> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt\n> index 9dc1f2a..e80bc01 100644\n> --- a/Documentation/git-filter-branch.txt\n> +++ b/Documentation/git-filter-branch.txt\n> @@ -248,6 +248,19 @@ To set a commit (which typically is at the tip of another\n>  history) to be the parent of the current initial commit, in\n>  order to paste the other history behind the current history:\n>  \n> +-----------------------------------------------------------------------------------------------------------------------------------\n> +git filter-branch --prune-empty --index-filter 'git ls-tree $GIT_COMMIT | egrep \\\n> +\"(top-dir-A|top-dir-B|consolidated-dir-C)\" | git mktree | xargs git read-tree -i -m'\n> +-----------------------------------------------------------------------------------------------------------------------------------\n> +\n> +The --subdirectory-filter works great when all commits of interest have\n> +that path but sometimes you have a history that contains an irregular \n> +structure. i.e. that was reorganized at some point and you would like to \n> +keep the prior history.\n> +\n> +For each commit the top-dir-A, top-dir-B and consolidated-dir-C paths (if they exist)\n> +are kept (and everything else discarded). \n> +\n>  -------------------------------------------------------------------\n>  git filter-branch --parent-filter 'sed \"s/^\\$/-p <graft-id>/\"' HEAD\n>  -------------------------------------------------------------------\n\nThis places the new text in the middle of another example, doesn't it?\n\nThe prefered style of examples to give motivation first, then the\nexample command, then a description of command details. I would drop the\nsentence \"i.e. ... was reoranized... history\" because it does not add\nvalue for the reader (I can think of other equally or even more likely\nreason why the interesting path structure is irregular).\n\nThe example looks better when it is broken into more lines, e.g. like this:\n\n-----------------------------------------------------------\ngit filter-branch --prune-empty --index-filter '\n\t\tgit ls-tree $GIT_COMMIT |\n\t\tegrep \"(top-dir-A|top-dir-B|other-dir-C)\" |\n \t\tgit mktree | xargs git read-tree -i -m'\n-----------------------------------------------------------\n\nAnd the dash lines are just as long as necessary.\n\n-- Hannes\n"}]}