From: Gustaf Hendeby <hendeby@isy.liu.se>
To: gitster@pobox.com
Cc: vmiklos@frugalware.org, git@vger.kernel.org,
Gustaf Hendeby <hendeby@isy.liu.se>
Subject: [PATCH] Make git add -n and git -u -n output consistent
Date: Thu, 22 May 2008 23:59:42 +0200 [thread overview]
Message-ID: <1211493582-13400-1-git-send-email-hendeby@isy.liu.se> (raw)
In-Reply-To: <4835E1AE.6030201@isy.liu.se>
Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
---
This would be one way to go to get a more coherent behavior or the -n
switch to git add. It would also unify the implementation somewhat.
I'd suggest amending this to your patch, or would the output be likely
to be used by scrips? In that case I'd vote for changing the output
of git add -n -u,
/Gustaf
builtin-add.c | 19 ++++++-------------
1 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index dd2ca4b..e8dce30 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -261,17 +261,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
fill_directory(&dir, pathspec, ignored_too);
- if (show_only) {
- const char *sep = "", *eof = "";
- for (i = 0; i < dir.nr; i++) {
- printf("%s%s", sep, dir.entries[i]->name);
- sep = " ";
- eof = "\n";
- }
- fputs(eof, stdout);
- return 0;
- }
-
if (read_cache() < 0)
die("index file corrupt");
@@ -284,12 +273,16 @@ int cmd_add(int argc, const char **argv, const char *prefix)
die("no files added");
}
- for (i = 0; i < dir.nr; i++)
- if (add_file_to_cache(dir.entries[i]->name, verbose ? ADD_CACHE_VERBOSE : 0)) {
+ for (i = 0; i < dir.nr; i++) {
+ int flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
+ (show_only ? ADD_CACHE_PRETEND : 0) |
+ (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0));
+ if (add_file_to_cache(dir.entries[i]->name, flags)) {
if (!ignore_add_errors)
die("adding files failed");
exit_status = 1;
}
+ }
finish:
if (active_cache_changed) {
--
1.5.5.1.501.gefb4
next prev parent reply other threads:[~2008-05-22 22:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-15 16:08 [BUG] git add -u ignores --dry-run flag Gustaf Hendeby
2008-05-15 16:20 ` [PATCH] Make git add -u honor --dry-run Miklos Vajna
2008-05-15 18:46 ` Gustaf Hendeby
2008-05-15 23:42 ` Re* " Junio C Hamano
2008-05-16 0:13 ` Miklos Vajna
2008-05-19 22:14 ` Gustaf Hendeby
2008-05-22 18:16 ` Junio C Hamano
2008-05-22 19:34 ` Gustaf Hendeby
2008-05-22 20:38 ` Junio C Hamano
2008-05-22 21:12 ` Gustaf Hendeby
2008-05-22 21:59 ` Gustaf Hendeby [this message]
2008-05-23 4:40 ` [PATCH] Make git add -n and git -u -n output consistent Junio C Hamano
2008-05-23 8:14 ` Gustaf Hendeby
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=1211493582-13400-1-git-send-email-hendeby@isy.liu.se \
--to=hendeby@isy.liu.se \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=vmiklos@frugalware.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;
as well as URLs for NNTP newsgroup(s).