{"thread":{"id":"40220","subject":"Add passed and estimated seconds to the filter-branch on demand via --progress-eta flag","startedAt":"2015-08-30T11:45:27Z","lastAt":"2015-08-30T21:55:59Z","messageCount":2,"participants":["Gabor Bernat","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"268931","messageId":"CANy2qHcz2Kk2_S29hyPf-yMe0AgjRZkd1=R33cY10sc6v91ixA@mail.gmail.com","threadId":"40220","inReplyTo":null,"subject":"Add passed and estimated seconds to the filter-branch on demand via --progress-eta flag","fromName":"Gabor Bernat","fromEmail":"bernat@primeranks.net","sentAt":"2015-08-30T11:45:27Z","receivedAt":"2015-08-30T11:45:27Z","isPatch":false,"sender":{"key":"bernat@primeranks.net","avatar":"https://gravatar.com/avatar/d65839a755b3bd913bc793c89024c14017d830f72093b3e2c248011c8854e79e?d=mp&s=160"},"body":"Hello,\n\nI've submitted this first to this list as a feature request, however\nin the meantime with the help of Jeff King <peff@peff.net>, Junio C\nHamano <gitster@pobox.com>, Eric Sunshine <sunshine@sunshineco.com>\nand Mikael Magnusson <mikachu@gmail.com> came up with solution, so now\nI submit it as a patch. Here follows a patch, I really hope I got\nright the format:\n\nFrom 620e69d10a1bfcfcace347cbb95991d75fd23a1d Mon Sep 17 00:00:00 2001\nFrom: Gabor Bernat <gabor.bernat@gravityrd.com>\nDate: Thu, 27 Aug 2015 00:46:52 +0200\nSubject: [PATCH] Add to the git filter-branch a --progress-eta flag which when\n enabled will print with the progress also the number of seconds passed since\n started plus the number of seconds predicted until the operation finishes.\n\nSigned-off-by: Gabor Bernat <gabor.bernat@gravityrd.com>\n---\n Documentation/git-filter-branch.txt |  6 ++++++\n git-filter-branch.sh                | 29 ++++++++++++++++++++++++++++-\n 2 files changed, 34 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-filter-branch.txt\nb/Documentation/git-filter-branch.txt\nindex 73fd9e8..6ca9d6e 100644\n--- a/Documentation/git-filter-branch.txt\n+++ b/Documentation/git-filter-branch.txt\n@@ -194,6 +194,12 @@ to other tags will be rewritten to point to the\nunderlying commit.\n  directory or when there are already refs starting with\n  'refs/original/', unless forced.\n\n+--progress-eta::\n+ If specified will print the number of seconds elapsed and the predicted\n+ count of seconds remaining until the operation is expected to finish. Note\n+ that for calculating the eta the global speed up to the current point is\n+ used.\n+\n <rev-list options>...::\n  Arguments for 'git rev-list'.  All positive refs included by\n  these options are rewritten.  You may also specify options\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 5b3f63d..7b565fb 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -105,6 +105,7 @@ filter_subdir=\n orig_namespace=refs/original/\n force=\n prune_empty=\n+progress_eta=\n remap_to_ancestor=\n while :\n do\n@@ -129,6 +130,11 @@ do\n  prune_empty=t\n  continue\n  ;;\n+ --progress-eta)\n+ shift\n+ progress_eta=t\n+ continue\n+ ;;\n  -*)\n  ;;\n  *)\n@@ -277,9 +283,30 @@ test $commits -eq 0 && die \"Found nothing to rewrite\"\n # Rewrite the commits\n\n git_filter_branch__commit_count=0\n+\n+case \"$progress_eta\" in\n+ t)\n+ start=$(PATH=`getconf PATH` awk 'BEGIN{srand();print srand()}')\n+ ;;\n+ '')\n+ ;;\n+esac\n+\n while read commit parents; do\n  git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))\n- printf \"\\rRewrite $commit ($git_filter_branch__commit_count/$commits)\"\n+\n+ case \"$progress_eta\" in\n+ t)\n+ now=$(PATH=`getconf PATH` awk 'BEGIN{srand();print srand()}')\n+ elapsed=$(($now - $start))\n+ remaining_second=$(( ($commits - $git_filter_branch__commit_count) *\n$elapsed / $git_filter_branch__commit_count ))\n+ progress=\" ($elapsed seconds passed, remaining $remaining_second predicted)\"\n+ ;;\n+ '')\n+ progress=\"\"\n+ esac\n+\n+ printf \"\\rRewrite $commit\n($git_filter_branch__commit_count/$commits)$progress\"\n\n  case \"$filter_subdir\" in\n  \"\")\n-- \n2.5.1.408.g14905ed.dirty\n\nLet me know if this works for adding it to the main repository,\n\nThanks a lot,\n\n\nBernát GÁBOR\n"},{"id":"268951","messageId":"CAPig+cS3rWfN_y73Tn_ryJpMzS8UvCs_ZaWAfYeJ82wJDp_ALw@mail.gmail.com","threadId":"40220","inReplyTo":"CANy2qHcz2Kk2_S29hyPf-yMe0AgjRZkd1=R33cY10sc6v91ixA@mail.gmail.com","subject":"Re: Add passed and estimated seconds to the filter-branch on demand via --progress-eta flag","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-08-30T21:55:59Z","receivedAt":"2015-08-30T21:55:59Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Aug 30, 2015 at 7:45 AM, Gabor Bernat <bernat@primeranks.net> wrote:\n> I've submitted this first to this list as a feature request, however\n> in the meantime with the help of Jeff King <peff@peff.net>, Junio C\n> Hamano <gitster@pobox.com>, Eric Sunshine <sunshine@sunshineco.com>\n> and Mikael Magnusson <mikachu@gmail.com> came up with solution, so now\n> I submit it as a patch. Here follows a patch, I really hope I got\n> right the format:\n\nThanks for the patch. Since the actual implementation is still under\ndiscussion[1], I'll just comment on the properties of the patch\nitself...\n\nIn order to allow \"git-am --scissors\" to extract the patch\nautomatically from your email, you'd want to separate the above\ncommentary from the below patch with a scissor line \"-- >8 --\".\nAlternately (and more commonly), you can make git-am happy by placing\nthe commentary (such as the above text) below the \"---\" line just\nunder your sign-off and before the diffstat.\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/276531\n\n> From 620e69d10a1bfcfcace347cbb95991d75fd23a1d Mon Sep 17 00:00:00 2001\n> From: Gabor Bernat <gabor.bernat@gravityrd.com>\n> Date: Thu, 27 Aug 2015 00:46:52 +0200\n\nWhen including a patch in a mail message like this (separated by a \"--\n>8--\" line), you'd normally drop these headers. \"From\" isn't\nmeaningful outside your own repository, and \"From:\" (with colon) and\n\"Date:\" are normally inferred from the email itself. In this case,\nhowever, use of \"From:\" (with a colon) is appropriate since it differs\nfrom the email address of your message.\n\nAn alternative is to use git-send-email to take care of the mail\nheader situation for you automatically.\n\n> Subject: [PATCH] Add to the git filter-branch a --progress-eta flag which when\n>  enabled will print with the progress also the number of seconds passed since\n>  started plus the number of seconds predicted until the operation finishes.\n\nA commit message should consist a one-line brief explanation of the\nchange (shorter than 72 characters), followed by a blank line,\nfollowed by one or more paragraphs explaining the change. The first\nline should also be prefixed by the area the patch is touching, is\ntypically not capitalized, and lacks a full-stop (period). For\nexample:\n\n    filter-branch: add --progress-eta option to estimate completion time\n\n    In addition to reporting how many commits have been processed and\n    how many remain, when --progress-eta is enabled, also report how\n    much time has elapsed and an estimate of how much remains.\n\n> Signed-off-by: Gabor Bernat <gabor.bernat@gravityrd.com>\n> ---\n\nThis is where you'd place commentary such as that which is currently\nat the top of this email (as well as the small comment at the very\nbottom), particularly if you are using git-send-email to send the\npatch.\n\nUnfortunately, this patch is severely whitespace damaged, as if it had\nbeen pasted into the message via Gmail's user-interface. Using\ngit-send-email can help avoid such damage.\n\n>  Documentation/git-filter-branch.txt |  6 ++++++\n>  git-filter-branch.sh                | 29 ++++++++++++++++++++++++++++-\n>  2 files changed, 34 insertions(+), 1 deletion(-)\n>\n> diff --git a/Documentation/git-filter-branch.txt\n> b/Documentation/git-filter-branch.txt\n> index 73fd9e8..6ca9d6e 100644\n> --- a/Documentation/git-filter-branch.txt\n> +++ b/Documentation/git-filter-branch.txt\n> @@ -194,6 +194,12 @@ to other tags will be rewritten to point to the\n> underlying commit.\n>   directory or when there are already refs starting with\n>   'refs/original/', unless forced.\n>\n> +--progress-eta::\n> + If specified will print the number of seconds elapsed and the predicted\n> + count of seconds remaining until the operation is expected to finish. Note\n> + that for calculating the eta the global speed up to the current point is\n> + used.\n> +\n>  <rev-list options>...::\n>   Arguments for 'git rev-list'.  All positive refs included by\n>   these options are rewritten.  You may also specify options\n> diff --git a/git-filter-branch.sh b/git-filter-branch.sh\n> index 5b3f63d..7b565fb 100755\n> --- a/git-filter-branch.sh\n> +++ b/git-filter-branch.sh\n> @@ -105,6 +105,7 @@ filter_subdir=\n>  orig_namespace=refs/original/\n>  force=\n>  prune_empty=\n> +progress_eta=\n>  remap_to_ancestor=\n>  while :\n>  do\n> @@ -129,6 +130,11 @@ do\n>   prune_empty=t\n>   continue\n>   ;;\n> + --progress-eta)\n> + shift\n> + progress_eta=t\n> + continue\n> + ;;\n>   -*)\n>   ;;\n>   *)\n> @@ -277,9 +283,30 @@ test $commits -eq 0 && die \"Found nothing to rewrite\"\n>  # Rewrite the commits\n>\n>  git_filter_branch__commit_count=0\n> +\n> +case \"$progress_eta\" in\n> + t)\n> + start=$(PATH=`getconf PATH` awk 'BEGIN{srand();print srand()}')\n> + ;;\n> + '')\n> + ;;\n> +esac\n> +\n>  while read commit parents; do\n>   git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))\n> - printf \"\\rRewrite $commit ($git_filter_branch__commit_count/$commits)\"\n> +\n> + case \"$progress_eta\" in\n> + t)\n> + now=$(PATH=`getconf PATH` awk 'BEGIN{srand();print srand()}')\n> + elapsed=$(($now - $start))\n> + remaining_second=$(( ($commits - $git_filter_branch__commit_count) *\n> $elapsed / $git_filter_branch__commit_count ))\n> + progress=\" ($elapsed seconds passed, remaining $remaining_second predicted)\"\n> + ;;\n> + '')\n> + progress=\"\"\n> + esac\n> +\n> + printf \"\\rRewrite $commit\n> ($git_filter_branch__commit_count/$commits)$progress\"\n>\n>   case \"$filter_subdir\" in\n>   \"\")\n> --\n> 2.5.1.408.g14905ed.dirty\n>\n> Let me know if this works for adding it to the main repository,\n>\n> Thanks a lot,\n>\n>\n> Bernát GÁBOR\n"}]}