From: Junio C Hamano <junkio@cox.net>
To: Petr Baudis <pasky@ucw.cz>
Cc: Linus Torvalds <torvalds@osdl.org>, git@vger.kernel.org
Subject: [PATCH 2/4] Add -z option to show-files
Date: Thu, 14 Apr 2005 23:04:12 -0700 [thread overview]
Message-ID: <7vis2oo9sz.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 7vr7hco9z7.fsf@assigned-by-dhcp.cox.net
This adds NUL-terminated output (-z) to show-files. This is necessary
for merge-trees script to deal with filenames with embedded newlines.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
show-files.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
Index: show-files.c
===================================================================
--- 6767883b330882bc0e9a7c1e4fd999c0ee97ba3a/show-files.c (mode:100664 sha1:a9fa6767a418f870a34b39379f417bf37b17ee18)
+++ 21e5e9f7d7dfa81c6519f0204d5a467236c7fdd5/show-files.c (mode:100664 sha1:c392db8b4edb16675528f86e106e841f42bc74e4)
@@ -14,6 +14,7 @@
static int show_cached = 0;
static int show_others = 0;
static int show_ignored = 0;
+static int line_terminator = '\n';
static const char **dir;
static int nr_dir;
@@ -105,12 +106,12 @@
}
if (show_others) {
for (i = 0; i < nr_dir; i++)
- printf("%s\n", dir[i]);
+ printf("%s%c", dir[i], line_terminator);
}
if (show_cached) {
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
- printf("%s\n", ce->name);
+ printf("%s%c", ce->name, line_terminator);
}
}
if (show_deleted) {
@@ -119,7 +120,7 @@
struct stat st;
if (!stat(ce->name, &st))
continue;
- printf("%s\n", ce->name);
+ printf("%s%c", ce->name, line_terminator);
}
}
if (show_ignored) {
@@ -134,6 +135,11 @@
for (i = 1; i < argc; i++) {
char *arg = argv[i];
+ if (!strcmp(arg, "-z")) {
+ line_terminator = 0;
+ continue;
+ }
+
if (!strcmp(arg, "--cached")) {
show_cached = 1;
continue;
next prev parent reply other threads:[~2005-04-15 6:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-15 6:00 [PATCH 0/4] Merging merge-trees changes to pasky-0.4 Junio C Hamano
2005-04-15 6:03 ` [PATCH 1/4] Add --cacheinfo option to update-cache Junio C Hamano
2005-04-15 6:04 ` Junio C Hamano [this message]
2005-04-15 6:05 ` [PATCH 3/4] Add -r and -z options to ls-tree Junio C Hamano
2005-04-15 6:06 ` [PATCH 4/4] Makefile change and merge-trees script itself 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vis2oo9sz.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=pasky@ucw.cz \
--cc=torvalds@osdl.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox