aboutsummaryrefslogtreecommitdiffstats
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-07-13 12:45:51 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-13 12:55:07 -0700
commit52f28529f4f90cebdca47f8eacbff5cb20004bed (patch)
tree5582a75c2121fca35a99eb35d9e22f97cd2ed5b3 /diff.c
parent8a62a3097c55b22ee4543edef10322775ef62c92 (diff)
downloadgit-52f28529f4f90cebdca47f8eacbff5cb20004bed.tar.gz
[PATCH] git-diff-*: --name-only and --name-only-z.
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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 36bbda6d8d..d0962bac96 100644
--- a/diff.c
+++ b/diff.c
@@ -818,6 +818,12 @@ static void diff_flush_raw(struct diff_filepair *p,
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
@@ -978,7 +984,8 @@ void diff_flush(int diff_output_style)
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++) {
@@ -997,6 +1004,10 @@ void diff_flush(int diff_output_style)
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++)