From c6dfb399448f6de17ce417052f1bb345c9e022c9 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Tue, 13 Oct 2009 12:53:28 +0200 Subject: [PATCH 1/3] remote-curl: add missing initialization of argv0_path All programs, in particular also the stand-alone programs (non-builtins) must call git_extract_argv0_path(argv[0]) in order to help builds that derive the installation prefix at runtime, such as the MinGW build. Without this call, the program segfaults (or raises an assertion failure). Signed-off-by: Johannes Sixt Tested-by: Michael Wookey Signed-off-by: Junio C Hamano --- remote-curl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/remote-curl.c b/remote-curl.c index ad6a1637b5..d8d276a471 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -82,6 +82,7 @@ int main(int argc, const char **argv) const char *url; struct walker *walker = NULL; + git_extract_argv0_path(argv[0]); setup_git_directory(); if (argc < 2) { fprintf(stderr, "Remote needed\n"); From d01a8e32fe10f1086e5e427f85237baff218fb01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Wed, 14 Oct 2009 00:11:09 +0200 Subject: [PATCH 2/3] clone: Supply the right commit hash to post-checkout when -b is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we use -b , we may checkout something else than what the remote's HEAD references, but we still used remote_head to supply the new ref value to the post-checkout hook, which is wrong. So instead of using remote_head to find the value to be passed to the post-checkout hook, we have to use our_head_points_at, which is always correctly setup, even if -b is not used. This also fixes a segfault when "clone -b " is used with a remote repo that doesn't have a valid HEAD, as in such a case remote_head is NULL, but we still tried to access it. Reported-by: Devin Cofer Signed-off-by: Björn Steinbrink Acked-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-clone.c | 3 ++- remote-curl.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin-clone.c b/builtin-clone.c index 4992c2597c..5762a6f9d8 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -641,7 +641,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) die("unable to write new index file"); err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1), - sha1_to_hex(remote_head->old_sha1), "1", NULL); + sha1_to_hex(our_head_points_at->old_sha1), "1", + NULL); if (!err && option_recursive) err = run_command_v_opt(argv_submodule, RUN_GIT_CMD); diff --git a/remote-curl.c b/remote-curl.c index d8d276a471..2faf1c6344 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -3,6 +3,7 @@ #include "strbuf.h" #include "walker.h" #include "http.h" +#include "exec_cmd.h" static struct ref *get_refs(struct walker *walker, const char *url) { From 583371af1f88e9cd48fedbb6bbb147d8091fd591 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Tue, 13 Oct 2009 23:02:04 -0400 Subject: [PATCH 3/3] change throughput display units with fast links Switch to MiB/s when the connection is fast enough (i.e. on a LAN). Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- progress.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/progress.c b/progress.c index 132ed95a3d..3971f49f4d 100644 --- a/progress.c +++ b/progress.c @@ -131,7 +131,13 @@ static void throughput_string(struct throughput *tp, off_t total, } else { l -= snprintf(tp->display, l, ", %u bytes", (int)total); } - if (rate) + + if (rate > 1 << 10) { + int x = rate + 5; /* for rounding */ + snprintf(tp->display + sizeof(tp->display) - l, l, + " | %u.%2.2u MiB/s", + x >> 10, ((x & ((1 << 10) - 1)) * 100) >> 10); + } else if (rate) snprintf(tp->display + sizeof(tp->display) - l, l, " | %u KiB/s", rate); }