26
};
27
static int patch_interactive, add_interactive, edit_interactive;
28
static int take_worktree_changes;
29
+static int add_renormalize;
30
31
struct update_callback_data {
32
int flags;
124
return !!data.add_errors;
125
}
126
127
+static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
128
+{
129
+ int i, retval = 0;
130
+
131
+ for (i = 0; i < active_nr; i++) {
132
+ struct cache_entry *ce = active_cache[i];
133
+
134
+ if (ce_stage(ce))
135
+ continue; /* do not touch unmerged paths */
136
+ if (!S_ISREG(ce->ce_mode) && !S_ISLNK(ce->ce_mode))
137
+ continue; /* do not touch non blobs */
138
+ if (pathspec && !ce_path_match(ce, pathspec, NULL))
139
+ continue;
140
+ retval |= add_file_to_cache(ce->name, flags | HASH_RENORMALIZE);
141
+ }
142
+
143
+ return retval;
144
+}
145
+
146
static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, int prefix)
147
{
148
char *seen;
296
OPT_BOOL('e', "edit", &edit_interactive, N_("edit current diff and apply")),
297
OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files")),
298
OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
299
+ OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")),
300
OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
301
OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")),
302
{ OPTION_CALLBACK, 0, "ignore-removal", &addremove_explicit,
427
chmod_arg[1] != 'x' || chmod_arg[2]))
428
die(_("--chmod param '%s' must be either -x or +x"), chmod_arg);
429
409
- add_new_files = !take_worktree_changes && !refresh_only;
430
+ add_new_files = !take_worktree_changes && !refresh_only && !add_renormalize;
431
require_pathspec = !(take_worktree_changes || (0 < addremove_explicit));
432
433
hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
521
522
plug_bulk_checkin();
523
503
- exit_status |= add_files_to_cache(prefix, &pathspec, flags);
524
+ if (add_renormalize)
525
+ exit_status |= renormalize_tracked_files(&pathspec, flags);
526
+ else
527
+ exit_status |= add_files_to_cache(prefix, &pathspec, flags);
528
529
if (add_new_files)
530
exit_status |= add_files(&dir, flags);