On Sun, Aug 30, 2015 at 7:45 AM, Gabor Bernat <ber...@primeranks.net> wrote:
> I've submitted this first to this list as a feature request, however
> in the meantime with the help of Jeff King <p...@peff.net>, Junio C
> Hamano <gits...@pobox.com>, Eric Sunshine <sunsh...@sunshineco.com>
> and Mikael Magnusson <mika...@gmail.com> came up with solution, so now
> I submit it as a patch. Here follows a patch, I really hope I got
> right the format:

Thanks for the patch. Since the actual implementation is still under
discussion[1], I'll just comment on the properties of the patch
itself...

In order to allow "git-am --scissors" to extract the patch
automatically from your email, you'd want to separate the above
commentary from the below patch with a scissor line "-- >8 --".
Alternately (and more commonly), you can make git-am happy by placing
the commentary (such as the above text) below the "---" line just
under your sign-off and before the diffstat.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/276531

> From 620e69d10a1bfcfcace347cbb95991d75fd23a1d Mon Sep 17 00:00:00 2001
> From: Gabor Bernat <gabor.ber...@gravityrd.com>
> Date: Thu, 27 Aug 2015 00:46:52 +0200

When including a patch in a mail message like this (separated by a "--
>8--" line), you'd normally drop these headers. "From" isn't
meaningful outside your own repository, and "From:" (with colon) and
"Date:" are normally inferred from the email itself. In this case,
however, use of "From:" (with a colon) is appropriate since it differs
from the email address of your message.

An alternative is to use git-send-email to take care of the mail
header situation for you automatically.

> Subject: [PATCH] Add to the git filter-branch a --progress-eta flag which when
>  enabled will print with the progress also the number of seconds passed since
>  started plus the number of seconds predicted until the operation finishes.

A commit message should consist a one-line brief explanation of the
change (shorter than 72 characters), followed by a blank line,
followed by one or more paragraphs explaining the change. The first
line should also be prefixed by the area the patch is touching, is
typically not capitalized, and lacks a full-stop (period). For
example:

    filter-branch: add --progress-eta option to estimate completion time

    In addition to reporting how many commits have been processed and
    how many remain, when --progress-eta is enabled, also report how
    much time has elapsed and an estimate of how much remains.

> Signed-off-by: Gabor Bernat <gabor.ber...@gravityrd.com>
> ---

This is where you'd place commentary such as that which is currently
at the top of this email (as well as the small comment at the very
bottom), particularly if you are using git-send-email to send the
patch.

Unfortunately, this patch is severely whitespace damaged, as if it had
been pasted into the message via Gmail's user-interface. Using
git-send-email can help avoid such damage.

>  Documentation/git-filter-branch.txt |  6 ++++++
>  git-filter-branch.sh                | 29 ++++++++++++++++++++++++++++-
>  2 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-filter-branch.txt
> b/Documentation/git-filter-branch.txt
> index 73fd9e8..6ca9d6e 100644
> --- a/Documentation/git-filter-branch.txt
> +++ b/Documentation/git-filter-branch.txt
> @@ -194,6 +194,12 @@ to other tags will be rewritten to point to the
> underlying commit.
>   directory or when there are already refs starting with
>   'refs/original/', unless forced.
>
> +--progress-eta::
> + If specified will print the number of seconds elapsed and the predicted
> + count of seconds remaining until the operation is expected to finish. Note
> + that for calculating the eta the global speed up to the current point is
> + used.
> +
>  <rev-list options>...::
>   Arguments for 'git rev-list'.  All positive refs included by
>   these options are rewritten.  You may also specify options
> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> index 5b3f63d..7b565fb 100755
> --- a/git-filter-branch.sh
> +++ b/git-filter-branch.sh
> @@ -105,6 +105,7 @@ filter_subdir=
>  orig_namespace=refs/original/
>  force=
>  prune_empty=
> +progress_eta=
>  remap_to_ancestor=
>  while :
>  do
> @@ -129,6 +130,11 @@ do
>   prune_empty=t
>   continue
>   ;;
> + --progress-eta)
> + shift
> + progress_eta=t
> + continue
> + ;;
>   -*)
>   ;;
>   *)
> @@ -277,9 +283,30 @@ test $commits -eq 0 && die "Found nothing to rewrite"
>  # Rewrite the commits
>
>  git_filter_branch__commit_count=0
> +
> +case "$progress_eta" in
> + t)
> + start=$(PATH=`getconf PATH` awk 'BEGIN{srand();print srand()}')
> + ;;
> + '')
> + ;;
> +esac
> +
>  while read commit parents; do
>   git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
> - printf "\rRewrite $commit ($git_filter_branch__commit_count/$commits)"
> +
> + case "$progress_eta" in
> + t)
> + now=$(PATH=`getconf PATH` awk 'BEGIN{srand();print srand()}')
> + elapsed=$(($now - $start))
> + remaining_second=$(( ($commits - $git_filter_branch__commit_count) *
> $elapsed / $git_filter_branch__commit_count ))
> + progress=" ($elapsed seconds passed, remaining $remaining_second predicted)"
> + ;;
> + '')
> + progress=""
> + esac
> +
> + printf "\rRewrite $commit
> ($git_filter_branch__commit_count/$commits)$progress"
>
>   case "$filter_subdir" in
>   "")
> --
> 2.5.1.408.g14905ed.dirty
>
> Let me know if this works for adding it to the main repository,
>
> Thanks a lot,
>
>
> Bernát GÁBOR
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to