summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8a62a30)
raw | patch | inline | side by side (parent: 8a62a30)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 13 Jul 2005 19:45:51 +0000 (12:45 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Wed, 13 Jul 2005 19:55:07 +0000 (12:55 -0700) |
Porcelain layers often want to find only names of changed files,
and even with diff-raw output format they end up having to pick
out only the filename. Support --name-only (and --name-only-z
for xargs -0 and cpio -0 users that want to treat filenames with
embedded newlines sanely) flag to help them.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
and even with diff-raw output format they end up having to pick
out only the filename. Support --name-only (and --name-only-z
for xargs -0 and cpio -0 users that want to treat filenames with
embedded newlines sanely) flag to help them.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff-cache.c | patch | blob | history | |
diff-files.c | patch | blob | history | |
diff-stages.c | patch | blob | history | |
diff-tree.c | patch | blob | history | |
diff.c | patch | blob | history | |
diff.h | patch | blob | history |
diff --git a/diff-cache.c b/diff-cache.c
index 33b3b3177990a42f06cf2e5723f22188f993ae30..e1ac57dde83ce9441d9b3d591b2eab6bd8560397 100644 (file)
--- a/diff-cache.c
+++ b/diff-cache.c
diff_output_format = DIFF_FORMAT_MACHINE;
continue;
}
+ if (!strcmp(arg, "--name-only")) {
+ diff_output_format = DIFF_FORMAT_NAME;
+ continue;
+ }
+ if (!strcmp(arg, "--name-only-z")) {
+ diff_output_format = DIFF_FORMAT_NAME_Z;
+ continue;
+ }
if (!strcmp(arg, "-R")) {
diff_setup_opt |= DIFF_SETUP_REVERSE;
continue;
diff --git a/diff-files.c b/diff-files.c
index 3221e319798c46b6208da54b23232b9ec4a048d2..6d2aec34067071894f8e6abc5a94fb7415bc328f 100644 (file)
--- a/diff-files.c
+++ b/diff-files.c
; /* no-op */
else if (!strcmp(argv[1], "-z"))
diff_output_format = DIFF_FORMAT_MACHINE;
+ else if (!strcmp(argv[1], "--name-only"))
+ diff_output_format = DIFF_FORMAT_NAME;
+ else if (!strcmp(argv[1], "--name-only-z"))
+ diff_output_format = DIFF_FORMAT_NAME_Z;
else if (!strcmp(argv[1], "-R"))
diff_setup_opt |= DIFF_SETUP_REVERSE;
else if (!strncmp(argv[1], "-S", 2))
diff --git a/diff-stages.c b/diff-stages.c
index 738fe5d987352528c407adba1f50c030dc1674e1..9d33535fe0553867a892c8b1ed77b4eb7233579e 100644 (file)
--- a/diff-stages.c
+++ b/diff-stages.c
find_copies_harder = 1;
else if (!strcmp(arg, "-z"))
diff_output_format = DIFF_FORMAT_MACHINE;
+ else if (!strcmp(arg, "--name-only"))
+ diff_output_format = DIFF_FORMAT_NAME;
+ else if (!strcmp(arg, "--name-only-z"))
+ diff_output_format = DIFF_FORMAT_NAME_Z;
else if (!strcmp(arg, "-R"))
diff_setup_opt |= DIFF_SETUP_REVERSE;
else if (!strncmp(arg, "-S", 2))
diff --git a/diff-tree.c b/diff-tree.c
index ea237051ee5e5249f8096ae75b188b6b7a55011a..f499d2ead5f3977fb0b5be2b21765c94a87ffd6f 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
find_copies_harder = 1;
continue;
}
+ if (!strcmp(arg, "--name-only")) {
+ diff_output_format = DIFF_FORMAT_NAME;
+ continue;
+ }
+ if (!strcmp(arg, "--name-only-z")) {
+ diff_output_format = DIFF_FORMAT_NAME_Z;
+ continue;
+ }
if (!strcmp(arg, "-z")) {
diff_output_format = DIFF_FORMAT_MACHINE;
continue;
index 36bbda6d8de847a912b21afc705cad63d121f5c9..d0962bac9629e886f6b4f7c30f0547542e94a237 100644 (file)
--- a/diff.c
+++ b/diff.c
putchar(line_termination);
}
+static void diff_flush_name(struct diff_filepair *p,
+ int line_termination)
+{
+ printf("%s%c", p->two->path, line_termination);
+}
+
int diff_unmodified_pair(struct diff_filepair *p)
{
/* This function is written stricter than necessary to support
int line_termination = '\n';
int inter_name_termination = '\t';
- if (diff_output_style == DIFF_FORMAT_MACHINE)
+ if (diff_output_style == DIFF_FORMAT_MACHINE ||
+ diff_output_style == DIFF_FORMAT_NAME_Z)
line_termination = inter_name_termination = 0;
for (i = 0; i < q->nr; i++) {
diff_flush_raw(p, line_termination,
inter_name_termination);
break;
+ case DIFF_FORMAT_NAME:
+ case DIFF_FORMAT_NAME_Z:
+ diff_flush_name(p, line_termination);
+ break;
}
}
for (i = 0; i < q->nr; i++)
index 9f0852d321bbed548fa57b5afdc3aad25c1dd943..46c0e236c3a894141f685f8cf1993003c0c9cf81 100644 (file)
--- a/diff.h
+++ b/diff.h
#define DIFF_FORMAT_MACHINE 1
#define DIFF_FORMAT_PATCH 2
#define DIFF_FORMAT_NO_OUTPUT 3
+#define DIFF_FORMAT_NAME 4
+#define DIFF_FORMAT_NAME_Z 5
extern void diff_flush(int output_style);