{"thread":{"id":"8282","subject":"[PATCH] Fix the progress code to output LF only when it is really needed","startedAt":"2007-05-23T16:07:25Z","lastAt":"2007-05-23T16:07:25Z","messageCount":1,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43038","messageId":"81b0412b0705230907x482a0f52n6e6b2302f0f20d04@mail.gmail.com","threadId":"8282","inReplyTo":null,"subject":"[PATCH] Fix the progress code to output LF only when it is really needed","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-05-23T16:07:25Z","receivedAt":"2007-05-23T16:07:25Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Signed-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nI was wondering about why git-reset --hard now prints an empty\nline between the command and the oneline commit description.\n\n progress.c |    6 +++++-\n progress.h |    1 +\n 2 files changed, 6 insertions(+), 1 deletions(-)\n\n\nFrom 139c597fecbb9ddf18c47b12cc97c42763a133bf Mon Sep 17 00:00:00 2001\nFrom: Alex Riesen <raa.lkml@gmail.com>\nDate: Wed, 23 May 2007 17:55:28 +0200\nSubject: [PATCH] Fix the progress code to output LF only when it is really needed\n\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n progress.c |    6 +++++-\n progress.h |    1 +\n 2 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/progress.c b/progress.c\nindex 05f7890..4344f4e 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -62,11 +62,13 @@ int display_progress(struct progress *progress, unsigned n)\n \t\t\tfprintf(stderr, \"%s%4u%% (%u/%u) done\\r\",\n \t\t\t\tprogress->prefix, percent, n, progress->total);\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\tprogress_update = 0;\n+\t\tprogress->need_lf = 1;\n \t\treturn 1;\n \t}\n \treturn 0;\n@@ -80,6 +82,7 @@ void start_progress(struct progress *progress, const char *title,\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@@ -95,12 +98,13 @@ void start_progress_delay(struct progress *progress, const char *title,\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 stop_progress(struct progress *progress)\n {\n \tclear_progress_signal();\n-\tif (progress->total)\n+\tif (progress->need_lf)\n \t\tfputc('\\n', stderr);\n }\ndiff --git a/progress.h b/progress.h\nindex 5ae1a89..a7c17ca 100644\n--- a/progress.h\n+++ b/progress.h\n@@ -8,6 +8,7 @@ struct progress {\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-- \n1.5.2.787.g56770\n\n"}]}