|  | 
| 48 | 48 | #include "csum-file.h" | 
| 49 | 49 | #include "promisor-remote.h" | 
| 50 | 50 | #include "hook.h" | 
|  | 51 | +#include "submodule.h" | 
|  | 52 | +#include "submodule-config.h" | 
| 51 | 53 | 
 | 
| 52 | 54 | /* Mask for the name length in ce_flags in the on-disk index */ | 
| 53 | 55 | 
 | 
| @@ -3927,13 +3929,54 @@ static void update_callback(struct diff_queue_struct *q, | 
| 3927 | 3929 | 		default: | 
| 3928 | 3930 | 			die(_("unexpected diff status %c"), p->status); | 
| 3929 | 3931 | 		case DIFF_STATUS_MODIFIED: | 
| 3930 |  | -		case DIFF_STATUS_TYPE_CHANGED: | 
|  | 3932 | +		case DIFF_STATUS_TYPE_CHANGED: { | 
|  | 3933 | +			const struct submodule *sub = submodule_from_path(data->repo, null_oid(the_hash_algo), path); | 
|  | 3934 | +			if (sub && sub->name && sub->ignore && !strcmp(sub->ignore, "all")) { | 
|  | 3935 | +				int pathspec_matches = 0; | 
|  | 3936 | +				char *norm_pathspec = NULL; | 
|  | 3937 | +				int ps_i; | 
|  | 3938 | +				trace_printf("ignore=all %s\n", path); | 
|  | 3939 | +				trace_printf("pathspec %s\n", | 
|  | 3940 | +						 (data->pathspec && data->pathspec->nr) ? "has pathspec" : "no pathspec"); | 
|  | 3941 | +				/* Safely scan all pathspec items (q->nr may exceed pathspec->nr). */ | 
|  | 3942 | +				if (data->pathspec) { | 
|  | 3943 | +					for (ps_i = 0; ps_i < data->pathspec->nr; ps_i++) { | 
|  | 3944 | +						const char *m = data->pathspec->items[ps_i].match; | 
|  | 3945 | +						if (!m) | 
|  | 3946 | +							continue; | 
|  | 3947 | +						norm_pathspec = xstrdup(m); | 
|  | 3948 | +						strip_dir_trailing_slashes(norm_pathspec); | 
|  | 3949 | +						if (!strcmp(path, norm_pathspec)) { | 
|  | 3950 | +							pathspec_matches = 1; | 
|  | 3951 | +							free(norm_pathspec); | 
|  | 3952 | +							norm_pathspec = NULL; | 
|  | 3953 | +							break; | 
|  | 3954 | +						} | 
|  | 3955 | +						free(norm_pathspec); | 
|  | 3956 | +						norm_pathspec = NULL; | 
|  | 3957 | +					} | 
|  | 3958 | +				} | 
|  | 3959 | +				if (pathspec_matches) { | 
|  | 3960 | +					if (data->ignored_too && data->ignored_too > 0) { | 
|  | 3961 | +						trace_printf("Forcing add of submodule ignored=all due to --force: %s\n", path); | 
|  | 3962 | +					} else { | 
|  | 3963 | +						printf(_("Skipping submodule due to ignore=all: %s"), path); | 
|  | 3964 | +						printf(_("Use -f if you really want to add them.") ); | 
|  | 3965 | +						continue; | 
|  | 3966 | +					} | 
|  | 3967 | +				} else { | 
|  | 3968 | +					/* No explicit pathspec match -> skip silently (or with trace). */ | 
|  | 3969 | +					trace_printf("pathspec does not match %s\n", path); | 
|  | 3970 | +					continue; | 
|  | 3971 | +				} | 
|  | 3972 | +			} | 
| 3931 | 3973 | 			if (add_file_to_index(data->index, path, data->flags)) { | 
| 3932 | 3974 | 				if (!(data->flags & ADD_CACHE_IGNORE_ERRORS)) | 
| 3933 | 3975 | 					die(_("updating files failed")); | 
| 3934 | 3976 | 				data->add_errors++; | 
| 3935 | 3977 | 			} | 
| 3936 | 3978 | 			break; | 
|  | 3979 | +		} | 
| 3937 | 3980 | 		case DIFF_STATUS_DELETED: | 
| 3938 | 3981 | 			if (data->flags & ADD_CACHE_IGNORE_REMOVAL) | 
| 3939 | 3982 | 				break; | 
|  | 
0 commit comments