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

[PATCH 1/2] progress: set default delay threshold to 100%, not 0%

From
Jeff King <peff@peff.net>
Date
Dec 4, 2017, 22:05 UTC
Message-ID
<20171204220523.GA18828@sigill.intra.peff.net>
In-Reply-To
<20171204220228.GA29422@sigill.intra.peff.net>

Commit 8aade107dd (progress: simplify "delayed" progress API, 2017-08-19) dropped the parameter by which callers could say "show my progress only if I haven't passed M% progress after N seconds". The intent was to just show nothing for 2 seconds, and then always progress after that.

But we flipped the logic in the wrapper: it sets M=0, meaning that we'd almost _never_ show progress after 2 seconds, since we'd generally have made some progress. This should have been 100%, not 0%.

We were fooled by existing calls like:
  start_progress_delay("foo", 0, 0, 2);

which behaved this way. The trick is that the first "0" there is "how many items total", and there zero means "we don't know". And without knowing that, we cannot compute a completed percent at all, and we ignored the threshold parameter entirely! Modeling our wrapper after that broke callers which pass a non-zero value for "total".

We can switch to the intended behavior by using "100" in the wrapper call.

Reported-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 progress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/progress.c b/progress.c
index 289678d43d..b774cb1cd1 100644
--- a/progress.c
+++ b/progress.c
@@ -229,7 +229,7 @@ static struct progress *start_progress_delay(const char *title, unsigned total,
 
 struct progress *start_delayed_progress(const char *title, unsigned total)
 {
-	return start_progress_delay(title, total, 0, 2);
+	return start_progress_delay(title, total, 100, 2);
 }
 
 struct progress *start_progress(const char *title, unsigned total)
-- 
2.15.0.691.g622df76569
Previous: Jeff KingNext: Jeff King
Message 5 of 11 in “progress: print progress output for all operations taking longer than 2s”
  1. progress: print progress output for all operations taking longer than 2slars.schneider@autodesk.com, Dec 4, 2017
  2. Jeff KingDec 4, 2017
  3. Junio C HamanoDec 4, 2017
  4. 0/2 fix v2.15 progress regressionJeff King, Dec 4, 2017
  5. 1/2 progress: set default delay threshold to 100%, not 0%Jeff King, Dec 4, 2017
  6. 2/2 progress: drop delay-threshold codeJeff King, Dec 4, 2017
  7. Lars SchneiderDec 5, 2017
  8. Ævar Arnfjörð BjarmasonDec 5, 2017
  9. Lars SchneiderDec 5, 2017
  10. Junio C HamanoDec 4, 2017
  11. Junio C HamanoDec 4, 2017

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.