{"thread":{"id":"36767","subject":"Re: [PATCH] contrib: add convert-grafts-to-replace-refs.sh","startedAt":"2014-05-27T21:19:47Z","lastAt":"2014-05-27T22:00:10Z","messageCount":2,"participants":["Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"242816","messageId":"CAPig+cR4G916TwqGDRMr9fAH=SZkUB8kqGy3Hy5YBHZLgUw8ig@mail.gmail.com","threadId":"36767","inReplyTo":"20140527182719.14437.62235.chriscool@tuxfamily.org","subject":"Re: [PATCH] contrib: add convert-grafts-to-replace-refs.sh","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-05-27T21:19:47Z","receivedAt":"2014-05-27T21:19:47Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tuesday, May 27, 2014, Christian Couder <chriscool@tuxfamily.org> wrote:\n>\n> This script adds into contrib/ an example script to convert\n> grafts from an existing grafts file into replace refs using\n> the new --graft option of \"git replace\".\n>\n> While at it let's mention this new script in the\n> \"git replace\" documentation for the --graft option.\n>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n>  Documentation/git-replace.txt             |  4 +++-\n>  contrib/convert-grafts-to-replace-refs.sh | 24 ++++++++++++++++++++++++\n>  2 files changed, 27 insertions(+), 1 deletion(-)\n>  create mode 100755 contrib/convert-grafts-to-replace-refs.sh\n>\n> diff --git a/Documentation/git-replace.txt b/Documentation/git-replace.txt\n> index 491875e..e1be2e6 100644\n> --- a/Documentation/git-replace.txt\n> +++ b/Documentation/git-replace.txt\n> @@ -79,7 +79,9 @@ OPTIONS\n>         content as <commit> except that its parents will be\n>         [<parent>...] instead of <commit>'s parents. A replacement ref\n>         is then created to replace <commit> with the newly created\n> -       commit.\n> +       commit. See contrib/convert-grafts-to-replace-refs.sh for an\n> +       example script based on this option that can convert grafts to\n> +       replace refs.\n>\n>  -l <pattern>::\n>  --list <pattern>::\n> diff --git a/contrib/convert-grafts-to-replace-refs.sh b/contrib/convert-grafts-to-replace-refs.sh\n> new file mode 100755\n> index 0000000..2404cc6\n> --- /dev/null\n> +++ b/contrib/convert-grafts-to-replace-refs.sh\n> @@ -0,0 +1,24 @@\n> +#!/bin/sh\n> +\n> +# You should execute this script in the repository where you\n> +# want to convert grafts to replace refs.\n> +\n> +die () {\n> +       echo >&2 \"$@\"\n> +       exit 1\n> +}\n> +\n> +GRAFTS_FILE=\"${GIT_DIR:-.git}/info/grafts\"\n> +\n> +test -f \"$GRAFTS_FILE\" || die \"Could not find graft file: '$GRAFTS_FILE'\"\n> +\n> +grep '^[^# ]' \"$GRAFTS_FILE\" | while read definition\n> +do\n> +       test -n \"$definition\" && {\n> +               echo \"Converting: $definition\"\n> +               git replace --graft $definition || die \"Convertion failed for: $definition\"\n\ns/Convertion/Conversion/\n\n> +       }\n> +done\n> +\n> +echo \"Success! All the grafts in '$GRAFTS_FILE' have been converted to replace refs!\"\n> +echo \"You should now move away or delete the grafts file: '$GRAFTS_FILE'\"\n\nRather than merely giving advice, would it make sees for the script\nrename the file (adding .bak or some such) and report that it did so?\n"},{"id":"242819","messageId":"xmqqwqd6evbp.fsf@gitster.dls.corp.google.com","threadId":"36767","inReplyTo":"CAPig+cR4G916TwqGDRMr9fAH=SZkUB8kqGy3Hy5YBHZLgUw8ig@mail.gmail.com","subject":"Re: [PATCH] contrib: add convert-grafts-to-replace-refs.sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-27T22:00:10Z","receivedAt":"2014-05-27T22:00:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n>> +echo \"Success! All the grafts in '$GRAFTS_FILE' have been converted to replace refs!\"\n>> +echo \"You should now move away or delete the grafts file: '$GRAFTS_FILE'\"\n>\n> Rather than merely giving advice, would it make sees for the script\n> rename the file (adding .bak or some such) and report that it did so?\n\nYeah, I would say so.\n"}]}