git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Kevin Willford <kcwillford@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Kevin Willford <kewillf@microsoft.com>
Subject: [PATCH 1/2] format-patch: have progress option while generating patches
Date: Wed, 31 May 2017 08:04:26 -0700	[thread overview]
Message-ID: <20170531150427.7820-2-kewillf@microsoft.com> (raw)
In-Reply-To: <20170531150427.7820-1-kewillf@microsoft.com>

When generating patches for the rebase command if the user does
not realize the branch they are rebasing onto is thousands of
commits different there is no progress indication after initial
rewinding message.

This patch allows a progress option to be passed to format-patch
so that the user can be informed the progress of generating the
patch.  This option will then be used by the rebase command when
calling format-patch.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
---
 Documentation/git-format-patch.txt |  8 ++++++++
 builtin/log.c                      | 10 ++++++++++
 2 files changed, 18 insertions(+)

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index c890328b02..ee5f99f606 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -23,6 +23,7 @@ SYNOPSIS
 		   [(--reroll-count|-v) <n>]
 		   [--to=<email>] [--cc=<email>]
 		   [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]
+		   [--progress]
 		   [<common diff options>]
 		   [ <since> | <revision range> ]
 
@@ -260,6 +261,7 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 -q::
 --quiet::
 	Do not print the names of the generated files to standard output.
+	Progress is not reported to the standard error stream.
 
 --no-binary::
 	Do not output contents of changes in binary files, instead
@@ -283,6 +285,12 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
 	range are always formatted as creation patches, independently
 	of this flag.
 
+--progress::
+	Progress status is reported on the standard error stream
+	by default when it is attached to a terminal, unless -q
+	is specified. This flag forces progress status even if the
+	standard error stream is not directed to a terminal.
+
 CONFIGURATION
 -------------
 You can specify extra mail header lines to be added to each message,
diff --git a/builtin/log.c b/builtin/log.c
index 631fbc984f..02c50431b6 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -26,6 +26,7 @@
 #include "version.h"
 #include "mailmap.h"
 #include "gpg-interface.h"
+#include "progress.h"
 
 /* Set a default date-time format for git log ("log.date" config variable) */
 static const char *default_date_mode = NULL;
@@ -1409,6 +1410,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	char *branch_name = NULL;
 	char *base_commit = NULL;
 	struct base_tree_info bases;
+	int show_progress = 0;
+	struct progress *progress = NULL;
 
 	const struct option builtin_format_patch_options[] = {
 		{ OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
@@ -1480,6 +1483,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		OPT_FILENAME(0, "signature-file", &signature_file,
 				N_("add a signature from a file")),
 		OPT__QUIET(&quiet, N_("don't print the patch filenames")),
+		OPT_BOOL(0, "progress", &show_progress,
+			 N_("show progress")),
 		OPT_END()
 	};
 
@@ -1739,8 +1744,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		start_number--;
 	}
 	rev.add_signoff = do_signoff;
+
+	if (show_progress && !quiet)
+		progress = start_progress(_("Generating patch"), total);
 	while (0 <= --nr) {
 		int shown;
+		display_progress(progress, total - nr);
 		commit = list[nr];
 		rev.nr = total - nr + (start_number - 1);
 		/* Make the second and subsequent mails replies to the first */
@@ -1805,6 +1814,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		if (!use_stdout)
 			fclose(rev.diffopt.file);
 	}
+	stop_progress(&progress);
 	free(list);
 	free(branch_name);
 	string_list_clear(&extra_to, 0);
-- 
2.13.0.92.g73a4ce6a77


  reply	other threads:[~2017-05-31 15:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 15:04 [PATCH 0/2] Add progress to format-patch and rebase Kevin Willford
2017-05-31 15:04 ` Kevin Willford [this message]
2017-05-31 18:40   ` [PATCH 1/2] format-patch: have progress option while generating patches Stefan Beller
2017-05-31 19:31     ` Kevin Willford
2017-05-31 22:01   ` Jeff King
2017-06-01  4:10     ` Junio C Hamano
2017-06-01 11:15     ` Johannes Schindelin
2017-06-01 15:54       ` Jeff King
2017-05-31 15:04 ` [PATCH 2/2] rebase: turn on progress option by default for format-patch Kevin Willford
2017-05-31 19:08   ` Stefan Beller
2017-05-31 19:46     ` Kevin Willford
2017-05-31 20:27       ` Stefan Beller
2017-06-01 11:11     ` Johannes Schindelin
2017-05-31 22:11   ` Jeff King
2017-06-03 23:45     ` Junio C Hamano
2017-08-10 18:32 ` [PATCH v2 0/2] Add progress for format-patch and rebase Kevin Willford
2017-08-10 22:48   ` Junio C Hamano
2017-08-10 23:17     ` Jeff King
2017-08-10 18:32 ` [PATCH v2 1/2] format-patch: have progress option while generating patches Kevin Willford
2017-08-10 23:20   ` Jeff King
2017-08-11 22:18     ` Junio C Hamano
2017-08-12  8:06       ` Philip Oakley
2017-08-13  4:39         ` Jeff King
2017-08-14 16:45           ` Junio C Hamano
2017-08-14 18:35             ` Junio C Hamano
2017-08-14 22:29               ` Jeff King
2017-08-14 22:42                 ` Junio C Hamano
2017-08-14 23:08                   ` Jeff King
2017-08-14 23:23                     ` Junio C Hamano
2017-08-19 17:39                 ` [PATCH] progress: simplify "delayed" progress API Junio C Hamano
2017-08-19 20:58                   ` Junio C Hamano
2017-08-20  7:43                   ` Jeff King
2017-08-10 18:32 ` [PATCH v2 2/2] rebase: turn on progress option by default for format-patch Kevin Willford
2017-08-11 22:22   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170531150427.7820-2-kewillf@microsoft.com \
    --to=kcwillford@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kewillf@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).