path: root/submodule.h
diff options
authorJens Lehmann <>2011-03-06 22:10:46 (GMT)
committerJunio C Hamano <>2011-03-09 21:10:35 (GMT)
commit88a21979c5717e3f37b9691e90b6dbf2b94c751a (patch)
tree4ab2508d6ea972df446b45b56b470330610176d2 /submodule.h
parent046613c5465e4fc0611f93a5ef31d3815fb50c22 (diff)
fetch/pull: recurse into submodules when necessary
To be able to access all commits of populated submodules referenced by the superproject it is sufficient to only then let "git fetch" recurse into a submodule when the new commits fetched in the superproject record new commits for it. Having these commits present is extremely useful when using the "--submodule" option to "git diff" (which is what "git gui" and "gitk" do since 1.6.6), as all submodule commits needed for creating a descriptive output can be accessed. Also merging submodule commits (added in 1.7.3) depends on the submodule commits in question being present to work. Last but not least this enables disconnected operation when using submodules, as all commits necessary for a successful "git submodule update -N" will have been fetched automatically. So we choose this mode as the default for fetch and pull. Before a new or changed ref from upstream is updated in update_local_ref() "git rev-list <new-sha1> --not --branches --remotes" is used to determine all newly fetched commits. These are then walked and diffed against their parent(s) to see if a submodule has been changed. If that is the case, its path is stored to be fetched after the superproject fetch is completed. Using the "--recurse-submodules" or the "--no-recurse-submodules" option disables the examination of the fetched refs because the result will be ignored anyway. There is currently no infrastructure for storing deleted and new submodules in the .git directory of the superproject. That's why fetch and pull for now only fetch submodules that are already checked out and are not renamed. In t7403 the "--no-recurse-submodules" argument had to be added to "git pull" to avoid failure because of the moved upstream submodule repo. Thanks-to: Jonathan Nieder <> Thanks-to: Heiko Voigt <> Signed-off-by: Jens Lehmann <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'submodule.h')
1 files changed, 9 insertions, 0 deletions
diff --git a/submodule.h b/submodule.h
index 4729023..3434a8e 100644
--- a/submodule.h
+++ b/submodule.h
@@ -3,17 +3,26 @@
struct diff_options;
+enum {
void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
const char *path);
int submodule_config(const char *var, const char *value, void *cb);
void gitmodules_config();
int parse_submodule_config_option(const char *var, const char *value);
void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
+int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
void show_submodule_summary(FILE *f, const char *path,
unsigned char one[20], unsigned char two[20],
unsigned dirty_submodule,
const char *del, const char *add, const char *reset);
void set_config_fetch_recurse_submodules(int value);
+void check_for_new_submodule_commits(unsigned char new_sha1[20]);
int fetch_populated_submodules(int num_options, const char **options,
const char *prefix, int ignore_config,
int quiet);