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

[PATCH 1/2] progress: add update_progress()

From
Ssdaoden@googlemail.com <sdaoden@googlemail.com>
Date
Aug 29, 2011, 20:17 UTC
Message-ID
<bc530ff857b92ad58bfd6f331cf6732ed86c42b0.1314647163.git.sdaoden@gmail.com>
In-Reply-To
<cover.1314647163.git.sdaoden@gmail.com>
From: Steffen Daode Nurpmeso <sdaoden@gmail.com>

Sometimes the task which is tracked via progress is splitted into two parts, e.g. check_updates() in unpack_trees.c updates the working tree by first removing files, followed by checking out files. Whereas it is possible to simply recreate a progress reporter, it's easier to simply call in to update the state of the yet existing one.

Inspired-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Steffen Daode Nurpmeso <sdaoden@gmail.com>
---
 progress.c |   15 +++++++++++++++
 progress.h |    2 ++
 2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/progress.c b/progress.c
index 3971f49..c86f83f 100644
--- a/progress.c
+++ b/progress.c
@@ -234,6 +234,21 @@ struct progress *start_progress(const char *title, unsigned total)
 	return start_progress_delay(title, total, 0, 0);
 }
 
+void update_progress(struct progress *progress, const char *title,
+			unsigned total)
+{
+	if (!progress)
+		return;
+	progress->title = title;
+	progress->total = total;
+	progress->last_value = -1;
+	progress->last_percent = -1;
+	if (progress->delay < 0)
+		progress->delay = 0;
+	clear_progress_signal();
+	set_progress_signal();
+}
+
 void stop_progress(struct progress **p_progress)
 {
 	stop_progress_msg(p_progress, "done");
diff --git a/progress.h b/progress.h
index 611e4c4..eed5b58 100644
--- a/progress.h
+++ b/progress.h
@@ -8,6 +8,8 @@ int display_progress(struct progress *progress, unsigned n);
 struct progress *start_progress(const char *title, unsigned total);
 struct progress *start_progress_delay(const char *title, unsigned total,
 				       unsigned percent_treshold, unsigned delay);
+void update_progress(struct progress *progress, const char *title,
+			unsigned total);
 void stop_progress(struct progress **progress);
 void stop_progress_msg(struct progress **progress, const char *msg);
 
-- 
1.7.7.rc0.dirty
Previous: sdaoden@googlemail.comNext: sdaoden@googlemail.com
Message 18 of 21 in “progress: use \r as EOL only if isatty(stderr) is true”
  1. progress: use \r as EOL only if isatty(stderr) is trueSteffen Daode Nurpmeso, Jun 28, 2011
  2. Junio C HamanoJun 28, 2011
  3. Steffen Daode NurpmesoJun 28, 2011
  4. Steffen Daode NurpmesoJun 28, 2011
  5. Jeff KingJun 28, 2011
  6. Junio C HamanoJun 29, 2011
  7. Miles BaderJun 30, 2011
  8. sideband: remove line padding (was: Re: [PATCH] progress: use \r as EOL only if isatty(stderr) is true)Steffen Daode Nurpmeso, Jun 29, 2011
  9. Nicolas PitreJun 29, 2011
  10. Steffen Daode NurpmesoJun 30, 2011
  11. Nicolas PitreJul 1, 2011
  12. checkout: be quiet if not on isatty()Steffen Daode Nurpmeso, Aug 27, 2011
  13. checkout: be quiet if not on isatty()Steffen Daode Nurpmeso, Aug 27, 2011
  14. Junio C HamanoAug 28, 2011
  15. martin f krafftAug 28, 2011
  16. checkout: add --verbose, and restrict progress reporting (was: Re: [PATCH] checkout: be quiet if not on isatty())Steffen Daode Nurpmeso, Aug 28, 2011
  17. 0/2 Add update_progress(), divert checkout messagessdaoden@googlemail.com, Aug 29, 2011
  18. 1/2 progress: add update_progress()sdaoden@googlemail.com, Aug 29, 2011
  19. 2/2 unpack-trees: divert check_updates() output via update_progress()sdaoden@googlemail.com, Aug 29, 2011
  20. Steffen Daode NurpmesoJun 28, 2011
  21. Steffen Daode NurpmesoJun 28, 2011

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.