git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [FEATURE REQUEST] Filter-branch extend progress with a simple estimated time remaning

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2015, 18:33 UTC
Message-ID
<xmqqh9nnz08i.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150825171238.GB9674@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> +start=$(date +%s)
Is that a GNU extension?
Show 22 quoted lines
>  git_filter_branch__commit_count=0
>  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)"
> +	now=$(date +%s)
> +	elapsed=$(($now - $start))
> +	# work in integer percentages as a sort of fixed-point
> +	pct=$(($git_filter_branch__commit_count * 100 / $commits))
> +	if test $pct -eq 0; then
> +		remain=
> +	else
> +		eta=$(($elapsed * 100 / $pct))
> +		remain="($(($eta - $elapsed)) seconds remaining)   "
> +	fi
> +	printf "\rRewrite $commit ($git_filter_branch__commit_count/$commits) $remain"
>  
>  	case "$filter_subdir" in
>  	"")
>
> but the time jumps around early on because of the lack of precision. And
> of course there's no smoothing, and no emphasis on recent history versus
> the whole operation. I'll leave those as an exercise to the reader. :)
;-)

An alternative implementation may be to ask `date` every 1000 commits (or whatever sufficiently large value that we can amortise the cost) to measure the rate and compute $remain based on that measurement. That way, we can afford to use more portable ways to ask `date` about the current time and compute the "how many seconds" ourselves.

Previous: Jeff KingNext: Jeff King
Message 3 of 24 in “[FEATURE REQUEST] Filter-branch extend progress with a simple estimated time remaning”
  1. Gabor BernatAug 25, 2015
  2. Jeff KingAug 25, 2015
  3. Junio C HamanoAug 25, 2015
  4. Jeff KingAug 25, 2015
  5. Jeff KingAug 25, 2015
  6. Gabor BernatAug 25, 2015
  7. Eric SunshineAug 25, 2015
  8. Jeff KingAug 26, 2015
  9. Gabor BernatAug 29, 2015
  10. Gabor BernatAug 29, 2015
  11. Eric SunshineAug 30, 2015
  12. Gabor BernatAug 30, 2015
  13. Eric SunshineAug 30, 2015
  14. Mikael MagnussonAug 30, 2015
  15. Gabor BernatAug 30, 2015
  16. Mikael MagnussonAug 30, 2015
  17. Eric SunshineAug 30, 2015
  18. Junio C HamanoAug 30, 2015
  19. Gabor BernatAug 30, 2015
  20. Mikael MagnussonAug 30, 2015
  21. Eric SunshineAug 30, 2015
  22. Eric SunshineAug 30, 2015
  23. Eric SunshineAug 30, 2015
  24. Junio C HamanoAug 31, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.