Skip to content

Commit b2d5354

Browse files
committed
add --force for adding submodule even ignore=all is set
1 parent a3105e7 commit b2d5354

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

builtin/add.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include "builtin.h"
8+
#include "trace.h"
89
#include "advice.h"
910
#include "config.h"
1011
#include "environment.h"
@@ -580,9 +581,10 @@ int cmd_add(int argc,
580581
if (add_renormalize)
581582
exit_status |= renormalize_tracked_files(repo, &pathspec, flags);
582583
else
584+
trace_printf("DEBUG ignored_too=%d\n", ignored_too);
583585
exit_status |= add_files_to_cache(repo, prefix,
584586
&pathspec, ps_matched,
585-
include_sparse, flags);
587+
include_sparse, flags, ignored_too);
586588

587589
if (take_worktree_changes && !add_renormalize && !ignore_add_errors &&
588590
report_path_error(ps_matched, &pathspec))

builtin/checkout.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,9 @@ static int merge_working_tree(const struct checkout_opts *opts,
898898
* entries in the index.
899899
*/
900900

901+
printf("adding files to index\n");
901902
add_files_to_cache(the_repository, NULL, NULL, NULL, 0,
902-
0);
903+
0, 0 );
903904
init_ui_merge_options(&o, the_repository);
904905
o.verbosity = 0;
905906
work = write_in_core_index_as_tree(the_repository);

builtin/commit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,9 @@ static const char *prepare_index(const char **argv, const char *prefix,
454454
char *ps_matched = xcalloc(pathspec.nr, 1);
455455
repo_hold_locked_index(the_repository, &index_lock,
456456
LOCK_DIE_ON_ERROR);
457+
printf("commit.c adding files to index\n");
457458
add_files_to_cache(the_repository, also ? prefix : NULL,
458-
&pathspec, ps_matched, 0, 0);
459+
&pathspec, ps_matched, 0, 0, 0 );
459460
if (!all && report_path_error(ps_matched, &pathspec))
460461
exit(128);
461462

read-cache-ll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ int cmp_cache_name_compare(const void *a_, const void *b_);
481481

482482
int add_files_to_cache(struct repository *repo, const char *prefix,
483483
const struct pathspec *pathspec, char *ps_matched,
484-
int include_sparse, int flags);
484+
int include_sparse, int flags, int ignored_too );
485485

486486
void overlay_tree_on_index(struct index_state *istate,
487487
const char *tree_name, const char *prefix);

read-cache.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,6 +3885,7 @@ struct update_callback_data {
38853885
struct index_state *index;
38863886
int include_sparse;
38873887
int flags;
3888+
int ignored_too;
38883889
int add_errors;
38893890
};
38903891

@@ -3930,9 +3931,25 @@ static void update_callback(struct diff_queue_struct *q,
39303931
const struct submodule *sub = submodule_from_path(data->repo, NULL, path);
39313932
if (sub) {
39323933
if ( sub->ignore ) {
3933-
fprintf(stderr, "GIT_TRACE: Skipping submodule with ignore NOT NULL: %s\n", path);
3934+
trace_printf("ignore=%s\n", sub->ignore);
39343935
if (strcmp(sub->ignore, "all") == 0) {
3936+
trace_printf("ignore=all - test\n");
3937+
if ( data->ignored_too ) {
3938+
trace_printf("ignored_too=%d --force given\n", data->ignored_too);
3939+
if ( data->ignored_too > 0 ) {
3940+
trace_printf("Adding submodule even ignore=all is due to --force|-f: %s\n", path);
3941+
} else {
3942+
printf("Skipping submodule with ignore=all: %s\n", path);
3943+
printf(" Use -f if you really want to add them.");
3944+
continue;
3945+
}
3946+
} else {
3947+
trace_printf("--force not set");
3948+
continue;
3949+
}
3950+
} else {
39353951
trace_printf("Skipping submodule with ignore=all: %s\n", path);
3952+
trace_printf(" Use -f if you really want to add them.");
39363953
continue;
39373954
}
39383955
}
@@ -3957,7 +3974,7 @@ static void update_callback(struct diff_queue_struct *q,
39573974

39583975
int add_files_to_cache(struct repository *repo, const char *prefix,
39593976
const struct pathspec *pathspec, char *ps_matched,
3960-
int include_sparse, int flags)
3977+
int include_sparse, int flags, int ignored_too )
39613978
{
39623979
struct update_callback_data data;
39633980
struct rev_info rev;
@@ -3966,6 +3983,8 @@ int add_files_to_cache(struct repository *repo, const char *prefix,
39663983
data.index = repo->index;
39673984
data.include_sparse = include_sparse;
39683985
data.flags = flags;
3986+
trace_printf("DEBUG ignored_too=%d\n", ignored_too);
3987+
data.ignored_too = ignored_too;
39693988

39703989
repo_init_revisions(repo, &rev, prefix);
39713990
setup_revisions(0, NULL, &rev, NULL);

0 commit comments

Comments
 (0)