[PATCH 06/12] git submodule update: Handle unmerged submodules in C
Signed-off-by: Stefan Beller --- builtin/submodule--helper.c | 15 +++ git-submodule.sh| 6 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 47dc9cb..f81f37a 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -284,11 +284,18 @@ static int module_list_or_clone(int argc, const char **argv, const char *prefix) for (i = 0; i < list.nr; i++) { const struct cache_entry *ce = list.entries[i]; - if (ce_stage(ce)) - printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1)); - else - printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), ce_stage(ce)); + char *env_prefix = getenv("prefix"); + if (ce_stage(ce)) { + if (env_prefix) + fprintf(stderr, "Skipping unmerged submodule %s/%s", + env_prefix, ce->name); + else + fprintf(stderr, "Skipping unmerged submodule %s", + ce->name); + continue; + } + printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), ce_stage(ce)); utf8_fprintf(stdout, "%s\n", ce->name); } return 0; diff --git a/git-submodule.sh b/git-submodule.sh index d2d80e2..0754ecd 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -661,11 +661,7 @@ cmd_update() while read mode sha1 stage sm_path do die_if_unmatched "$mode" - if test "$stage" = U - then - echo >&2 "Skipping unmerged submodule $prefix$sm_path" - continue - fi + name=$(git submodule--helper name "$sm_path") || exit url=$(git config submodule."$name".url) if ! test -z "$update" -- 2.5.0.277.gfdc362b.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 06/12] git submodule update: Handle unmerged submodules in C
Stefan Beller writes: > Signed-off-by: Stefan Beller > --- > builtin/submodule--helper.c | 15 +++ > git-submodule.sh| 6 +- > 2 files changed, 12 insertions(+), 9 deletions(-) > > diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c > index 47dc9cb..f81f37a 100644 > --- a/builtin/submodule--helper.c > +++ b/builtin/submodule--helper.c > @@ -284,11 +284,18 @@ static int module_list_or_clone(int argc, const char > **argv, const char *prefix) > for (i = 0; i < list.nr; i++) { > const struct cache_entry *ce = list.entries[i]; > > - if (ce_stage(ce)) > - printf("%06o %s U\t", ce->ce_mode, > sha1_to_hex(null_sha1)); > - else > - printf("%06o %s %d\t", ce->ce_mode, > sha1_to_hex(ce->sha1), ce_stage(ce)); > + char *env_prefix = getenv("prefix"); This somehow makes me feel dirty. Do we really export such an environment variable that is named overly generically to communicate with our own helpers? I can see why you need to be able to prefix leading paths (i.e. you would need to prefix path to the enclosing submodule to a path to obtain the "global view" from the very top-level superproject while recursing into nested submodules), but still... > + if (ce_stage(ce)) { > + if (env_prefix) > + fprintf(stderr, "Skipping unmerged submodule > %s/%s", > + env_prefix, ce->name); > + else > + fprintf(stderr, "Skipping unmerged submodule > %s", > + ce->name); > + continue; > + } > > + printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), > ce_stage(ce)); > utf8_fprintf(stdout, "%s\n", ce->name); > } > return 0; > diff --git a/git-submodule.sh b/git-submodule.sh > index d2d80e2..0754ecd 100755 > --- a/git-submodule.sh > +++ b/git-submodule.sh > @@ -661,11 +661,7 @@ cmd_update() > while read mode sha1 stage sm_path > do > die_if_unmatched "$mode" > - if test "$stage" = U > - then > - echo >&2 "Skipping unmerged submodule $prefix$sm_path" > - continue > - fi > + > name=$(git submodule--helper name "$sm_path") || exit > url=$(git config submodule."$name".url) > if ! test -z "$update" -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 06/12] git submodule update: Handle unmerged submodules in C
On Tue, Oct 20, 2015 at 2:11 PM, Junio C Hamano wrote: > Stefan Beller writes: > >> Signed-off-by: Stefan Beller >> --- >> builtin/submodule--helper.c | 15 +++ >> git-submodule.sh| 6 +- >> 2 files changed, 12 insertions(+), 9 deletions(-) >> >> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c >> index 47dc9cb..f81f37a 100644 >> --- a/builtin/submodule--helper.c >> +++ b/builtin/submodule--helper.c >> @@ -284,11 +284,18 @@ static int module_list_or_clone(int argc, const char >> **argv, const char *prefix) >> for (i = 0; i < list.nr; i++) { >> const struct cache_entry *ce = list.entries[i]; >> >> - if (ce_stage(ce)) >> - printf("%06o %s U\t", ce->ce_mode, >> sha1_to_hex(null_sha1)); >> - else >> - printf("%06o %s %d\t", ce->ce_mode, >> sha1_to_hex(ce->sha1), ce_stage(ce)); >> + char *env_prefix = getenv("prefix"); > [Just checked the date, it's the old series. I am about to send out a new series which collapses some patches in here, is on top of the fixes series and off course fixes this issue ;) ] > This somehow makes me feel dirty. Do we really export such an > environment variable that is named overly generically to communicate > with our own helpers? I agree that this is bad. It was the fastest way. I should have taken the slower road. I think I'll replace this with another argument. > > I can see why you need to be able to prefix leading paths (i.e. you > would need to prefix path to the enclosing submodule to a path to > obtain the "global view" from the very top-level superproject while > recursing into nested submodules), but still... > >> + if (ce_stage(ce)) { >> + if (env_prefix) >> + fprintf(stderr, "Skipping unmerged submodule >> %s/%s", >> + env_prefix, ce->name); >> + else >> + fprintf(stderr, "Skipping unmerged submodule >> %s", >> + ce->name); >> + continue; >> + } >> >> + printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), >> ce_stage(ce)); >> utf8_fprintf(stdout, "%s\n", ce->name); >> } >> return 0; >> diff --git a/git-submodule.sh b/git-submodule.sh >> index d2d80e2..0754ecd 100755 >> --- a/git-submodule.sh >> +++ b/git-submodule.sh >> @@ -661,11 +661,7 @@ cmd_update() >> while read mode sha1 stage sm_path >> do >> die_if_unmatched "$mode" >> - if test "$stage" = U >> - then >> - echo >&2 "Skipping unmerged submodule $prefix$sm_path" >> - continue >> - fi >> + >> name=$(git submodule--helper name "$sm_path") || exit >> url=$(git config submodule."$name".url) >> if ! test -z "$update" -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html