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

[PATCH 3/4] remote-curl: optionally show progress for HTTP get

From
Toon Claes <toon@iotcl.com>
Date
May 8, 2024, 12:44 UTC
Message-ID
<20240508124453.600871-4-toon@iotcl.com>
In-Reply-To
<20240508124453.600871-1-toon@iotcl.com>

git-remote-curl supports the `option progress` basically since it's inception. But this option had no effect for regular HTTP(S) downloads.

Add progress indicator when downloading files through curl HTTP GET.
Signed-off-by: Toon Claes <toon@iotcl.com>
---
 remote-curl.c       |  8 +++++++-
 t/t5557-http-get.sh | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/remote-curl.c b/remote-curl.c
index 0b6d7815fd..9fc7c3580c 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -1293,6 +1293,7 @@ static void parse_get(const char *arg)
 {
 	struct strbuf url = STRBUF_INIT;
 	struct strbuf path = STRBUF_INIT;
+	struct http_get_options http_options = {0};
 	const char *space;
 
 	space = strchr(arg, ' ');
@@ -1303,7 +1304,12 @@ static void parse_get(const char *arg)
 	strbuf_add(&url, arg, space - arg);
 	strbuf_addstr(&path, space + 1);
 
-	if (http_get_file(url.buf, path.buf, NULL))
+	http_options.initial_request = 1;
+
+	if (options.progress)
+		http_options.progress = 1;
+
+	if (http_get_file(url.buf, path.buf, &http_options))
 		die(_("failed to download file at URL '%s'"), url.buf);
 
 	strbuf_release(&url);
diff --git a/t/t5557-http-get.sh b/t/t5557-http-get.sh
index 76a4bbd16a..92a138caaf 100755
--- a/t/t5557-http-get.sh
+++ b/t/t5557-http-get.sh
@@ -36,4 +36,19 @@ test_expect_success 'get by URL: 200' '
 	test_cmp "$HTTPD_DOCUMENT_ROOT_PATH/exists.txt" file2
 '
 
+test_expect_success 'get by URL with progress' '
+	echo hello >"$HTTPD_DOCUMENT_ROOT_PATH/hello.txt" &&
+
+	url="$HTTPD_URL/hello.txt" &&
+	cat >input <<-EOF &&
+	capabilities
+	option progress true
+	get $url file3
+
+	EOF
+
+	git remote-http $url <input 2>err &&
+        test_grep "^Downloading via HTTP: 100%" err
+'
+
 test_done
-- 
2.44.0.651.g21306a098c
Previous: Jeff KingNext: Junio C Hamano
Message 9 of 25 in “bundle-uri: show progress when downloading from bundle URIs”
  1. 0/4 bundle-uri: show progress when downloading from bundle URIsToon Claes, May 8, 2024
  2. 1/4 progress: add function to set totalToon Claes, May 8, 2024
  3. 2/4 http: add the ability to log progressToon Claes, May 8, 2024
  4. Eric SunshineMay 8, 2024
  5. Jeff KingMay 9, 2024
  6. Junio C HamanoMay 9, 2024
  7. Jeff KingMay 9, 2024
  8. Jeff KingMay 9, 2024
  9. 3/4 remote-curl: optionally show progress for HTTP getToon Claes, May 8, 2024
  10. Junio C HamanoMay 8, 2024
  11. 4/4 bundle-uri: enable git-remote-https progressToon Claes, May 8, 2024
  12. Jeff KingMay 9, 2024
  13. Toon ClaesFeb 14, 2025
  14. Jeff KingFeb 21, 2025
  15. Junio C HamanoMay 8, 2024
  16. 0/7 Show progress when downloading from bundle URIsToon Claes, Feb 19, 2025
  17. 1/7 progress: add function to set totalToon Claes, Feb 19, 2025
  18. Jeff KingFeb 21, 2025
  19. 2/7 progress: allow pure-throughput progress metersToon Claes, Feb 19, 2025
  20. 3/7 http: turn off curl signalsToon Claes, Feb 19, 2025
  21. 4/7 http: add the ability to log progressToon Claes, Feb 19, 2025
  22. 5/7 remote-curl: optionally show progress for HTTP getToon Claes, Feb 19, 2025
  23. 6/7 bundle-uri: enable git-remote-https progressToon Claes, Feb 19, 2025
  24. 7/7 http: silence stderr when progress is enabledToon Claes, Feb 19, 2025
  25. Jeff KingFeb 21, 2025

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.