summaryrefslogtreecommitdiff
path: root/builtin-apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-18 10:14:48 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-08-18 10:14:48 (GMT)
commita2bf404e280b8d56d0efa15bd9700464cf8f0d4d (patch)
treec0ba2232ecf9315c320327c35f86a6b7f66ada64 /builtin-apply.c
parent82e2765f59126f96da6e5dc30adf7c6189e9697d (diff)
downloadgit-a2bf404e280b8d56d0efa15bd9700464cf8f0d4d.zip
git-a2bf404e280b8d56d0efa15bd9700464cf8f0d4d.tar.gz
git-a2bf404e280b8d56d0efa15bd9700464cf8f0d4d.tar.bz2
git-apply --verbose
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-apply.c')
-rw-r--r--builtin-apply.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/builtin-apply.c b/builtin-apply.c
index 668be9c..42253e6 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -39,12 +39,13 @@ static int check;
static int apply = 1;
static int apply_in_reverse;
static int apply_with_reject;
+static int apply_verbosely;
static int no_add;
static int show_index_info;
static int line_termination = '\n';
static unsigned long p_context = -1;
static const char apply_usage[] =
-"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...";
+"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...";
static enum whitespace_eol {
nowarn_whitespace,
@@ -153,6 +154,24 @@ struct patch {
struct patch *next;
};
+static void say_patch_name(FILE *output, const char *pre, struct patch *patch, const char *post)
+{
+ fputs(pre, output);
+ if (patch->old_name && patch->new_name &&
+ strcmp(patch->old_name, patch->new_name)) {
+ write_name_quoted(NULL, 0, patch->old_name, 1, output);
+ fputs(" => ", output);
+ write_name_quoted(NULL, 0, patch->new_name, 1, output);
+ }
+ else {
+ const char *n = patch->new_name;
+ if (!n)
+ n = patch->old_name;
+ write_name_quoted(NULL, 0, n, 1, output);
+ }
+ fputs(post, output);
+}
+
#define CHUNKSIZE (8192)
#define SLOP (16)
@@ -1928,6 +1947,9 @@ static int check_patch_list(struct patch *patch)
int error = 0;
for (prev_patch = NULL; patch ; patch = patch->next) {
+ if (apply_verbosely)
+ say_patch_name(stderr,
+ "Checking patch ", patch, "...\n");
error |= check_patch(patch, prev_patch);
prev_patch = patch;
}
@@ -2253,8 +2275,12 @@ static int write_out_one_reject(struct patch *patch)
cnt++;
}
- if (!cnt)
+ if (!cnt) {
+ if (apply_verbosely)
+ say_patch_name(stderr,
+ "Applied patch ", patch, " cleanly.\n");
return 0;
+ }
/* This should not happen, because a removal patch that leaves
* contents are marked "rejected" at the patch level.
@@ -2262,6 +2288,10 @@ static int write_out_one_reject(struct patch *patch)
if (!patch->new_name)
die("internal error");
+ /* Say this even without --verbose */
+ say_patch_name(stderr, "Applying patch ", patch, " with");
+ fprintf(stderr, " %d rejects...\n", cnt);
+
cnt = strlen(patch->new_name);
if (ARRAY_SIZE(namebuf) <= cnt + 5) {
cnt = ARRAY_SIZE(namebuf) - 5;
@@ -2530,6 +2560,10 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
apply = apply_with_reject = 1;
continue;
}
+ if (!strcmp(arg, "--verbose")) {
+ apply_verbosely = 1;
+ continue;
+ }
if (!strcmp(arg, "--inaccurate-eof")) {
inaccurate_eof = 1;
continue;