{"thread":{"id":"17597","subject":"[PATCH] submodule: add --no-fetch parameter to update command","startedAt":"2009-02-05T22:18:32Z","lastAt":"2009-02-07T15:44:25Z","messageCount":4,"participants":["Fabian Franz","Lars Hjemli","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"103402","messageId":"1233872312-17781-1-git-send-email-git@fabian-franz.de","threadId":"17597","inReplyTo":null,"subject":"[PATCH] submodule: add --no-fetch parameter to update command","fromName":"Fabian Franz","fromEmail":"git@fabian-franz.de","sentAt":"2009-02-05T22:18:32Z","receivedAt":"2009-02-05T22:18:32Z","isPatch":true,"sender":{"key":"git@fabian-franz.de","avatar":null},"body":"git submodule update --no-fetch makes it possible to use git submodule\nupdate in complete offline mode by not fetching new revisions.\n\nThis does make sense in the following setup:\n\n* There is an unstable and a stable branch in the super/master repository.\n* The submodules might be at different revisions in the branches.\n* You are at some place without internet connection ;)\n\nWith this patch it is now possible to change branches and update\nthe submodules to be at the recorded revision without online access.\n\nAnother advantage is that with -N the update operation is faster, because fetch is checking for new updates even if there was no fetch/pull on the super/master repository since the last update.\n\nSigned-off-by: Fabian Franz <git@fabian-franz.de>\n---\n Documentation/git-submodule.txt |    7 ++++++-\n git-submodule.sh                |   19 ++++++++++++++++---\n 2 files changed, 22 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 2f207fb..3b8df44 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n 'git submodule' [--quiet] add [-b branch] [--] <repository> <path>\n 'git submodule' [--quiet] status [--cached] [--] [<path>...]\n 'git submodule' [--quiet] init [--] [<path>...]\n-'git submodule' [--quiet] update [--init] [--] [<path>...]\n+'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]\n 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n 'git submodule' [--quiet] foreach <command>\n 'git submodule' [--quiet] sync [--] [<path>...]\n@@ -172,6 +172,11 @@ OPTIONS\n \t(the default). This limit only applies to modified submodules. The\n \tsize is always limited to 1 for added/deleted/typechanged submodules.\n \n+-N::\n+--no-fetch::\n+\tThis option is only valid for the update command.\n+\tDon't fetch new objects from the remote site.\n+\n <path>...::\n \tPaths to submodule(s). When specified this will restrict the command\n \tto only operate on the submodules found at the specified paths.\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2f47e06..af8d10c 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -5,7 +5,7 @@\n # Copyright (c) 2007 Lars Hjemli\n \n USAGE=\"[--quiet] [--cached] \\\n-[add <repo> [-b branch] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \\\n+[add <repo> [-b branch] <path>]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit <n>] [<commit>]] \\\n [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]\"\n OPTIONS_SPEC=\n . git-sh-setup\n@@ -16,6 +16,7 @@ command=\n branch=\n quiet=\n cached=\n+nofetch=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -300,6 +301,10 @@ cmd_update()\n \t\t\tshift\n \t\t\tcmd_init \"$@\" || return\n \t\t\t;;\n+\t\t-N|--no-fetch)\n+\t\t\tshift\n+\t\t\tnofetch=1\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -345,8 +350,16 @@ cmd_update()\n \t\t\tthen\n \t\t\t\tforce=\"-f\"\n \t\t\tfi\n-\t\t\t(unset GIT_DIR; cd \"$path\" && git-fetch &&\n-\t\t\t\tgit-checkout $force -q \"$sha1\") ||\n+\n+\t\t\tif test -z \"$nofetch\"\n+\t\t\tthen\n+\t\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t\tgit-fetch) ||\n+\t\t\t\tdie \"Unable to fetch in submodule path '$path'\"\n+\t\t\tfi\n+\n+\t\t\t(unset GIT_DIR; cd \"$path\" &&\n+\t\t\t\t  git-checkout $force -q \"$sha1\") ||\n \t\t\tdie \"Unable to checkout '$sha1' in submodule path '$path'\"\n \n \t\t\tsay \"Submodule path '$path': checked out '$sha1'\"\n-- \n1.6.1.2.351.gccea\n"},{"id":"103535","messageId":"8c5c35580902061001m6259d4ebt1c0dea7691b0a5dc@mail.gmail.com","threadId":"17597","inReplyTo":"1233872312-17781-1-git-send-email-git@fabian-franz.de","subject":"Re: [PATCH] submodule: add --no-fetch parameter to update command","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2009-02-06T18:01:25Z","receivedAt":"2009-02-06T18:01:25Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On Thu, Feb 5, 2009 at 23:18, Fabian Franz <git@fabian-franz.de> wrote:\n> git submodule update --no-fetch makes it possible to use git submodule\n> update in complete offline mode by not fetching new revisions.\n\nThis is nice, but it would be even nicer IMHO if \"submodule update\"\nfirst tried to checkout the submodule commit and only if that failed\nwould it try to fetch objects (before re-trying the checkout).\n\n\n>  Documentation/git-submodule.txt |    7 ++++++-\n>  git-submodule.sh                |   19 ++++++++++++++++---\n>  2 files changed, 22 insertions(+), 4 deletions(-)\n\nExtending t/t7400-submodule-basic.sh would also be nice (either for\n--no-fetch or for a less fetchy \"submodule update\").\n\n--\nlarsh\n"},{"id":"103601","messageId":"7vbptey6tk.fsf@gitster.siamese.dyndns.org","threadId":"17597","inReplyTo":"1233872312-17781-1-git-send-email-git@fabian-franz.de","subject":"Re: [PATCH] submodule: add --no-fetch parameter to update command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-07T08:44:39Z","receivedAt":"2009-02-07T08:44:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fabian Franz <git@fabian-franz.de> writes:\n\n> git submodule update --no-fetch makes it possible to use git submodule\n> update in complete offline mode by not fetching new revisions.\n>\n> This does make sense in the following setup:\n>\n> * There is an unstable and a stable branch in the super/master repository.\n> * The submodules might be at different revisions in the branches.\n> * You are at some place without internet connection ;)\n>\n> With this patch it is now possible to change branches and update\n> the submodules to be at the recorded revision without online access.\n\nHow is this better than \"cd submodule/path && git checkout whatever\"?\n\n> Another advantage is that with -N the update operation is faster,\n> because fetch is checking for new updates even if there was no\n> fetch/pull on the super/master repository since the last update.\n\nDo we know this is common enough to deserve a shortopt -N?\n\nThe logic of the patch itself looks sane to me.\n"},{"id":"103632","messageId":"20090207154425.325390@gmx.net","threadId":"17597","inReplyTo":"8c5c35580902061001m6259d4ebt1c0dea7691b0a5dc@mail.gmail.com","subject":"Re: [PATCH] submodule: add --no-fetch parameter to update command","fromName":"Fabian Franz","fromEmail":"fabianfranz@gmx.de","sentAt":"2009-02-07T15:44:25Z","receivedAt":"2009-02-07T15:44:25Z","isPatch":true,"sender":{"key":"fabianfranz@gmx.de","avatar":null},"body":"> Fabian Franz <git@fabian-franz.de> writes:\n> \n> > git submodule update --no-fetch makes it possible to use git submodule\n> > update in complete offline mode by not fetching new revisions.\n> >\n> > This does make sense in the following setup:\n> >\n> > * There is an unstable and a stable branch in the super/master\n> repository.\n> > * The submodules might be at different revisions in the branches.\n> > * You are at some place without internet connection ;)\n> >\n> > With this patch it is now possible to change branches and update\n> > the submodules to be at the recorded revision without online access.\n> \n> How is this better than \"cd submodule/path && git checkout whatever\"?\n\nIt is better if you have a complex setup recorded in the master repository.\n\nIf my co-worker commited his newest revisions for the \"stable\" branch, I\nmight not know which of his revisions I need to checkout.\n\n> > Another advantage is that with -N the update operation is faster,\n> > because fetch is checking for new updates even if there was no\n> > fetch/pull on the super/master repository since the last update.\n> \n> Do we know this is common enough to deserve a shortopt -N?\n\nI don't think so, gonna resend later.\n\n> The logic of the patch itself looks sane to me.\n\nNice.\n\nBest Wishes,\n\nFabian\n"}]}