X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=builtin%2Fadd.c;h=1e33ab81f2e80d8d66b404e5bc53334de4ca7311;hb=c937d70bfb7661d5122e08758ae0531073a719ed;hp=26b6ced09ea26d7eda4c63a930354d2bb580a547;hpb=34415c76c8f67c8692090ef4911d1626689e8f38;p=thirdparty%2Fgit.git diff --git a/builtin/add.c b/builtin/add.c index 26b6ced09e..1e33ab81f2 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -38,17 +38,23 @@ struct update_callback_data { int add_errors; }; -static void chmod_pathspec(struct pathspec *pathspec, char flip) +static void chmod_pathspec(struct pathspec *pathspec, char flip, int show_only) { int i; for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; + int err; if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL)) continue; - if (chmod_cache_entry(ce, flip) < 0) + if (!show_only) + err = chmod_cache_entry(ce, flip); + else + err = S_ISREG(ce->ce_mode) ? 0 : -1; + + if (err < 0) fprintf(stderr, "cannot chmod %cx '%s'\n", flip, ce->name); } } @@ -239,7 +245,7 @@ int run_add_interactive(const char *revision, const char *patch_mode, return status; } -int interactive_add(int argc, const char **argv, const char *prefix, int patch) +int interactive_add(const char **argv, const char *prefix, int patch) { struct pathspec pathspec; @@ -451,7 +457,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) if (add_interactive) { if (pathspec_from_file) die(_("--pathspec-from-file is incompatible with --interactive/--patch")); - exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive)); + exit(interactive_add(argv + 1, prefix, patch_interactive)); } if (legacy_stash_p) { struct pathspec pathspec; @@ -609,7 +615,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) exit_status |= add_files(&dir, flags); if (chmod_arg && pathspec.nr) - chmod_pathspec(&pathspec, chmod_arg[0]); + chmod_pathspec(&pathspec, chmod_arg[0], show_only); unplug_bulk_checkin(); finish: