summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 38ed1d8)
raw | patch | inline | side by side (parent: 38ed1d8)
author | Gustaf Hendeby <hendeby@isy.liu.se> | |
Thu, 22 May 2008 21:59:42 +0000 (23:59 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 23 May 2008 21:47:02 +0000 (14:47 -0700) |
Output format from "git add -n $path" lists path to blobs that are going
to be added on a single line, separated with SP. On the other hand, the
suggested "git add -u -n" shows one path per line, like "add '<file>'\n".
Of course, these two are inconsistent.
Plain "git add -n" can afford to only say names of paths, as all it does
is to add (update). However, "git add -u" needs to be able to express
"remove" somehow. So if we need to have them formatted the same way, we
need to unify with the "git add -n -u" format. Incidentally, this is
consistent with how 'update-index' says it.
This changes the output from "git add -n $paths" but as a general
principle, output from Porcelain commands is a fair game for improvements
and not for script consumption.
Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to be added on a single line, separated with SP. On the other hand, the
suggested "git add -u -n" shows one path per line, like "add '<file>'\n".
Of course, these two are inconsistent.
Plain "git add -n" can afford to only say names of paths, as all it does
is to add (update). However, "git add -u" needs to be able to express
"remove" somehow. So if we need to have them formatted the same way, we
need to unify with the "git add -n -u" format. Incidentally, this is
consistent with how 'update-index' says it.
This changes the output from "git add -n $paths" but as a general
principle, output from Porcelain commands is a fair game for improvements
and not for script consumption.
Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-add.c | patch | blob | history |
diff --git a/builtin-add.c b/builtin-add.c
index 05af57f6ec6d3d9b936a1808a005cb08e47a8d94..8f81f3fbfb06d0acb7df9a14fc3a873834cfecf0 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
int i, newfd;
const char **pathspec;
struct dir_struct dir;
+ int flags;
argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
newfd = hold_locked_index(&lock_file, 1);
+ flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
+ (show_only ? ADD_CACHE_PRETEND : 0));
+
if (take_worktree_changes) {
const char **pathspec;
- int flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
- (show_only ? ADD_CACHE_PRETEND : 0));
-
if (read_cache() < 0)
die("index file corrupt");
pathspec = get_pathspec(prefix, argv);
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");
}
for (i = 0; i < dir.nr; i++)
- add_file_to_cache(dir.entries[i]->name, verbose ? ADD_CACHE_VERBOSE : 0);
+ add_file_to_cache(dir.entries[i]->name, flags);
finish:
if (active_cache_changed) {