push limitations
v4 cover push limitations
The first iteration of this patch series can be found here:
http://thread.gmane.org/gmane.comp.version-control.git/176328/focus=176327
The second iteration of this patch series can be found here:
http://thread.gmane.org/gmane.comp.version-control.git/177992
The third iteration of this patch series can be found here:
http://thread.gmane.org/gmane.comp.version-control.git/179037/focus=179048
Fredrik Gustafsson (2):
rev-parse: add option --is-well-formed-git-dir [path]
push: Don't push a repository with unpushed submodules
Documentation/git-push.txt | 6 ++ Documentation/git-rev-parse.txt | 4 ++ builtin/push.c | 17 ++++++ builtin/rev-parse.c | 8 +++ cache.h | 1 + combine-diff.c | 2 +- setup.c | 7 +++ submodule.c | 108 +++++++++++++++++++++++++++++++++++++++ submodule.h | 1 + t/t5531-deep-submodule-push.sh | 94 ++++++++++++++++++++++++++++++++++ t/t7400-submodule-basic.sh | 4 +- t/t7403-submodule-sync.sh | 5 +- t/t7407-submodule-foreach.sh | 97 ++++++++++++++++++----------------- transport.c | 9 +++ transport.h | 1 + 15 files changed, 312 insertions(+), 52 deletions(-)
Signature · 1 line
1.7.6.398.g64865.dirty
PATCH v4 2/2 push: Don't push a repository with unpushed submodules
When working with submodules it is easy to forget to push a submodule to the server but pushing a super-project that contains a commit for that submodule. The result is that the superproject points at a submodule commit that is not available on the server.
This adds the option --recurse-submodules=check to push. When using this option git will check that all submodule commits that are about to be pushed are present on a remote of the submodule.
To be able to use a combined diff, disabling a diff callback has been removed from combined-diff.c.
---
I am not sure whether the change required for the diff callback has other side effects. Another pair of eyes appreciated.
Documentation/git-push.txt | 6 ++ builtin/push.c | 17 ++++++ combine-diff.c | 2 +- submodule.c | 108 ++++++++++++++++++++++++++++++++++++++++ submodule.h | 1 + t/t5531-deep-submodule-push.sh | 94 ++++++++++++++++++++++++++++++++++ transport.c | 9 +++ transport.h | 1 + 8 files changed, 237 insertions(+), 1 deletions(-)
Documentation/git-push.txt +6 -0
@@ -162,6 +162,12 @@ useful if you write an alias or script around 'git push'. is specified. This flag forces progress status even if the standard error stream is not directed to a terminal. +--recurse-submodules=check:: + Check whether all submodule commits used by the revisions to be + pushed are available on a remote tracking branch. Otherwise the + push will be aborted and the command will exit with non-zero status. + + include::urls-remotes.txt[] OUTPUT
builtin/push.c +17 -0
@@ -8,6 +8,7 @@#include "remote.h" #include "transport.h" #include "parse-options.h" +#include "submodule.h" static const char *const push_usage[] = {"git push [<options>] [<repository> [<refspec>...]]" ,
@@ -219,6 +220,19 @@ static int do_push(const char *repo, int flags)return !!errs; } +static int option_parse_recurse_submodules (const struct option *opt, +const char *arg,int unset) +{ +int *flags = opt->value; +if (arg) { +if (!strcmp (arg,"check" )) + *flags |=TRANSPORT_RECURSE_SUBMODULES_CHECK ; +else +die ("bad %s argument: %s" , opt->long_name, arg); + } +return 0 ; +} +int cmd_push (int argc,const char **argv,const char *prefix) {int flags =0 ;
@@ -236,6 +250,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)OPT_BIT ('n' ,"dry-run" , &flags,"dry run" ,TRANSPORT_PUSH_DRY_RUN ),OPT_BIT (0 ,"porcelain" , &flags,"machine-readable output" ,TRANSPORT_PUSH_PORCELAIN ),OPT_BIT ('f' ,"force" , &flags,"force updates" ,TRANSPORT_PUSH_FORCE ), + { OPTION_CALLBACK, 0, "recurse-submodules", &flags, "check", +"controls recursive pushing of submodules" , + PARSE_OPT_OPTARG, option_parse_recurse_submodules },OPT_BOOLEAN (0 ,"thin" , &thin,"use thin pack" ),OPT_STRING (0 ,"receive-pack" , &receivepack,"receive-pack" ,"receive pack program" ), OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
combine-diff.c +1 -1
@@ -1068,7 +1068,7 @@ void diff_tree_combined(const unsigned char *sha1,* when doing combined diff. */ int stat_opt = (opt->output_format & - (DIFF_FORMAT_NUMSTAT |DIFF_FORMAT_DIFFSTAT )); + (DIFF_FORMAT_NUMSTAT |DIFF_FORMAT_DIFFSTAT |DIFF_FORMAT_CALLBACK ));if (i ==0 && stat_opt) diffopts.output_format = stat_opt;else
submodule.c +108 -0
114 lines not on this page · raw message
submodule.h +1 -0
@@ -29,5 +29,6 @@ int fetch_populated_submodules(int num_options, const char **options,unsigned is_submodule_modified (const char *path,int ignore_untracked);int merge_submodule (unsigned char result[20 ],const char *path,const unsigned char base[20 ],const unsigned char a[20 ],const unsigned char b[20 ]); +int check_submodule_needs_pushing (unsigned char new_sha1[20 ],const char *remotes_name);#endif
t/t5531-deep-submodule-push.sh +94 -0
98 lines not on this page · raw message
transport.c +9 -0
@@ -10,6 +10,7 @@#include "refs.h" #include "branch.h" #include "url.h" +#include "submodule.h" /* rsync support */
@@ -1041,6 +1042,14 @@ int transport_push(struct transport *transport, flags &TRANSPORT_PUSH_MIRROR , flags & TRANSPORT_PUSH_FORCE); +if ((flags &TRANSPORT_RECURSE_SUBMODULES_CHECK ) && !is_bare_repository ()) { +struct ref *ref = remote_refs; +for (; ref; ref = ref->next) +if (!is_null_sha1 (ref->new_sha1) && +check_submodule_needs_pushing (ref->new_sha1,transport->remote->name)) +die ("There are unpushed submodules, aborting." ); + } + push_ret = transport->push_refs (transport, remote_refs, flags); err =push_had_errors (remote_refs); ret = push_ret | err;
transport.h +1 -0
@@ -101,6 +101,7 @@ struct transport {#define TRANSPORT_PUSH_MIRROR 8#define TRANSPORT_PUSH_PORCELAIN 16#define TRANSPORT_PUSH_SET_UPSTREAM 32 +#define TRANSPORT_RECURSE_SUBMODULES_CHECK 64#define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
Signature · 1 line
1.7.6.398.g64865.dirty
Please ignore this series, it slipped through by accident.
Am 14.08.2011 10:57, schrieb Fredrik Gustafsson:
Quoted 31 lines
The first iteration of this patch series can be found here:
http://thread.gmane.org/gmane.comp.version-control.git/176328/focus=176327The second iteration of this patch series can be found here:
http://thread.gmane.org/gmane.comp.version-control.git/177992The third iteration of this patch series can be found here:
http://thread.gmane.org/gmane.comp.version-control.git/179037/focus=179048Fredrik Gustafsson (2):
rev-parse: add option --is-well-formed-git-dir [path]
push: Don't push a repository with unpushed submodulesDocumentation/git-push.txt | 6 ++ Documentation/git-rev-parse.txt | 4 ++ builtin/push.c | 17 ++++++ builtin/rev-parse.c | 8 +++ cache.h | 1 + combine-diff.c | 2 +- setup.c | 7 +++ submodule.c | 108 +++++++++++++++++++++++++++++++++++++++ submodule.h | 1 + t/t5531-deep-submodule-push.sh | 94 ++++++++++++++++++++++++++++++++++ t/t7400-submodule-basic.sh | 4 +- t/t7403-submodule-sync.sh | 5 +- t/t7407-submodule-foreach.sh | 97 ++++++++++++++++++----------------- transport.c | 9 +++ transport.h | 1 + 15 files changed, 312 insertions(+), 52 deletions(-)