{"thread":{"id":"10338","subject":"[PATCH 0/6] miscelaneous stuff","startedAt":"2007-10-17T01:55:44Z","lastAt":"2007-10-18T08:34:37Z","messageCount":17,"participants":["Nicolas Pitre","Shawn O. Pearce","Johannes Sixt","Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"56175","messageId":"1192586150-13743-1-git-send-email-nico@cam.org","threadId":"10338","inReplyTo":null,"subject":"[PATCH 0/6] miscelaneous stuff","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T01:55:44Z","receivedAt":"2007-10-17T01:55:44Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"This is a few patches I've been accumulating.  Included is a rework of\nthe progress display so it uses much less screen lines, as well as a\ncouple code cleanups.\n\n\nNicolas\n"},{"id":"56176","messageId":"1192586150-13743-2-git-send-email-nico@cam.org","threadId":"10338","inReplyTo":"1192586150-13743-1-git-send-email-nico@cam.org","subject":"[PATCH 1/6] more compact progress display","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T01:55:45Z","receivedAt":"2007-10-17T01:55:45Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Each progress can be on a single line instead of two.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n builtin-pack-objects.c   |   16 ++++---------\n builtin-unpack-objects.c |    2 +-\n index-pack.c             |    4 +-\n progress.c               |   53 +++++++++++++++++++++------------------------\n progress.h               |   10 +++-----\n unpack-trees.c           |    4 +-\n 6 files changed, 39 insertions(+), 50 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 0be539e..df69abd 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -606,7 +606,7 @@ static void write_pack_file(void)\n \tuint32_t nr_remaining = nr_result;\n \n \tif (do_progress)\n-\t\tstart_progress(&progress_state, \"Writing %u objects...\", \"\", nr_result);\n+\t\tstart_progress(&progress_state, \"Writing objects\", nr_result);\n \twritten_list = xmalloc(nr_objects * sizeof(struct object_entry *));\n \n \tdo {\n@@ -1717,9 +1717,8 @@ static void prepare_pack(int window, int depth)\n \tif (nr_deltas) {\n \t\tunsigned nr_done = 0;\n \t\tif (progress)\n-\t\t\tstart_progress(&progress_state,\n-\t\t\t\t       \"Deltifying %u objects...\", \"\",\n-\t\t\t\t       nr_deltas);\n+\t\t\tstart_progress(&progress_state, \"Deltifying objects\",\n+\t\t\t\t\tnr_deltas);\n \t\tqsort(delta_list, n, sizeof(*delta_list), type_size_sort);\n \t\tll_find_deltas(delta_list, n, window+1, depth, &nr_done);\n \t\tif (progress)\n@@ -2135,23 +2134,18 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \tprepare_packed_git();\n \n \tif (progress)\n-\t\tstart_progress(&progress_state, \"Generating pack...\",\n-\t\t\t       \"Counting objects: \", 0);\n+\t\tstart_progress(&progress_state, \"Counting objects\", 0);\n \tif (!use_internal_rev_list)\n \t\tread_object_list_from_stdin();\n \telse {\n \t\trp_av[rp_ac] = NULL;\n \t\tget_object_list(rp_ac, rp_av);\n \t}\n-\tif (progress) {\n+\tif (progress)\n \t\tstop_progress(&progress_state);\n-\t\tfprintf(stderr, \"Done counting %u objects.\\n\", nr_objects);\n-\t}\n \n \tif (non_empty && !nr_result)\n \t\treturn 0;\n-\tif (progress && (nr_objects != nr_result))\n-\t\tfprintf(stderr, \"Result has %u objects.\\n\", nr_result);\n \tif (nr_result)\n \t\tprepare_pack(window, depth);\n \twrite_pack_file();\ndiff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c\nindex a6ff62f..2317b8f 100644\n--- a/builtin-unpack-objects.c\n+++ b/builtin-unpack-objects.c\n@@ -322,7 +322,7 @@ static void unpack_all(void)\n \tuse(sizeof(struct pack_header));\n \n \tif (!quiet)\n-\t\tstart_progress(&progress, \"Unpacking %u objects...\", \"\", nr_objects);\n+\t\tstart_progress(&progress, \"Unpacking objects\", nr_objects);\n \tobj_list = xmalloc(nr_objects * sizeof(*obj_list));\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tunpack_one(i);\ndiff --git a/index-pack.c b/index-pack.c\nindex db58e05..c784dec 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -406,7 +406,7 @@ static void parse_pack_objects(unsigned char *sha1)\n \t * - remember base (SHA1 or offset) for all deltas.\n \t */\n \tif (verbose)\n-\t\tstart_progress(&progress, \"Indexing %u objects...\", \"\", nr_objects);\n+\t\tstart_progress(&progress, \"Indexing objects\", nr_objects);\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tstruct object_entry *obj = &objects[i];\n \t\tdata = unpack_raw_entry(obj, &delta->base);\n@@ -455,7 +455,7 @@ static void parse_pack_objects(unsigned char *sha1)\n \t *   for some more deltas.\n \t */\n \tif (verbose)\n-\t\tstart_progress(&progress, \"Resolving %u deltas...\", \"\", nr_deltas);\n+\t\tstart_progress(&progress, \"Resolving deltas\", nr_deltas);\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tstruct object_entry *obj = &objects[i];\n \t\tunion delta_base base;\ndiff --git a/progress.c b/progress.c\nindex 4344f4e..7629e05 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -35,10 +35,11 @@ static void clear_progress_signal(void)\n \tprogress_update = 0;\n }\n \n-int display_progress(struct progress *progress, unsigned n)\n+static int display(struct progress *progress, unsigned n, int done)\n {\n+\tchar *eol;\n+\n \tif (progress->delay) {\n-\t\tchar buf[80];\n \t\tif (!progress_update || --progress->delay)\n \t\t\treturn 0;\n \t\tif (progress->total) {\n@@ -51,60 +52,56 @@ int display_progress(struct progress *progress, unsigned n)\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t}\n-\t\tif (snprintf(buf, sizeof(buf),\n-\t\t\t     progress->delayed_title, progress->total))\n-\t\t\tfprintf(stderr, \"%s\\n\", buf);\n \t}\n+\n+\tprogress->last_value = n;\n+\teol = done ? \", done.   \\n\" : \"   \\r\";\n \tif (progress->total) {\n \t\tunsigned percent = n * 100 / progress->total;\n \t\tif (percent != progress->last_percent || progress_update) {\n \t\t\tprogress->last_percent = percent;\n-\t\t\tfprintf(stderr, \"%s%4u%% (%u/%u) done\\r\",\n-\t\t\t\tprogress->prefix, percent, n, progress->total);\n+\t\t\tfprintf(stderr, \"%s: %3u%% (%u/%u)%s\", progress->title,\n+\t\t\t\tpercent, n, progress->total, eol);\n \t\t\tprogress_update = 0;\n-\t\t\tprogress->need_lf = 1;\n \t\t\treturn 1;\n \t\t}\n \t} else if (progress_update) {\n-\t\tfprintf(stderr, \"%s%u\\r\", progress->prefix, n);\n+\t\tfprintf(stderr, \"%s: %u%s\", progress->title, n, eol);\n \t\tprogress_update = 0;\n-\t\tprogress->need_lf = 1;\n \t\treturn 1;\n \t}\n+\n \treturn 0;\n }\n \n-void start_progress(struct progress *progress, const char *title,\n-\t\t    const char *prefix, unsigned total)\n+int display_progress(struct progress *progress, unsigned n)\n {\n-\tchar buf[80];\n-\tprogress->prefix = prefix;\n-\tprogress->total = total;\n-\tprogress->last_percent = -1;\n-\tprogress->delay = 0;\n-\tprogress->need_lf = 0;\n-\tif (snprintf(buf, sizeof(buf), title, total))\n-\t\tfprintf(stderr, \"%s\\n\", buf);\n-\tset_progress_signal();\n+\treturn display(progress, n, 0);\n }\n \n void start_progress_delay(struct progress *progress, const char *title,\n-\t\t\t  const char *prefix, unsigned total,\n-\t\t\t  unsigned percent_treshold, unsigned delay)\n+\t\t\t  unsigned total, unsigned percent_treshold, unsigned delay)\n {\n-\tprogress->prefix = prefix;\n+\tprogress->title = title;\n \tprogress->total = total;\n+\tprogress->last_value = -1;\n \tprogress->last_percent = -1;\n \tprogress->delayed_percent_treshold = percent_treshold;\n-\tprogress->delayed_title = title;\n \tprogress->delay = delay;\n-\tprogress->need_lf = 0;\n \tset_progress_signal();\n }\n \n+void start_progress(struct progress *progress, const char *title, unsigned total)\n+{\n+\tstart_progress_delay(progress, title, total, 0, 0);\n+}\n+\n void stop_progress(struct progress *progress)\n {\n+\tif (progress->last_value != -1) {\n+\t\t/* Force the last update */\n+\t\tprogress_update = 1;\n+\t\tdisplay(progress, progress->last_value, 1);\n+\t}\n \tclear_progress_signal();\n-\tif (progress->need_lf)\n-\t\tfputc('\\n', stderr);\n }\ndiff --git a/progress.h b/progress.h\nindex a7c17ca..07b56bd 100644\n--- a/progress.h\n+++ b/progress.h\n@@ -2,21 +2,19 @@\n #define PROGRESS_H\n \n struct progress {\n-\tconst char *prefix;\n+\tconst char *title;\n+\tint last_value;\n \tunsigned total;\n \tunsigned last_percent;\n \tunsigned delay;\n \tunsigned delayed_percent_treshold;\n-\tconst char *delayed_title;\n-\tint need_lf;\n };\n \n int display_progress(struct progress *progress, unsigned n);\n void start_progress(struct progress *progress, const char *title,\n-\t\t    const char *prefix, unsigned total);\n+\t\t    unsigned total);\n void start_progress_delay(struct progress *progress, const char *title,\n-\t\t\t  const char *prefix, unsigned total,\n-\t\t\t  unsigned percent_treshold, unsigned delay);\n+\t\t\t  unsigned total, unsigned percent_treshold, unsigned delay);\n void stop_progress(struct progress *progress);\n \n #endif\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex ccfeb6e..e083898 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -307,8 +307,8 @@ static void check_updates(struct cache_entry **src, int nr,\n \t\t\t\ttotal++;\n \t\t}\n \n-\t\tstart_progress_delay(&progress, \"Checking %u files out...\",\n-\t\t\t\t     \"\", total, 50, 2);\n+\t\tstart_progress_delay(&progress, \"Checking files out\",\n+\t\t\t\t     total, 50, 2);\n \t\tcnt = 0;\n \t}\n \n-- \n1.5.3.4.1212.gdb015\n"},{"id":"56177","messageId":"1192586150-13743-3-git-send-email-nico@cam.org","threadId":"10338","inReplyTo":"1192586150-13743-2-git-send-email-nico@cam.org","subject":"[PATCH 2/6] cope with multiple line breaks within sideband progress messages","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T01:55:46Z","receivedAt":"2007-10-17T01:55:46Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"A single sideband packet may sometimes contain multiple lines of progress\nmessages, but we prepend \"remote: \" only to the whole buffer which creates\na messed up display in that case.  Make sure that the \"remote: \" prefix\nis applied to every remote lines.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n sideband.c |   19 +++++++++++++++++--\n 1 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/sideband.c b/sideband.c\nindex 277fa3c..ab8a1e9 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -17,7 +17,7 @@ int recv_sideband(const char *me, int in_stream, int out, int err)\n \tstrcpy(buf, \"remote:\");\n \twhile (1) {\n \t\tint band, len;\n-\t\tlen\t= packet_read_line(in_stream, buf+7, LARGE_PACKET_MAX);\n+\t\tlen = packet_read_line(in_stream, buf+7, LARGE_PACKET_MAX);\n \t\tif (len == 0)\n \t\t\tbreak;\n \t\tif (len < 1) {\n@@ -35,7 +35,22 @@ int recv_sideband(const char *me, int in_stream, int out, int err)\n \t\t\treturn SIDEBAND_REMOTE_ERROR;\n \t\tcase 2:\n \t\t\tbuf[7] = ' ';\n-\t\t\tsafe_write(err, buf, 8+len);\n+\t\t\tlen += 8;\n+\t\t\twhile (1) {\n+\t\t\t\tint brk = 8;\n+\t\t\t\twhile (brk < len) {\n+\t\t\t\t\tbrk++;\n+\t\t\t\t\tif (buf[brk-1] == '\\n' ||\n+\t\t\t\t\t    buf[brk-1] == '\\r')\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t\tsafe_write(err, buf, brk);\n+\t\t\t\tif (brk < len) {\n+\t\t\t\t\tmemmove(buf + 8, buf + brk, len - brk);\n+\t\t\t\t\tlen = len - brk + 8;\n+\t\t\t\t} else\n+\t\t\t\t\tbreak;\n+\t\t\t}\n \t\t\tcontinue;\n \t\tcase 1:\n \t\t\tsafe_write(out, buf+8, len);\n-- \n1.5.3.4.1212.gdb015\n"},{"id":"56180","messageId":"1192586150-13743-4-git-send-email-nico@cam.org","threadId":"10338","inReplyTo":"1192586150-13743-3-git-send-email-nico@cam.org","subject":"[PATCH 3/6] pack-objects: no delta possible with only one object in the list","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T01:55:47Z","receivedAt":"2007-10-17T01:55:47Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"... so don't even try in that case, and save another useless line of\nprogress display.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n builtin-pack-objects.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex df69abd..d729cb7 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -1714,7 +1714,7 @@ static void prepare_pack(int window, int depth)\n \t\tdelta_list[n++] = entry;\n \t}\n \n-\tif (nr_deltas) {\n+\tif (nr_deltas && n > 1) {\n \t\tunsigned nr_done = 0;\n \t\tif (progress)\n \t\t\tstart_progress(&progress_state, \"Deltifying objects\",\n-- \n1.5.3.4.1212.gdb015\n"},{"id":"56179","messageId":"1192586150-13743-5-git-send-email-nico@cam.org","threadId":"10338","inReplyTo":"1192586150-13743-4-git-send-email-nico@cam.org","subject":"[PATCH 4/6] pack-objects.c: fix some global variable abuse and memory leaks","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T01:55:48Z","receivedAt":"2007-10-17T01:55:48Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"To keep things well layered, sha1close() now returns the file descriptor\nwhen it doesn't close the file.\n\nAn ugly cast was added to the return of write_idx_file() to avoid a\nwarning.  A proper fix will come separately.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n builtin-pack-objects.c |   29 +++++++++++++++--------------\n csum-file.c            |   23 ++++++++++++++---------\n 2 files changed, 29 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex d729cb7..933c252 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -65,8 +65,6 @@ static int no_reuse_delta, no_reuse_object, keep_unreachable;\n static int local;\n static int incremental;\n static int allow_ofs_delta;\n-static const char *pack_tmp_name, *idx_tmp_name;\n-static char tmpname[PATH_MAX];\n static const char *base_name;\n static int progress = 1;\n static int window = 10;\n@@ -587,12 +585,6 @@ static off_t write_one(struct sha1file *f,\n \treturn offset + size;\n }\n \n-static int open_object_dir_tmp(const char *path)\n-{\n-    snprintf(tmpname, sizeof(tmpname), \"%s/%s\", get_object_directory(), path);\n-    return xmkstemp(tmpname);\n-}\n-\n /* forward declaration for write_pack_file */\n static int adjust_perm(const char *path, mode_t mode);\n \n@@ -611,11 +603,16 @@ static void write_pack_file(void)\n \n \tdo {\n \t\tunsigned char sha1[20];\n+\t\tchar *pack_tmp_name = NULL;\n \n \t\tif (pack_to_stdout) {\n \t\t\tf = sha1fd(1, \"<stdout>\");\n \t\t} else {\n-\t\t\tint fd = open_object_dir_tmp(\"tmp_pack_XXXXXX\");\n+\t\t\tchar tmpname[PATH_MAX];\n+\t\t\tint fd;\n+\t\t\tsnprintf(tmpname, sizeof(tmpname),\n+\t\t\t\t \"%s/tmp_pack_XXXXXX\", get_object_directory());\n+\t\t\tfd = xmkstemp(tmpname);\n \t\t\tpack_tmp_name = xstrdup(tmpname);\n \t\t\tf = sha1fd(fd, pack_tmp_name);\n \t\t}\n@@ -643,19 +640,21 @@ static void write_pack_file(void)\n \t\tif (pack_to_stdout || nr_written == nr_remaining) {\n \t\t\tsha1close(f, sha1, 1);\n \t\t} else {\n-\t\t\tsha1close(f, sha1, 0);\n-\t\t\tfixup_pack_header_footer(f->fd, sha1, pack_tmp_name, nr_written);\n-\t\t\tclose(f->fd);\n+\t\t\tint fd = sha1close(f, NULL, 0);\n+\t\t\tfixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);\n+\t\t\tclose(fd);\n \t\t}\n \n \t\tif (!pack_to_stdout) {\n \t\t\tmode_t mode = umask(0);\n+\t\t\tchar *idx_tmp_name, tmpname[PATH_MAX];\n \n \t\t\tumask(mode);\n \t\t\tmode = 0444 & ~mode;\n \n-\t\t\tidx_tmp_name = write_idx_file(NULL,\n-\t\t\t\t(struct pack_idx_entry **) written_list, nr_written, sha1);\n+\t\t\tidx_tmp_name = (char *) write_idx_file(NULL,\n+\t\t\t\t\t(struct pack_idx_entry **) written_list,\n+\t\t\t\t\tnr_written, sha1);\n \t\t\tsnprintf(tmpname, sizeof(tmpname), \"%s-%s.pack\",\n \t\t\t\t base_name, sha1_to_hex(sha1));\n \t\t\tif (adjust_perm(pack_tmp_name, mode))\n@@ -672,6 +671,8 @@ static void write_pack_file(void)\n \t\t\tif (rename(idx_tmp_name, tmpname))\n \t\t\t\tdie(\"unable to rename temporary index file: %s\",\n \t\t\t\t    strerror(errno));\n+\t\t\tfree(idx_tmp_name);\n+\t\t\tfree(pack_tmp_name);\n \t\t\tputs(sha1_to_hex(sha1));\n \t\t}\n \ndiff --git a/csum-file.c b/csum-file.c\nindex 9ab9971..9929991 100644\n--- a/csum-file.c\n+++ b/csum-file.c\n@@ -31,22 +31,27 @@ static void sha1flush(struct sha1file *f, unsigned int count)\n \n int sha1close(struct sha1file *f, unsigned char *result, int final)\n {\n+\tint fd;\n \tunsigned offset = f->offset;\n \tif (offset) {\n \t\tSHA1_Update(&f->ctx, f->buffer, offset);\n \t\tsha1flush(f, offset);\n \t\tf->offset = 0;\n \t}\n-\tif (!final)\n-\t\treturn 0;\t/* only want to flush (no checksum write, no close) */\n-\tSHA1_Final(f->buffer, &f->ctx);\n-\tif (result)\n-\t\thashcpy(result, f->buffer);\n-\tsha1flush(f, 20);\n-\tif (close(f->fd))\n-\t\tdie(\"%s: sha1 file error on close (%s)\", f->name, strerror(errno));\n+\tif (final) {\n+\t\t/* write checksum and close fd */\n+\t\tSHA1_Final(f->buffer, &f->ctx);\n+\t\tif (result)\n+\t\t\thashcpy(result, f->buffer);\n+\t\tsha1flush(f, 20);\n+\t\tif (close(f->fd))\n+\t\t\tdie(\"%s: sha1 file error on close (%s)\",\n+\t\t\t    f->name, strerror(errno));\n+\t\tfd = 0;\n+\t} else\n+\t\tfd = f->fd;\n \tfree(f);\n-\treturn 0;\n+\treturn fd;\n }\n \n int sha1write(struct sha1file *f, void *buf, unsigned int count)\n-- \n1.5.3.4.1212.gdb015\n"},{"id":"56181","messageId":"1192586150-13743-6-git-send-email-nico@cam.org","threadId":"10338","inReplyTo":"1192586150-13743-5-git-send-email-nico@cam.org","subject":"[PATCH 5/6] fix const issues with some functions","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T01:55:49Z","receivedAt":"2007-10-17T01:55:49Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Two functions, namely write_idx_file() and open_pack_file(), currently\nreturn a const pointer.  However that pointer is either a copy of the\nfirst argument, or set to a malloc'd buffer when that first argument\nis null.  In the later case it is wrong to qualify that pointer as const\nsince ownership of the buffer is transferred to the caller to dispose of,\nand obviously the free() function is not meant to be passed const\npointers.\n\nMaking the return pointer not const causes a warning when the first\nargument is returned since that argument is also marked const.\n\nThe correct thing to do is therefore to remove the const qualifiers,\navoiding the need for ugly casts only to silence some warnings.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n builtin-pack-objects.c |    2 +-\n index-pack.c           |    8 ++++----\n pack-write.c           |    3 ++-\n pack.h                 |    2 +-\n 4 files changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 933c252..15d3750 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -652,7 +652,7 @@ static void write_pack_file(void)\n \t\t\tumask(mode);\n \t\t\tmode = 0444 & ~mode;\n \n-\t\t\tidx_tmp_name = (char *) write_idx_file(NULL,\n+\t\t\tidx_tmp_name = write_idx_file(NULL,\n \t\t\t\t\t(struct pack_idx_entry **) written_list,\n \t\t\t\t\tnr_written, sha1);\n \t\t\tsnprintf(tmpname, sizeof(tmpname), \"%s-%s.pack\",\ndiff --git a/index-pack.c b/index-pack.c\nindex c784dec..60173d5 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -106,7 +106,7 @@ static void use(int bytes)\n \tconsumed_bytes += bytes;\n }\n \n-static const char *open_pack_file(const char *pack_name)\n+static char *open_pack_file(char *pack_name)\n {\n \tif (from_stdin) {\n \t\tinput_fd = 0;\n@@ -686,15 +686,15 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n int main(int argc, char **argv)\n {\n \tint i, fix_thin_pack = 0;\n-\tconst char *curr_pack, *pack_name = NULL;\n-\tconst char *curr_index, *index_name = NULL;\n+\tchar *curr_pack, *pack_name = NULL;\n+\tchar *curr_index, *index_name = NULL;\n \tconst char *keep_name = NULL, *keep_msg = NULL;\n \tchar *index_name_buf = NULL, *keep_name_buf = NULL;\n \tstruct pack_idx_entry **idx_objects;\n \tunsigned char sha1[20];\n \n \tfor (i = 1; i < argc; i++) {\n-\t\tconst char *arg = argv[i];\n+\t\tchar *arg = argv[i];\n \n \t\tif (*arg == '-') {\n \t\t\tif (!strcmp(arg, \"--stdin\")) {\ndiff --git a/pack-write.c b/pack-write.c\nindex 979bdff..665e2b2 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -17,7 +17,8 @@ static int sha1_compare(const void *_a, const void *_b)\n  * the SHA1 hash of sorted object names. The objects array passed in\n  * will be sorted by SHA1 on exit.\n  */\n-const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1)\n+char *write_idx_file(char *index_name, struct pack_idx_entry **objects,\n+\t\t     int nr_objects, unsigned char *sha1)\n {\n \tstruct sha1file *f;\n \tstruct pack_idx_entry **sorted_by_sha, **list, **last;\ndiff --git a/pack.h b/pack.h\nindex b57ba2d..b31b376 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -55,7 +55,7 @@ struct pack_idx_entry {\n \toff_t offset;\n };\n \n-extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);\n+extern char *write_idx_file(char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);\n \n extern int verify_pack(struct packed_git *, int);\n extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t);\n-- \n1.5.3.4.1212.gdb015\n"},{"id":"56178","messageId":"1192586150-13743-7-git-send-email-nico@cam.org","threadId":"10338","inReplyTo":"1192586150-13743-6-git-send-email-nico@cam.org","subject":"[PATCH 6/6] fix for more minor memory leaks","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T01:55:50Z","receivedAt":"2007-10-17T01:55:50Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Now that some pointers have lost their const attribute, we can free their\nassociated memory when done with them.  This is more a correctness issue\nabout the rule for freeing those pointers which isn't completely trivial\nmore than the leak itself which didn't matter as the program is\nexiting anyway.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n index-pack.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/index-pack.c b/index-pack.c\nindex 60173d5..2f149a4 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -815,6 +815,10 @@ int main(int argc, char **argv)\n \tfree(objects);\n \tfree(index_name_buf);\n \tfree(keep_name_buf);\n+\tif (pack_name == NULL)\n+\t\tfree(curr_pack);\n+\tif (index_name == NULL)\n+\t\tfree(curr_index);\n \n \treturn 0;\n }\n-- \n1.5.3.4.1212.gdb015\n"},{"id":"56182","messageId":"20071017021137.GO13801@spearce.org","threadId":"10338","inReplyTo":"1192586150-13743-2-git-send-email-nico@cam.org","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-17T02:11:37Z","receivedAt":"2007-10-17T02:11:37Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nicolas Pitre <nico@cam.org> wrote:\n> Each progress can be on a single line instead of two.\n\nNice.  Of course that screws with git-gui and now I have to\nmatch two regexs and not one.  But whatever.\n \n> +++ b/progress.c\n> @@ -35,10 +35,11 @@ static void clear_progress_signal(void)\n>  \tprogress_update = 0;\n>  }\n>  \n> -int display_progress(struct progress *progress, unsigned n)\n> +static int display(struct progress *progress, unsigned n, int done)\n>  {\n> +\tchar *eol;\n> +\n>  \tif (progress->delay) {\n> -\t\tchar buf[80];\n>  \t\tif (!progress_update || --progress->delay)\n>  \t\t\treturn 0;\n>  \t\tif (progress->total) {\n> @@ -51,60 +52,56 @@ int display_progress(struct progress *progress, unsigned n)\n>  \t\t\t\treturn 0;\n>  \t\t\t}\n>  \t\t}\n> -\t\tif (snprintf(buf, sizeof(buf),\n> -\t\t\t     progress->delayed_title, progress->total))\n> -\t\t\tfprintf(stderr, \"%s\\n\", buf);\n>  \t}\n> +\n> +\tprogress->last_value = n;\n\nHmm. n is unsigned and last_value is signed.  Uh?  I know you are\nusing the special value -1 to mean we've never output anything for\nthis progress meter but mixing signed and unsigned always gives me\nthe willies.\n\n-- \nShawn.\n"},{"id":"56183","messageId":"20071017021555.GP13801@spearce.org","threadId":"10338","inReplyTo":"1192586150-13743-4-git-send-email-nico@cam.org","subject":"Deltifying? (was [PATCH 3/6] pack-objects: no delta possible...)","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-17T02:15:55Z","receivedAt":"2007-10-17T02:15:55Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nicolas Pitre <nico@cam.org> wrote:\n>  \t\t\tstart_progress(&progress_state, \"Deltifying objects\",\n\nTotally unrelated to this patch but yesterday a coworker called the\nGrammar Police on me because Git said \"Deltifying objects\" in their\nconsole window during a fetch or push operation.  I told them it was\nperfectly valid, they disagreed.  I got free coffee out of the deal.\n\nBut still, it bothers some users that we use perhaps less than\ncommonly accepted English in an important tool's output.  Seeing it\nin your context just reminded me of that discussion yesterday.\n\n-- \nShawn.\n"},{"id":"56186","messageId":"alpine.LFD.0.9999.0710162223030.19446@xanadu.home","threadId":"10338","inReplyTo":"20071017021137.GO13801@spearce.org","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T02:24:25Z","receivedAt":"2007-10-17T02:24:25Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 16 Oct 2007, Shawn O. Pearce wrote:\n\n> Hmm. n is unsigned and last_value is signed.  Uh?  I know you are\n> using the special value -1 to mean we've never output anything for\n> this progress meter but mixing signed and unsigned always gives me\n> the willies.\n\nReally?  ;-)\n\n\nNicolas\n"},{"id":"56188","messageId":"alpine.LFD.0.9999.0710162224590.19446@xanadu.home","threadId":"10338","inReplyTo":"20071017021555.GP13801@spearce.org","subject":"Re: Deltifying? (was [PATCH 3/6] pack-objects: no delta possible...)","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T02:28:56Z","receivedAt":"2007-10-17T02:28:56Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 16 Oct 2007, Shawn O. Pearce wrote:\n\n> Nicolas Pitre <nico@cam.org> wrote:\n> >  \t\t\tstart_progress(&progress_state, \"Deltifying objects\",\n> \n> Totally unrelated to this patch but yesterday a coworker called the\n> Grammar Police on me because Git said \"Deltifying objects\" in their\n> console window during a fetch or push operation.  I told them it was\n> perfectly valid, they disagreed.  I got free coffee out of the deal.\n\nWhatever is proper English I don't mind, as long as it is short, like a \nsingle word to describe the action + \"objects\".\n\n> But still, it bothers some users that we use perhaps less than\n> commonly accepted English in an important tool's output.  Seeing it\n> in your context just reminded me of that discussion yesterday.\n\nWith Git's growing user base, this is becoming more and more common \nthough.  ;-)\n\n\nNicolas\n"},{"id":"56207","messageId":"4715ACE4.9080907@viscovery.net","threadId":"10338","inReplyTo":"1192586150-13743-2-git-send-email-nico@cam.org","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-10-17T06:34:12Z","receivedAt":"2007-10-17T06:34:12Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Nicolas Pitre schrieb:\n> -\t\tstart_progress_delay(&progress, \"Checking %u files out...\",\n> -\t\t\t\t     \"\", total, 50, 2);\n> +\t\tstart_progress_delay(&progress, \"Checking files out\",\n> +\t\t\t\t     total, 50, 2);\n\nWhile you are here, could you make that \"Checking out files\", please?\n\n-- Hannes\n"},{"id":"56208","messageId":"20071017063727.GX13801@spearce.org","threadId":"10338","inReplyTo":"4715ACE4.9080907@viscovery.net","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-17T06:37:27Z","receivedAt":"2007-10-17T06:37:27Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Nicolas Pitre schrieb:\n> >-\t\tstart_progress_delay(&progress, \"Checking %u files out...\",\n> >-\t\t\t\t     \"\", total, 50, 2);\n> >+\t\tstart_progress_delay(&progress, \"Checking files out\",\n> >+\t\t\t\t     total, 50, 2);\n> \n> While you are here, could you make that \"Checking out files\", please?\n\nI'll amend it right now.  I'm finishing up building my nightly\nupdate to git/spearce.git and this is about to go into next.\nSo... you just caught me in time to do an amend.  :-)\n\n-- \nShawn.\n"},{"id":"56222","messageId":"20071017082003.GA10799@diana.vm.bytemark.co.uk","threadId":"10338","inReplyTo":"20071017021137.GO13801@spearce.org","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-17T08:20:03Z","receivedAt":"2007-10-17T08:20:03Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-16 22:11:37 -0400, Shawn O. Pearce wrote:\n\n> Nicolas Pitre <nico@cam.org> wrote:\n>\n> > Each progress can be on a single line instead of two.\n>\n> Nice. Of course that screws with git-gui and now I have to match two\n> regexs and not one. But whatever.\n\nMaybe an env variable could cause the code to emit machine-friendly\nprogress information instead?\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"56295","messageId":"alpine.LFD.0.9999.0710171653500.19446@xanadu.home","threadId":"10338","inReplyTo":"20071017082003.GA10799@diana.vm.bytemark.co.uk","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-10-17T20:56:09Z","receivedAt":"2007-10-17T20:56:09Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Wed, 17 Oct 2007, Karl Hasselström wrote:\n\n> On 2007-10-16 22:11:37 -0400, Shawn O. Pearce wrote:\n> \n> > Nicolas Pitre <nico@cam.org> wrote:\n> >\n> > > Each progress can be on a single line instead of two.\n> >\n> > Nice. Of course that screws with git-gui and now I have to match two\n> > regexs and not one. But whatever.\n> \n> Maybe an env variable could cause the code to emit machine-friendly\n> progress information instead?\n\nThat won't help with remotely generated progress unaware of local env \nvariable, and the remote server might still be generating old format.\n\n\nNicolas\n"},{"id":"56341","messageId":"20071018045807.GC14735@spearce.org","threadId":"10338","inReplyTo":"alpine.LFD.0.9999.0710171653500.19446@xanadu.home","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-18T04:58:07Z","receivedAt":"2007-10-18T04:58:07Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nicolas Pitre <nico@cam.org> wrote:\n> On Wed, 17 Oct 2007, Karl Hasselström wrote:\n> > On 2007-10-16 22:11:37 -0400, Shawn O. Pearce wrote:\n> > > Nicolas Pitre <nico@cam.org> wrote:\n> > >\n> > > > Each progress can be on a single line instead of two.\n> > >\n> > > Nice. Of course that screws with git-gui and now I have to match two\n> > > regexs and not one. But whatever.\n> > \n> > Maybe an env variable could cause the code to emit machine-friendly\n> > progress information instead?\n> \n> That won't help with remotely generated progress unaware of local env \n> variable, and the remote server might still be generating old format.\n\nAgreed.  I've already merged Nico's change into my next branch.\nI'll update git-gui soon to understand both formats, and that's that.\n\n-- \nShawn.\n"},{"id":"56375","messageId":"20071018083437.GA302@diana.vm.bytemark.co.uk","threadId":"10338","inReplyTo":"alpine.LFD.0.9999.0710171653500.19446@xanadu.home","subject":"Re: [PATCH 1/6] more compact progress display","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-18T08:34:37Z","receivedAt":"2007-10-18T08:34:37Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-17 16:56:09 -0400, Nicolas Pitre wrote:\n\n> On Wed, 17 Oct 2007, Karl Hasselström wrote:\n>\n> > Maybe an env variable could cause the code to emit\n> > machine-friendly progress information instead?\n>\n> That won't help with remotely generated progress unaware of local\n> env variable, and the remote server might still be generating old\n> format.\n\nAh, I didn't realize the progress meter was generated on the remote\nside. Sorry for the noise.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}