{"thread":{"id":"25575","subject":"Restart submodule update --recursive","startedAt":"2010-10-28T07:25:34Z","lastAt":"2010-11-02T11:08:53Z","messageCount":11,"participants":["Lukasz Palczewski","Johan Herland","Jonathan Nieder","Jens Lehmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"154615","messageId":"loom.20101028T090353-376@post.gmane.org","threadId":"25575","inReplyTo":null,"subject":"Restart submodule update --recursive","fromName":"Lukasz Palczewski","fromEmail":"l.palczewski@prevac.pl","sentAt":"2010-10-28T07:25:34Z","receivedAt":"2010-10-28T07:25:34Z","isPatch":false,"sender":{"key":"l.palczewski@prevac.pl","avatar":null},"body":"Hi.\nI have a problem with the time and the stoping of the submodule update command\nwhen the error occures.\nIn our project we have lots of submodules with submodules in them. So I use git\ncommand: git submodule update --recursive, to update all the submodules, but it\ntake some time to do it. I have to do it quite often becouse I'm a tester of the\nsoftware and I usually don't know which submodule I need to update, to have the\nnewest version. If I have some local changes in some submodule, the command\nstops and I have to revert the changes and start the submodule update from the\nbegining again. \nIs there a way to start the submodule update from the place, where the error\noccured and the command stop? Something like:\ngit submodule update --recursive --restart_form_last_error\nIf there isn't, can You add this feature?\n"},{"id":"154622","messageId":"201010281235.14313.johan@herland.net","threadId":"25575","inReplyTo":"loom.20101028T090353-376@post.gmane.org","subject":"Re: Restart submodule update --recursive","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2010-10-28T10:35:14Z","receivedAt":"2010-10-28T10:35:14Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Thursday 28 October 2010, Lukasz Palczewski wrote:\n> Hi.\n> I have a problem with the time and the stoping of the submodule\n> update command when the error occures.\n> In our project we have lots of submodules with submodules in them. So\n> I use git command: git submodule update --recursive, to update all\n> the submodules, but it take some time to do it. I have to do it quite\n> often becouse I'm a tester of the software and I usually don't know\n> which submodule I need to update, to have the newest version. If I\n> have some local changes in some submodule, the command stops and I\n> have to revert the changes and start the submodule update from the\n> begining again.\n> Is there a way to start the submodule update from the place, where\n> the error occured and the command stop? Something like:\n> git submodule update --recursive --restart_form_last_error\n\nNo, but you can use 'git submodule foreach --recursive \"$SCRIPT\"', where \n$SCRIPT is a command (or list of commands) for updating your current \nsubmodule. As long as the SCRIPT returns successfully (exit value 0), \nthe submodule foreach will keep going into each submodule. You can the \nlook at the output from your script to deduce which submodules need to \nbe updated manually. Or you may even be able to solve your problem \nautomatically.\n\nYou could for example try something like (all on one line):\n\ngit submodule foreach --recursive \"git fetch && git stash && git \ncheckout $sha1 && git stash pop; true\"\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"154644","messageId":"20101028181515.GB14212@burratino","threadId":"25575","inReplyTo":"loom.20101028T090353-376@post.gmane.org","subject":"Re: Restart submodule update --recursive","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-28T18:15:15Z","receivedAt":"2010-10-28T18:15:15Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(+cc: Jens of submodule-usability-enhancements fame)\n\nHi Lukasz,\n\nLukasz Palczewski wrote:\n\n>                                                                       I use git\n> command: git submodule update --recursive\n[...]\n>                 If I have some local changes in some submodule, the command\n> stops and I have to revert the changes and start the submodule update from the\n> begining again.\n> Is there a way to start the submodule update from the place, where the error\n> occured and the command stop? Something like:\n> git submodule update --recursive --restart_form_last_error\n\nHow many submodules are involved here?  I suspect there is some\noptimization possible: if a submodule was already updated, there\nshould not be much to do on the second pass, right?  What aspect of\nthe update seems to take the most time (as witnessed by pstree -a, for\nexample)?  Maybe what would be most useful is a hypothetical\n\n\tgit submodule update --fetch-only\n\t(or git fetch --recursive)\n\nfollowed by\n\n\tgit submodule update --no-fetch\n\t(or git checkout --recursive)\n\n?\n\nBut if there are many, many submodules, it could be better to script\na --save-progress and --resume along the lines you described.\n\nTwo possible approaches:\n\n - Make a new script using \"git submodule foreach --recursive\" that\n   steps through the list by hand, or\n\n - Take cmd_update from git-submodule.sh in the git sources and modify\n   to taste.\n\nIf you follow either of those approaches, please keep up posted.  Such\nscripts are inspiring and can be useful to others, too.\n\nThanks for an interesting example,\nJonathan\n"},{"id":"154762","messageId":"loom.20101029T085153-262@post.gmane.org","threadId":"25575","inReplyTo":"20101028181515.GB14212@burratino","subject":"Re: Restart submodule update --recursive","fromName":"Lukasz Palczewski","fromEmail":"l.palczewski@prevac.pl","sentAt":"2010-10-29T07:17:03Z","receivedAt":"2010-10-29T07:17:03Z","isPatch":false,"sender":{"key":"l.palczewski@prevac.pl","avatar":null},"body":"Hi Jonathan,\n\nJonathan Nieder writes:\n\n> [...]\n> But if there are many, many submodules, it could be better to script\n> a --save-progress and --resume along the lines you described.\n> \n> Two possible approaches:\n> \n>  - Make a new script using \"git submodule foreach --recursive\" that\n>    steps through the list by hand, or\n> \n>  - Take cmd_update from git-submodule.sh in the git sources and modify\n>    to taste.\n> [...]\n\nI think modyfying the git-submodule.sh will be better for me. So I looked into\nit and first problem araised: \nHow do I get a name of submodule with a name of a previous submodule?\nMaybe I will start with how my repository looks like:\n\nMain\n |\n --> sub1\n |     |\n |     --> nsub1\n |     |\n |     --> nsub2\n |     |\n |     --> nsub3\n |     |\n |     --> etc.     \n |\n --> sub2\n |     |\n |     --> nsub2 (no nsub1)\n |     |\n |     --> nsub3\n |     |\n |     --> nsub4\n |\n --> sub3\n |     |\n |     --> nsub1\n |     |\n |     --> nsub3 (no nsub2)\n |     |\n |     --> nsub4\n |\n etc.\n\nIt would be nice if I could get name like this sub1/nsub1 when I am in submodule\nsub1. Right now, I can get submodule name: nsub1. I tried to find some commands\nto get something like this, but could not find it.\n\nIf I can get that, I will be in home. Do You know how to do it?\nBTW. thanks for previous suggestion.\n\nLukasz Palczewski\n"},{"id":"154763","messageId":"loom.20101029T091828-728@post.gmane.org","threadId":"25575","inReplyTo":"201010281235.14313.johan@herland.net","subject":"Re: Restart submodule update --recursive","fromName":"Lukasz Palczewski","fromEmail":"l.palczewski@prevac.pl","sentAt":"2010-10-29T07:28:16Z","receivedAt":"2010-10-29T07:28:16Z","isPatch":false,"sender":{"key":"l.palczewski@prevac.pl","avatar":null},"body":"Hi Johan,\n\nJohan Herland writes:\n\n> [...]\n> You could for example try something like (all on one line):\n> \n> git submodule foreach --recursive \"git fetch && git stash && git \n> checkout $sha1 && git stash pop; true\"\n> \n> ...Johan\n> \n\nThanks for the suggestion. Using s script in a command good idea, but it will\nwork only for the local changes (I think), so I am continuing with a second\nsuggestion from Jonathan. If it works, it would not matter what error arises.\n\nLukasz Palczewski\n"},{"id":"154774","messageId":"20101029091202.GA26442@burratino","threadId":"25575","inReplyTo":"loom.20101029T085153-262@post.gmane.org","subject":"Re: Restart submodule update --recursive","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-29T09:12:02Z","receivedAt":"2010-10-29T09:12:02Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Lukasz,\n\n[side note: if you use a newsreader, please reply by mail instead of\nthrough gmane so the Cc: list can be preserved.]\n\nLukasz Palczewski wrote:\n\n> I think modyfying the git-submodule.sh will be better for me. So I looked into\n> it and first problem araised: \n> How do I get a name of submodule with a name of a previous submodule?\n[...]\n> It would be nice if I could get name like this sub1/nsub1 when I am in submodule\n> sub1.\n\nWhat path do you want to get when there are three levels of submodules?\n\nTo understand how git-submodule works, it helps to see how low-level it\nis.  The core is this function:\n\n #\n # Get submodule info for registered submodules\n # $@ = path to limit submodule list\n #\n module_list ()\n {\n\tgit ls-files --error-unmatch --stage -- \"$@\" | grep '^160000 '\n }\n\nwhich is just reading submodule entries from the index in the current\nrepository.  Like all index entries, they are attached to paths relative to\nthe toplevel of the current repository.\n\nTo get a path relative to the toplevel of the superproject using module_list,\nyou need to build it up as you go along.  For example,\n\n\tgit submodule foreach --recursive 'echo $prefix'\n\ndoes this (see cmd_foreach).\n---\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 1ed331c..e9bdbca 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -145,17 +145,21 @@ summary::\n \n foreach::\n \tEvaluates an arbitrary shell command in each checked out submodule.\n-\tThe command has access to the variables $name, $path, $sha1 and\n-\t$toplevel:\n+\tThe command has access to the variables $name, $path, $prefix, $sha1,\n+\tand $toplevel:\n \t$name is the name of the relevant submodule section in .gitmodules,\n \t$path is the name of the submodule directory relative to the\n \tsuperproject, $sha1 is the commit as recorded in the superproject,\n-\tand $toplevel is the absolute path to the top-level of the superproject.\n+\t$toplevel is the absolute path to the top-level of the superproject,\n+\tand $toplevel/${prefix}$path is the absolute path for any file\n+\tin the submodule worktree.\n \tAny submodules defined in the superproject but not checked out are\n \tignored by this command. Unless given --quiet, foreach prints the name\n \tof each submodule before evaluating the command.\n \tIf --recursive is given, submodules are traversed recursively (i.e.\n-\tthe given shell command is evaluated in nested submodules as well).\n+\tthe given shell command is evaluated in nested submodules as well)\n+\tand the superproject used to define $toplevel and $prefix is the\n+\toutermost project.\n \tA non-zero return from the command in any submodule causes\n \tthe processing to terminate. This can be overridden by adding '|| :'\n \tto the end of the command.\n-- \n"},{"id":"154780","messageId":"4CCAB20A.1000408@prevac.pl","threadId":"25575","inReplyTo":"20101029091202.GA26442@burratino","subject":"Re: Restart submodule update --recursive","fromName":"Lukasz Palczewski","fromEmail":"l.palczewski@prevac.pl","sentAt":"2010-10-29T11:37:46Z","receivedAt":"2010-10-29T11:37:46Z","isPatch":false,"sender":{"key":"l.palczewski@prevac.pl","avatar":null},"body":"Jonathan Nieder wrote:\n> Hi Lukasz,\n>\n> [side note: if you use a newsreader, please reply by mail instead of\n> through gmane so the Cc: list can be preserved.]\nSorry, but I do not use it. I will send You a normal email.\n\nI have added two options to git submodule update:\n--save-progress\n--resume-update\nFirst one You can use, to save the ./.git/SubmoduleUpdateLog.log the \nprogress of updating:\ngit submodule update --recursive --save-progress\nThe second one is used for skipping updated submodules:\ngit submodule update --recursive --resume-update\n\nThe downside of it is, that u can use only one --resume-update. If there \nwill be another error, then using it again will start form the last \nsubmodule that --save-progres saved.\n\nI have send two files:\n\"git-submodule\" - it has my changes\n\"git-submodule - Original\" - it not modyfied\nso that You can see what lines I have added.\n\nLet me know if this change will be in next version of git.\n\nBest regards,\nLukasz Palczewski\n\n\n#!/bin/sh\n#\n# git-submodules.sh: add, init, update or list git submodules\n#\n# Copyright (c) 2007 Lars Hjemli\n\ndashless=$(basename \"$0\" | sed -e 's/-/ /')\nUSAGE=\"[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <repository> [<path>]\n   or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]\n   or: $dashless [--quiet] init [--] [<path>...]\n   or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]\n   or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n   or: $dashless [--quiet] foreach [--recursive] <command>\n   or: $dashless [--quiet] sync [--] [<path>...]\"\nOPTIONS_SPEC=\n. git-sh-setup\n. git-parse-remote\nrequire_work_tree\n\ncommand=\nbranch=\nforce=\nreference=\ncached=\nrecursive=\ninit=\nfiles=\nnofetch=\nupdate=\nprefix=\n\n# Resolve relative url by appending to parent's url\nresolve_relative_url ()\n{\n\tremote=$(get_default_remote)\n\tremoteurl=$(git config \"remote.$remote.url\") ||\n\t\tdie \"remote ($remote) does not have a url defined in .git/config\"\n\turl=\"$1\"\n\tremoteurl=${remoteurl%/}\n\twhile test -n \"$url\"\n\tdo\n\t\tcase \"$url\" in\n\t\t../*)\n\t\t\turl=\"${url#../}\"\n\t\t\tremoteurl=\"${remoteurl%/*}\"\n\t\t\t;;\n\t\t./*)\n\t\t\turl=\"${url#./}\"\n\t\t\t;;\n\t\t*)\n\t\t\tbreak;;\n\t\tesac\n\tdone\n\techo \"$remoteurl/${url%/}\"\n}\n\n#\n# Get submodule info for registered submodules\n# $@ = path to limit submodule list\n#\nmodule_list()\n{\n\tgit ls-files --error-unmatch --stage -- \"$@\" | sane_grep '^160000 '\n}\n\n#\n# Map submodule path to submodule name\n#\n# $1 = path\n#\nmodule_name()\n{\n\t# Do we have \"submodule.<something>.path = $1\" defined in .gitmodules file?\n\tre=$(printf '%s\\n' \"$1\" | sed -e 's/[].[^$\\\\*]/\\\\&/g')\n\tname=$( git config -f .gitmodules --get-regexp '^submodule\\..*\\.path$' |\n\t\tsed -n -e 's|^submodule\\.\\(.*\\)\\.path '\"$re\"'$|\\1|p' )\n       test -z \"$name\" &&\n       die \"No submodule mapping found in .gitmodules for path '$path'\"\n       echo \"$name\"\n}\n\n#\n# Clone a submodule\n#\n# Prior to calling, cmd_update checks that a possibly existing\n# path is not a git repository.\n# Likewise, cmd_add checks that path does not exist at all,\n# since it is the location of a new submodule.\n#\nmodule_clone()\n{\n\tpath=$1\n\turl=$2\n\treference=\"$3\"\n\n\t# If there already is a directory at the submodule path,\n\t# expect it to be empty (since that is the default checkout\n\t# action) and try to remove it.\n\t# Note: if $path is a symlink to a directory the test will\n\t# succeed but the rmdir will fail. We might want to fix this.\n\tif test -d \"$path\"\n\tthen\n\t\trmdir \"$path\" 2>/dev/null ||\n\t\tdie \"Directory '$path' exists, but is neither empty nor a git repository\"\n\tfi\n\n\ttest -e \"$path\" &&\n\tdie \"A file already exist at path '$path'\"\n\n\tif test -n \"$reference\"\n\tthen\n\t\tgit-clone \"$reference\" -n \"$url\" \"$path\"\n\telse\n\t\tgit-clone -n \"$url\" \"$path\"\n\tfi ||\n\tdie \"Clone of '$url' into submodule path '$path' failed\"\n}\n\n#\n# Add a new submodule to the working tree, .gitmodules and the index\n#\n# $@ = repo path\n#\n# optional branch is stored in global branch variable\n#\ncmd_add()\n{\n\t# parse $args after \"submodule ... add\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-b | --branch)\n\t\t\tcase \"$2\" in '') usage ;; esac\n\t\t\tbranch=$2\n\t\t\tshift\n\t\t\t;;\n\t\t-f | --force)\n\t\t\tforce=$1\n\t\t\t;;\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--reference)\n\t\t\tcase \"$2\" in '') usage ;; esac\n\t\t\treference=\"--reference=$2\"\n\t\t\tshift\n\t\t\t;;\n\t\t--reference=*)\n\t\t\treference=\"$1\"\n\t\t\tshift\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\trepo=$1\n\tpath=$2\n\n\tif test -z \"$path\"; then\n\t\tpath=$(echo \"$repo\" |\n\t\t\tsed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n\tfi\n\n\tif test -z \"$repo\" -o -z \"$path\"; then\n\t\tusage\n\tfi\n\n\t# assure repo is absolute or relative to parent\n\tcase \"$repo\" in\n\t./*|../*)\n\t\t# dereference source url relative to parent's url\n\t\trealrepo=$(resolve_relative_url \"$repo\") || exit\n\t\t;;\n\t*:*|/*)\n\t\t# absolute url\n\t\trealrepo=$repo\n\t\t;;\n\t*)\n\t\tdie \"repo URL: '$repo' must be absolute or begin with ./|../\"\n\t;;\n\tesac\n\n\t# normalize path:\n\t# multiple //; leading ./; /./; /../; trailing /\n\tpath=$(printf '%s/\\n' \"$path\" |\n\t\tsed -e '\n\t\t\ts|//*|/|g\n\t\t\ts|^\\(\\./\\)*||\n\t\t\ts|/\\./|/|g\n\t\t\t:start\n\t\t\ts|\\([^/]*\\)/\\.\\./||\n\t\t\ttstart\n\t\t\ts|/*$||\n\t\t')\n\tgit ls-files --error-unmatch \"$path\" > /dev/null 2>&1 &&\n\tdie \"'$path' already exists in the index\"\n\n\tif test -z \"$force\" && ! git add --dry-run --ignore-missing \"$path\" > /dev/null 2>&1\n\tthen\n\t\techo >&2 \"The following path is ignored by one of your .gitignore files:\" &&\n\t\techo >&2 $path &&\n\t\techo >&2 \"Use -f if you really want to add it.\"\n\t\texit 1\n\tfi\n\n\t# perhaps the path exists and is already a git repo, else clone it\n\tif test -e \"$path\"\n\tthen\n\t\tif test -d \"$path\"/.git -o -f \"$path\"/.git\n\t\tthen\n\t\t\techo \"Adding existing repo at '$path' to the index\"\n\t\telse\n\t\t\tdie \"'$path' already exists and is not a valid git repo\"\n\t\tfi\n\n\t\tcase \"$repo\" in\n\t\t./*|../*)\n\t\t\turl=$(resolve_relative_url \"$repo\") || exit\n\t\t    ;;\n\t\t*)\n\t\t\turl=\"$repo\"\n\t\t\t;;\n\t\tesac\n\t\tgit config submodule.\"$path\".url \"$url\"\n\telse\n\n\t\tmodule_clone \"$path\" \"$realrepo\" \"$reference\" || exit\n\t\t(\n\t\t\tclear_local_git_env\n\t\t\tcd \"$path\" &&\n\t\t\t# ash fails to wordsplit ${branch:+-b \"$branch\"...}\n\t\t\tcase \"$branch\" in\n\t\t\t'') git checkout -f -q ;;\n\t\t\t?*) git checkout -f -q -b \"$branch\" \"origin/$branch\" ;;\n\t\t\tesac\n\t\t) || die \"Unable to checkout submodule '$path'\"\n\tfi\n\n\tgit add $force \"$path\" ||\n\tdie \"Failed to add submodule '$path'\"\n\n\tgit config -f .gitmodules submodule.\"$path\".path \"$path\" &&\n\tgit config -f .gitmodules submodule.\"$path\".url \"$repo\" &&\n\tgit add --force .gitmodules ||\n\tdie \"Failed to register submodule '$path'\"\n}\n\n#\n# Execute an arbitrary command sequence in each checked out\n# submodule\n#\n# $@ = command to execute\n#\ncmd_foreach()\n{\n\t# parse $args after \"submodule ... foreach\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--recursive)\n\t\t\trecursive=1\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\ttoplevel=$(pwd)\n\n\tmodule_list |\n\twhile read mode sha1 stage path\n\tdo\n\t\tif test -e \"$path\"/.git\n\t\tthen\n\t\t\tsay \"Entering '$prefix$path'\"\n\t\t\tname=$(module_name \"$path\")\n\t\t\t(\n\t\t\t\tprefix=\"$prefix$path/\"\n\t\t\t\tclear_local_git_env\n\t\t\t\tcd \"$path\" &&\n\t\t\t\teval \"$@\" &&\n\t\t\t\tif test -n \"$recursive\"\n\t\t\t\tthen\n\t\t\t\t\tcmd_foreach \"--recursive\" \"$@\"\n\t\t\t\tfi\n\t\t\t) ||\n\t\t\tdie \"Stopping at '$path'; script returned non-zero status.\"\n\t\tfi\n\tdone\n}\n\n#\n# Register submodules in .git/config\n#\n# $@ = requested paths (default to all)\n#\ncmd_init()\n{\n\t# parse $args after \"submodule ... init\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\n\t\t# Skip already registered paths\n\t\tname=$(module_name \"$path\") || exit\n\t\turl=$(git config submodule.\"$name\".url)\n\t\ttest -z \"$url\" || continue\n\n\t\turl=$(git config -f .gitmodules submodule.\"$name\".url)\n\t\ttest -z \"$url\" &&\n\t\tdie \"No url found for submodule path '$path' in .gitmodules\"\n\n\t\t# Possibly a url relative to parent\n\t\tcase \"$url\" in\n\t\t./*|../*)\n\t\t\turl=$(resolve_relative_url \"$url\") || exit\n\t\t\t;;\n\t\tesac\n\n\t\tgit config submodule.\"$name\".url \"$url\" ||\n\t\tdie \"Failed to register url for submodule path '$path'\"\n\n\t\tupd=\"$(git config -f .gitmodules submodule.\"$name\".update)\"\n\t\ttest -z \"$upd\" ||\n\t\tgit config submodule.\"$name\".update \"$upd\" ||\n\t\tdie \"Failed to register update mode for submodule path '$path'\"\n\n\t\tsay \"Submodule '$name' ($url) registered for path '$path'\"\n\tdone\n}\n\n#\n# Update each submodule path to correct revision, using clone and checkout as needed\n#\n# $@ = requested paths (default to all)\n#\ncmd_update()\n{\n\t# parse $args after \"submodule ... update\".\n\torig_args=\"$@\"\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tshift\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t-i|--init)\n\t\t\tinit=1\n\t\t\tshift\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-r|--rebase)\n\t\t\tshift\n\t\t\tupdate=\"rebase\"\n\t\t\t;;\n\t\t--reference)\n\t\t\tcase \"$2\" in '') usage ;; esac\n\t\t\treference=\"--reference=$2\"\n\t\t\tshift 2\n\t\t\t;;\n\t\t--reference=*)\n\t\t\treference=\"$1\"\n\t\t\tshift\n\t\t\t;;\n\t\t-m|--merge)\n\t\t\tshift\n\t\t\tupdate=\"merge\"\n\t\t\t;;\n\t\t--recursive)\n\t\t\tshift\n\t\t\trecursive=1\n\t\t\t;;\n\t\t--save-progress)\n\t\t\tshift\n\t\t\tsave_progress=1\n\t\t\tif test -e ./.git/SubmoduleUpdateLog.log\n\t\t\tthen\n\t\t\t\trm ./.git/SubmoduleUpdateLog.log\n\t\t\tfi\n\t\t\t;;\t\n\t\t--resume-update)\n\t\t\tshift\n\t\t\tsubmodule_resume=1\n\t\t\t;;\t\t\t\t\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\tdone\n\n\tif test -n \"$init\"\n\tthen\n\t\tcmd_init \"--\" \"$@\" || return\n\tfi\n\t\t\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\t\t\n\t\tname=$(module_name \"$path\") || exit\n\t\turl=$(git config submodule.\"$name\".url)\n\t\tupdate_module=$(git config submodule.\"$name\".update)\n\t\t\n\t\tif test -n \"$submodule_resume\"\n\t\tthen\n\t\t\tSubmodulePathResume=`pwd`\n\t\t\tSubmodulePathResume=$SubmodulePathResume/\"$name\"\n\t\t\t\n\t\t\t#say $SubmodulePathResume\n\t\t\tif test -e ./.git/SubmoduleUpdateLog.log\n\t\t\tthen\n\t\t\t\tAFile=`cat \"./.git/SubmoduleUpdateLog.log\" | grep \"$SubmodulePathResume\"`\n\t\t\t\t\n\t\t\t\t#say $AFile;\t\t\t\n\t\t\t\tif test -n \"$AFile\"\n\t\t\t\tthen\n\t\t\t\t\tsay \"Skip module '$SubmodulePathResume'\"\n\t\t\t\t\tCancelRecursive=1\n\t\t\t\telse\n\t\t\t\t\t#say \"Checking\"\n\t\t\t\t\t#say \"$SubmodulePathResume\"\n\t\t\t\t\tCancelRecursive=\"\"\n\t\t\t\tfi\t\t\t\n\t\t\tfi\n\t\tfi\n\t\t\n\t\tif test -z \"$url\"\n\t\tthen\n\t\t\t# Only mention uninitialized submodules when its\n\t\t\t# path have been specified\n\t\t\ttest \"$#\" != \"0\" &&\n\t\t\tsay \"Submodule path '$path' not initialized\" &&\n\t\t\tsay \"Maybe you want to use 'update --init'?\"\n\t\t\tcontinue\n\t\tfi\n\n\t\tif ! test -d \"$path\"/.git -o -f \"$path\"/.git\n\t\tthen\n\t\t\tmodule_clone \"$path\" \"$url\" \"$reference\"|| exit\n\t\t\tsubsha1=\n\t\telse\n\t\t\tsubsha1=$(clear_local_git_env; cd \"$path\" &&\n\t\t\t\tgit rev-parse --verify HEAD) ||\n\t\t\tdie \"Unable to find current revision in submodule path '$path'\"\n\t\tfi\n\n\t\tif ! test -z \"$update\"\n\t\tthen\n\t\t\tupdate_module=$update\n\t\tfi\n\n\t\tif test \"$subsha1\" != \"$sha1\"\n\t\tthen\n\t\t\tforce=\n\t\t\tif test -z \"$subsha1\"\n\t\t\tthen\n\t\t\t\tforce=\"-f\"\n\t\t\tfi\n\n\t\t\tif test -z \"$nofetch\"\n\t\t\tthen\n\t\t\t\t(clear_local_git_env; 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\t\t\t\n\t\t\tcase \"$update_module\" in\n\t\t\trebase)\n\t\t\t\tcommand=\"git rebase\"\n\t\t\t\taction=\"rebase\"\n\t\t\t\tmsg=\"rebased onto\"\n\t\t\t\t;;\n\t\t\tmerge)\n\t\t\t\tcommand=\"git merge\"\n\t\t\t\taction=\"merge\"\n\t\t\t\tmsg=\"merged in\"\n\t\t\t\t;;\n\t\t\t*)\n\t\t\t\tcommand=\"git checkout $force -q\"\n\t\t\t\taction=\"checkout\"\n\t\t\t\tmsg=\"checked out\"\n\t\t\t\t;;\n\t\t\tesac\n\n\t\t\t(clear_local_git_env; cd \"$path\" && $command \"$sha1\") ||\n\t\t\tdie \"Unable to $action '$sha1' in submodule path '$path'\"\n\t\t\tsay \"Submodule path '$path': $msg '$sha1'\"\n\t\tfi\n\t\n\t\tif test -n \"$recursive\"\n\t\tthen\n\t\t\tif test -z \"$CancelRecursive\"\n\t\t\tthen\n\t\t\t\t(clear_local_git_env; cd \"$path\" && cmd_update $orig_args) ||\n\t\t\t\tdie \"Failed to recurse into submodule path '$path'\"\n\t\t\tfi\n\t\tfi\n\t\t\n\t\tif test -n \"$save_progress\"\n\t\tthen\n\t\t\t\tSubmodulePath=`pwd`\n\t\t\t\tSubmodulePath=$SubmodulePath/\"$name\"\n\t\t\t\t\n\t\t\t\t#say \"'$SubmodulePath'\"\n\t\t\t\techo \"'$SubmodulePath'\" >> ./.git/SubmoduleUpdateLog.log\n\t\tfi\n\tdone\n}\n\nset_name_rev () {\n\trevname=$( (\n\t\tclear_local_git_env\n\t\tcd \"$1\" && {\n\t\t\tgit describe \"$2\" 2>/dev/null ||\n\t\t\tgit describe --tags \"$2\" 2>/dev/null ||\n\t\t\tgit describe --contains \"$2\" 2>/dev/null ||\n\t\t\tgit describe --all --always \"$2\"\n\t\t}\n\t) )\n\ttest -z \"$revname\" || revname=\" ($revname)\"\n}\n#\n# Show commit summary for submodules in index or working tree\n#\n# If '--cached' is given, show summary between index and given commit,\n# or between working tree and given commit\n#\n# $@ = [commit (default 'HEAD'),] requested paths (default all)\n#\ncmd_summary() {\n\tsummary_limit=-1\n\tfor_status=\n\tdiff_cmd=diff-index\n\n\t# parse $args after \"submodule ... summary\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t--cached)\n\t\t\tcached=\"$1\"\n\t\t\t;;\n\t\t--files)\n\t\t\tfiles=\"$1\"\n\t\t\t;;\n\t\t--for-status)\n\t\t\tfor_status=\"$1\"\n\t\t\t;;\n\t\t-n|--summary-limit)\n\t\t\tif summary_limit=$(($2 + 0)) 2>/dev/null && test \"$summary_limit\" = \"$2\"\n\t\t\tthen\n\t\t\t\t:\n\t\t\telse\n\t\t\t\tusage\n\t\t\tfi\n\t\t\tshift\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\ttest $summary_limit = 0 && return\n\n\tif rev=$(git rev-parse -q --verify --default HEAD ${1+\"$1\"})\n\tthen\n\t\thead=$rev\n\t\ttest $# = 0 || shift\n\telif test -z \"$1\" -o \"$1\" = \"HEAD\"\n\tthen\n\t\t# before the first commit: compare with an empty tree\n\t\thead=$(git hash-object -w -t tree --stdin </dev/null)\n\t\ttest -z \"$1\" || shift\n\telse\n\t\thead=\"HEAD\"\n\tfi\n\n\tif [ -n \"$files\" ]\n\tthen\n\t\ttest -n \"$cached\" &&\n\t\tdie \"--cached cannot be used with --files\"\n\t\tdiff_cmd=diff-files\n\t\thead=\n\tfi\n\n\tcd_to_toplevel\n\t# Get modified modules cared by user\n\tmodules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- \"$@\" |\n\t\tsane_egrep '^:([0-7]* )?160000' |\n\t\twhile read mod_src mod_dst sha1_src sha1_dst status name\n\t\tdo\n\t\t\t# Always show modules deleted or type-changed (blob<->module)\n\t\t\ttest $status = D -o $status = T && echo \"$name\" && continue\n\t\t\t# Also show added or modified modules which are checked out\n\t\t\tGIT_DIR=\"$name/.git\" git-rev-parse --git-dir >/dev/null 2>&1 &&\n\t\t\techo \"$name\"\n\t\tdone\n\t)\n\n\ttest -z \"$modules\" && return\n\n\tgit $diff_cmd $cached --ignore-submodules=dirty --raw $head -- $modules |\n\tsane_egrep '^:([0-7]* )?160000' |\n\tcut -c2- |\n\twhile read mod_src mod_dst sha1_src sha1_dst status name\n\tdo\n\t\tif test -z \"$cached\" &&\n\t\t\ttest $sha1_dst = 0000000000000000000000000000000000000000\n\t\tthen\n\t\t\tcase \"$mod_dst\" in\n\t\t\t160000)\n\t\t\t\tsha1_dst=$(GIT_DIR=\"$name/.git\" git rev-parse HEAD)\n\t\t\t\t;;\n\t\t\t100644 | 100755 | 120000)\n\t\t\t\tsha1_dst=$(git hash-object $name)\n\t\t\t\t;;\n\t\t\t000000)\n\t\t\t\t;; # removed\n\t\t\t*)\n\t\t\t\t# unexpected type\n\t\t\t\techo >&2 \"unexpected mode $mod_dst\"\n\t\t\t\tcontinue ;;\n\t\t\tesac\n\t\tfi\n\t\tmissing_src=\n\t\tmissing_dst=\n\n\t\ttest $mod_src = 160000 &&\n\t\t! GIT_DIR=\"$name/.git\" git-rev-parse -q --verify $sha1_src^0 >/dev/null &&\n\t\tmissing_src=t\n\n\t\ttest $mod_dst = 160000 &&\n\t\t! GIT_DIR=\"$name/.git\" git-rev-parse -q --verify $sha1_dst^0 >/dev/null &&\n\t\tmissing_dst=t\n\n\t\ttotal_commits=\n\t\tcase \"$missing_src,$missing_dst\" in\n\t\tt,)\n\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_src\"\n\t\t\t;;\n\t\t,t)\n\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_dst\"\n\t\t\t;;\n\t\tt,t)\n\t\t\terrmsg=\"  Warn: $name doesn't contain commits $sha1_src and $sha1_dst\"\n\t\t\t;;\n\t\t*)\n\t\t\terrmsg=\n\t\t\ttotal_commits=$(\n\t\t\tif test $mod_src = 160000 -a $mod_dst = 160000\n\t\t\tthen\n\t\t\t\trange=\"$sha1_src...$sha1_dst\"\n\t\t\telif test $mod_src = 160000\n\t\t\tthen\n\t\t\t\trange=$sha1_src\n\t\t\telse\n\t\t\t\trange=$sha1_dst\n\t\t\tfi\n\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\tgit rev-list --first-parent $range -- | wc -l\n\t\t\t)\n\t\t\ttotal_commits=\" ($(($total_commits + 0)))\"\n\t\t\t;;\n\t\tesac\n\n\t\tsha1_abbr_src=$(echo $sha1_src | cut -c1-7)\n\t\tsha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)\n\t\tif test $status = T\n\t\tthen\n\t\t\tif test $mod_dst = 160000\n\t\t\tthen\n\t\t\t\techo \"* $name $sha1_abbr_src(blob)->$sha1_abbr_dst(submodule)$total_commits:\"\n\t\t\telse\n\t\t\t\techo \"* $name $sha1_abbr_src(submodule)->$sha1_abbr_dst(blob)$total_commits:\"\n\t\t\tfi\n\t\telse\n\t\t\techo \"* $name $sha1_abbr_src...$sha1_abbr_dst$total_commits:\"\n\t\tfi\n\t\tif test -n \"$errmsg\"\n\t\tthen\n\t\t\t# Don't give error msg for modification whose dst is not submodule\n\t\t\t# i.e. deleted or changed to blob\n\t\t\ttest $mod_dst = 160000 && echo \"$errmsg\"\n\t\telse\n\t\t\tif test $mod_src = 160000 -a $mod_dst = 160000\n\t\t\tthen\n\t\t\t\tlimit=\n\t\t\t\ttest $summary_limit -gt 0 && limit=\"-$summary_limit\"\n\t\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\t\tgit log $limit --pretty='format:  %m %s' \\\n\t\t\t\t--first-parent $sha1_src...$sha1_dst\n\t\t\telif test $mod_dst = 160000\n\t\t\tthen\n\t\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\t\tgit log --pretty='format:  > %s' -1 $sha1_dst\n\t\t\telse\n\t\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\t\tgit log --pretty='format:  < %s' -1 $sha1_src\n\t\t\tfi\n\t\t\techo\n\t\tfi\n\t\techo\n\tdone |\n\tif test -n \"$for_status\"; then\n\t\tif [ -n \"$files\" ]; then\n\t\t\techo \"# Submodules changed but not updated:\"\n\t\telse\n\t\t\techo \"# Submodule changes to be committed:\"\n\t\tfi\n\t\techo \"#\"\n\t\tsed -e 's|^|# |' -e 's|^# $|#|'\n\telse\n\t\tcat\n\tfi\n}\n#\n# List all submodules, prefixed with:\n#  - submodule not initialized\n#  + different revision checked out\n#\n# If --cached was specified the revision in the index will be printed\n# instead of the currently checked out revision.\n#\n# $@ = requested paths (default to all)\n#\ncmd_status()\n{\n\t# parse $args after \"submodule ... status\".\n\torig_args=\"$@\"\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--cached)\n\t\t\tcached=1\n\t\t\t;;\n\t\t--recursive)\n\t\t\trecursive=1\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\n\t\tname=$(module_name \"$path\") || exit\n\t\turl=$(git config submodule.\"$name\".url)\n\t\tdisplaypath=\"$prefix$path\"\n\t\tif test -z \"$url\" || ! test -d \"$path\"/.git -o -f \"$path\"/.git\n\t\tthen\n\t\t\tsay \"-$sha1 $displaypath\"\n\t\t\tcontinue;\n\t\tfi\n\t\tset_name_rev \"$path\" \"$sha1\"\n\t\tif git diff-files --ignore-submodules=dirty --quiet -- \"$path\"\n\t\tthen\n\t\t\tsay \" $sha1 $displaypath$revname\"\n\t\telse\n\t\t\tif test -z \"$cached\"\n\t\t\tthen\n\t\t\t\tsha1=$(clear_local_git_env; cd \"$path\" && git rev-parse --verify HEAD)\n\t\t\t\tset_name_rev \"$path\" \"$sha1\"\n\t\t\tfi\n\t\t\tsay \"+$sha1 $displaypath$revname\"\n\t\tfi\n\n\t\tif test -n \"$recursive\"\n\t\tthen\n\t\t\t(\n\t\t\t\tprefix=\"$displaypath/\"\n\t\t\t\tclear_local_git_env\n\t\t\t\tcd \"$path\" &&\n\t\t\t\tcmd_status $orig_args\n\t\t\t) ||\n\t\t\tdie \"Failed to recurse into submodule path '$path'\"\n\t\tfi\n\tdone\n}\n#\n# Sync remote urls for submodules\n# This makes the value for remote.$remote.url match the value\n# specified in .gitmodules.\n#\ncmd_sync()\n{\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\tshift\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\tdone\n\tcd_to_toplevel\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\n\t\tname=$(module_name \"$path\")\n\t\turl=$(git config -f .gitmodules --get submodule.\"$name\".url)\n\n\t\t# Possibly a url relative to parent\n\t\tcase \"$url\" in\n\t\t./*|../*)\n\t\t\turl=$(resolve_relative_url \"$url\") || exit\n\t\t\t;;\n\t\tesac\n\n\t\tif test -e \"$path\"/.git\n\t\tthen\n\t\t(\n\t\t\tsay \"Synchronizing submodule url for '$name'\"\n\t\t\tgit config submodule.\"$name\".url \"$url\"\n\t\t\tclear_local_git_env\n\t\t\tcd \"$path\"\n\t\t\tremote=$(get_default_remote)\n\t\t\tgit config remote.\"$remote\".url \"$url\"\n\t\t)\n\t\tfi\n\tdone\n}\n\n# This loop parses the command line arguments to find the\n# subcommand name to dispatch.  Parsing of the subcommand specific\n# options are primarily done by the subcommand implementations.\n# Subcommand specific options such as --branch and --cached are\n# parsed here as well, for backward compatibility.\n\nwhile test $# != 0 && test -z \"$command\"\ndo\n\tcase \"$1\" in\n\tadd | foreach | init | update | status | summary | sync)\n\t\tcommand=$1\n\t\t;;\n\t-q|--quiet)\n\t\tGIT_QUIET=1\n\t\t;;\n\t-b|--branch)\n\t\tcase \"$2\" in\n\t\t'')\n\t\t\tusage\n\t\t\t;;\n\t\tesac\n\t\tbranch=\"$2\"; shift\n\t\t;;\n\t--cached)\n\t\tcached=\"$1\"\n\t\t;;\n\t--)\n\t\tbreak\n\t\t;;\n\t-*)\n\t\tusage\n\t\t;;\n\t*)\n\t\tbreak\n\t\t;;\n\tesac\n\tshift\ndone\n\n# No command word defaults to \"status\"\ntest -n \"$command\" || command=status\n\n# \"-b branch\" is accepted only by \"add\"\nif test -n \"$branch\" && test \"$command\" != add\nthen\n\tusage\nfi\n\n# \"--cached\" is accepted only by \"status\" and \"summary\"\nif test -n \"$cached\" && test \"$command\" != status -a \"$command\" != summary\nthen\n\tusage\nfi\n\n\"cmd_$command\" \"$@\"\n\n\n#!/bin/sh\n#\n# git-submodules.sh: add, init, update or list git submodules\n#\n# Copyright (c) 2007 Lars Hjemli\n\ndashless=$(basename \"$0\" | sed -e 's/-/ /')\nUSAGE=\"[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <repository> [<path>]\n   or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]\n   or: $dashless [--quiet] init [--] [<path>...]\n   or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]\n   or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n   or: $dashless [--quiet] foreach [--recursive] <command>\n   or: $dashless [--quiet] sync [--] [<path>...]\"\nOPTIONS_SPEC=\n. git-sh-setup\n. git-parse-remote\nrequire_work_tree\n\ncommand=\nbranch=\nforce=\nreference=\ncached=\nrecursive=\ninit=\nfiles=\nnofetch=\nupdate=\nprefix=\n\n# Resolve relative url by appending to parent's url\nresolve_relative_url ()\n{\n\tremote=$(get_default_remote)\n\tremoteurl=$(git config \"remote.$remote.url\") ||\n\t\tdie \"remote ($remote) does not have a url defined in .git/config\"\n\turl=\"$1\"\n\tremoteurl=${remoteurl%/}\n\twhile test -n \"$url\"\n\tdo\n\t\tcase \"$url\" in\n\t\t../*)\n\t\t\turl=\"${url#../}\"\n\t\t\tremoteurl=\"${remoteurl%/*}\"\n\t\t\t;;\n\t\t./*)\n\t\t\turl=\"${url#./}\"\n\t\t\t;;\n\t\t*)\n\t\t\tbreak;;\n\t\tesac\n\tdone\n\techo \"$remoteurl/${url%/}\"\n}\n\n#\n# Get submodule info for registered submodules\n# $@ = path to limit submodule list\n#\nmodule_list()\n{\n\tgit ls-files --error-unmatch --stage -- \"$@\" | sane_grep '^160000 '\n}\n\n#\n# Map submodule path to submodule name\n#\n# $1 = path\n#\nmodule_name()\n{\n\t# Do we have \"submodule.<something>.path = $1\" defined in .gitmodules file?\n\tre=$(printf '%s\\n' \"$1\" | sed -e 's/[].[^$\\\\*]/\\\\&/g')\n\tname=$( git config -f .gitmodules --get-regexp '^submodule\\..*\\.path$' |\n\t\tsed -n -e 's|^submodule\\.\\(.*\\)\\.path '\"$re\"'$|\\1|p' )\n       test -z \"$name\" &&\n       die \"No submodule mapping found in .gitmodules for path '$path'\"\n       echo \"$name\"\n}\n\n#\n# Clone a submodule\n#\n# Prior to calling, cmd_update checks that a possibly existing\n# path is not a git repository.\n# Likewise, cmd_add checks that path does not exist at all,\n# since it is the location of a new submodule.\n#\nmodule_clone()\n{\n\tpath=$1\n\turl=$2\n\treference=\"$3\"\n\n\t# If there already is a directory at the submodule path,\n\t# expect it to be empty (since that is the default checkout\n\t# action) and try to remove it.\n\t# Note: if $path is a symlink to a directory the test will\n\t# succeed but the rmdir will fail. We might want to fix this.\n\tif test -d \"$path\"\n\tthen\n\t\trmdir \"$path\" 2>/dev/null ||\n\t\tdie \"Directory '$path' exists, but is neither empty nor a git repository\"\n\tfi\n\n\ttest -e \"$path\" &&\n\tdie \"A file already exist at path '$path'\"\n\n\tif test -n \"$reference\"\n\tthen\n\t\tgit-clone \"$reference\" -n \"$url\" \"$path\"\n\telse\n\t\tgit-clone -n \"$url\" \"$path\"\n\tfi ||\n\tdie \"Clone of '$url' into submodule path '$path' failed\"\n}\n\n#\n# Add a new submodule to the working tree, .gitmodules and the index\n#\n# $@ = repo path\n#\n# optional branch is stored in global branch variable\n#\ncmd_add()\n{\n\t# parse $args after \"submodule ... add\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-b | --branch)\n\t\t\tcase \"$2\" in '') usage ;; esac\n\t\t\tbranch=$2\n\t\t\tshift\n\t\t\t;;\n\t\t-f | --force)\n\t\t\tforce=$1\n\t\t\t;;\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--reference)\n\t\t\tcase \"$2\" in '') usage ;; esac\n\t\t\treference=\"--reference=$2\"\n\t\t\tshift\n\t\t\t;;\n\t\t--reference=*)\n\t\t\treference=\"$1\"\n\t\t\tshift\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\trepo=$1\n\tpath=$2\n\n\tif test -z \"$path\"; then\n\t\tpath=$(echo \"$repo\" |\n\t\t\tsed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\n\tfi\n\n\tif test -z \"$repo\" -o -z \"$path\"; then\n\t\tusage\n\tfi\n\n\t# assure repo is absolute or relative to parent\n\tcase \"$repo\" in\n\t./*|../*)\n\t\t# dereference source url relative to parent's url\n\t\trealrepo=$(resolve_relative_url \"$repo\") || exit\n\t\t;;\n\t*:*|/*)\n\t\t# absolute url\n\t\trealrepo=$repo\n\t\t;;\n\t*)\n\t\tdie \"repo URL: '$repo' must be absolute or begin with ./|../\"\n\t;;\n\tesac\n\n\t# normalize path:\n\t# multiple //; leading ./; /./; /../; trailing /\n\tpath=$(printf '%s/\\n' \"$path\" |\n\t\tsed -e '\n\t\t\ts|//*|/|g\n\t\t\ts|^\\(\\./\\)*||\n\t\t\ts|/\\./|/|g\n\t\t\t:start\n\t\t\ts|\\([^/]*\\)/\\.\\./||\n\t\t\ttstart\n\t\t\ts|/*$||\n\t\t')\n\tgit ls-files --error-unmatch \"$path\" > /dev/null 2>&1 &&\n\tdie \"'$path' already exists in the index\"\n\n\tif test -z \"$force\" && ! git add --dry-run --ignore-missing \"$path\" > /dev/null 2>&1\n\tthen\n\t\techo >&2 \"The following path is ignored by one of your .gitignore files:\" &&\n\t\techo >&2 $path &&\n\t\techo >&2 \"Use -f if you really want to add it.\"\n\t\texit 1\n\tfi\n\n\t# perhaps the path exists and is already a git repo, else clone it\n\tif test -e \"$path\"\n\tthen\n\t\tif test -d \"$path\"/.git -o -f \"$path\"/.git\n\t\tthen\n\t\t\techo \"Adding existing repo at '$path' to the index\"\n\t\telse\n\t\t\tdie \"'$path' already exists and is not a valid git repo\"\n\t\tfi\n\n\t\tcase \"$repo\" in\n\t\t./*|../*)\n\t\t\turl=$(resolve_relative_url \"$repo\") || exit\n\t\t    ;;\n\t\t*)\n\t\t\turl=\"$repo\"\n\t\t\t;;\n\t\tesac\n\t\tgit config submodule.\"$path\".url \"$url\"\n\telse\n\n\t\tmodule_clone \"$path\" \"$realrepo\" \"$reference\" || exit\n\t\t(\n\t\t\tclear_local_git_env\n\t\t\tcd \"$path\" &&\n\t\t\t# ash fails to wordsplit ${branch:+-b \"$branch\"...}\n\t\t\tcase \"$branch\" in\n\t\t\t'') git checkout -f -q ;;\n\t\t\t?*) git checkout -f -q -b \"$branch\" \"origin/$branch\" ;;\n\t\t\tesac\n\t\t) || die \"Unable to checkout submodule '$path'\"\n\tfi\n\n\tgit add $force \"$path\" ||\n\tdie \"Failed to add submodule '$path'\"\n\n\tgit config -f .gitmodules submodule.\"$path\".path \"$path\" &&\n\tgit config -f .gitmodules submodule.\"$path\".url \"$repo\" &&\n\tgit add --force .gitmodules ||\n\tdie \"Failed to register submodule '$path'\"\n}\n\n#\n# Execute an arbitrary command sequence in each checked out\n# submodule\n#\n# $@ = command to execute\n#\ncmd_foreach()\n{\n\t# parse $args after \"submodule ... foreach\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--recursive)\n\t\t\trecursive=1\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\ttoplevel=$(pwd)\n\n\tmodule_list |\n\twhile read mode sha1 stage path\n\tdo\n\t\tif test -e \"$path\"/.git\n\t\tthen\n\t\t\tsay \"Entering '$prefix$path'\"\n\t\t\tname=$(module_name \"$path\")\n\t\t\t(\n\t\t\t\tprefix=\"$prefix$path/\"\n\t\t\t\tclear_local_git_env\n\t\t\t\tcd \"$path\" &&\n\t\t\t\teval \"$@\" &&\n\t\t\t\tif test -n \"$recursive\"\n\t\t\t\tthen\n\t\t\t\t\tcmd_foreach \"--recursive\" \"$@\"\n\t\t\t\tfi\n\t\t\t) ||\n\t\t\tdie \"Stopping at '$path'; script returned non-zero status.\"\n\t\tfi\n\tdone\n}\n\n#\n# Register submodules in .git/config\n#\n# $@ = requested paths (default to all)\n#\ncmd_init()\n{\n\t# parse $args after \"submodule ... init\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\n\t\t# Skip already registered paths\n\t\tname=$(module_name \"$path\") || exit\n\t\turl=$(git config submodule.\"$name\".url)\n\t\ttest -z \"$url\" || continue\n\n\t\turl=$(git config -f .gitmodules submodule.\"$name\".url)\n\t\ttest -z \"$url\" &&\n\t\tdie \"No url found for submodule path '$path' in .gitmodules\"\n\n\t\t# Possibly a url relative to parent\n\t\tcase \"$url\" in\n\t\t./*|../*)\n\t\t\turl=$(resolve_relative_url \"$url\") || exit\n\t\t\t;;\n\t\tesac\n\n\t\tgit config submodule.\"$name\".url \"$url\" ||\n\t\tdie \"Failed to register url for submodule path '$path'\"\n\n\t\tupd=\"$(git config -f .gitmodules submodule.\"$name\".update)\"\n\t\ttest -z \"$upd\" ||\n\t\tgit config submodule.\"$name\".update \"$upd\" ||\n\t\tdie \"Failed to register update mode for submodule path '$path'\"\n\n\t\tsay \"Submodule '$name' ($url) registered for path '$path'\"\n\tdone\n}\n\n#\n# Update each submodule path to correct revision, using clone and checkout as needed\n#\n# $@ = requested paths (default to all)\n#\ncmd_update()\n{\n\t# parse $args after \"submodule ... update\".\n\torig_args=\"$@\"\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tshift\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t-i|--init)\n\t\t\tinit=1\n\t\t\tshift\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-r|--rebase)\n\t\t\tshift\n\t\t\tupdate=\"rebase\"\n\t\t\t;;\n\t\t--reference)\n\t\t\tcase \"$2\" in '') usage ;; esac\n\t\t\treference=\"--reference=$2\"\n\t\t\tshift 2\n\t\t\t;;\n\t\t--reference=*)\n\t\t\treference=\"$1\"\n\t\t\tshift\n\t\t\t;;\n\t\t-m|--merge)\n\t\t\tshift\n\t\t\tupdate=\"merge\"\n\t\t\t;;\n\t\t--recursive)\n\t\t\tshift\n\t\t\trecursive=1\n\t\t\t;;\n\t\t--save-progress)\n\t\t\tshift\n\t\t\tsave_progress=1\n\t\t\t;;\t\n\t\t--resume-update)\n\t\t\tshift\n\t\t\tsubmodule_resume=1\n\t\t\t;;\t\t\t\t\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\tdone\n\n\tif test -n \"$init\"\n\tthen\n\t\tcmd_init \"--\" \"$@\" || return\n\tfi\n\t\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\n\t\t\n\t\tname=$(module_name \"$path\") || exit\n\t\turl=$(git config submodule.\"$name\".url)\n\t\tupdate_module=$(git config submodule.\"$name\".update)\n\t\t\n\t\tif test -n \"$submodule_resume\"\n\t\tthen\n\t\t\tSubmodulePathResume=`pwd`\n\t\t\tSubmodulePathResume=$SubmodulePathResume/\"$name\"\n\t\t\t\n\t\t\t#SubmodulePathResume=$(pwd echo\"'$name'\")\n\t\t\t#say \"'$SubmodulePathResume'\"\n\t\t\t\n\t\t\tsay $SubmodulePathResume\n\t\t\tAFile=`cat \"Test.txt\" | grep \"$SubmodulePathResume\"`\n\t\t\t\n\t\t\tsay $AFile;\n\t\t\t\n\t\t\tif test -n \"$AFile\"\n\t\t\tthen\n\t\t\t\tsay \"CancelRecursive\"\n\t\t\t\tCancelRecursive=1\n\t\t\telse\n\t\t\t\tsay \"dupa\"\n\t\t\t\tCancelRecursive=\"\"\n\t\t\tfi\t\t\t\n\t\tfi\n\t\t\n\t\tif test -z \"$url\"\n\t\tthen\n\t\t\t# Only mention uninitialized submodules when its\n\t\t\t# path have been specified\n\t\t\ttest \"$#\" != \"0\" &&\n\t\t\tsay \"Submodule path '$path' not initialized\" &&\n\t\t\tsay \"Maybe you want to use 'update --init'?\"\n\t\t\tcontinue\n\t\tfi\n\n\t\tif ! test -d \"$path\"/.git -o -f \"$path\"/.git\n\t\tthen\n\t\t\tmodule_clone \"$path\" \"$url\" \"$reference\"|| exit\n\t\t\tsubsha1=\n\t\telse\n\t\t\tsubsha1=$(clear_local_git_env; cd \"$path\" &&\n\t\t\t\tgit rev-parse --verify HEAD) ||\n\t\t\tdie \"Unable to find current revision in submodule path '$path'\"\n\t\tfi\n\n\t\tif ! test -z \"$update\"\n\t\tthen\n\t\t\tupdate_module=$update\n\t\tfi\n\n\t\tif test \"$subsha1\" != \"$sha1\"\n\t\tthen\n\t\t\tforce=\n\t\t\tif test -z \"$subsha1\"\n\t\t\tthen\n\t\t\t\tforce=\"-f\"\n\t\t\tfi\n\n\t\t\tif test -z \"$nofetch\"\n\t\t\tthen\n\t\t\t\t(clear_local_git_env; 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\t\t\t\n\t\t\tif test -n \"$submodule_resume\"\n\t\t\tthen\n\t\t\t\tupdate=\"resume\"\n\t\t\tfi\n\n\t\t\tcase \"$update_module\" in\n\t\t\trebase)\n\t\t\t\tcommand=\"git rebase\"\n\t\t\t\taction=\"rebase\"\n\t\t\t\tmsg=\"rebased onto\"\n\t\t\t\t;;\n\t\t\tmerge)\n\t\t\t\tcommand=\"git merge\"\n\t\t\t\taction=\"merge\"\n\t\t\t\tmsg=\"merged in\"\n\t\t\t\t;;\n\t\t\t*)\n\t\t\t\tcommand=\"git checkout $force -q\"\n\t\t\t\taction=\"checkout\"\n\t\t\t\tmsg=\"checked out\"\n\t\t\t\t;;\n\t\t\tresume)\n\t\t\t\t\n\t\t\t\t;;\n\t\t\tesac\n\n\t\t\t(clear_local_git_env; cd \"$path\" && $command \"$sha1\") ||\n\t\t\tdie \"Unable to $action '$sha1' in submodule path '$path'\"\n\t\t\tsay \"Submodule path '$path': $msg '$sha1'\"\n\t\tfi\n\t\n\t\tif test -n \"$recursive\"\n\t\tthen\n\t\t\tif test -z \"$CancelRecursive\"\n\t\t\tthen\n\t\t\t\t(clear_local_git_env; cd \"$path\" && cmd_update $orig_args) ||\n\t\t\t\tdie \"Failed to recurse into submodule path '$path'\"\n\t\t\tfi\n\t\tfi\n\t\t\n\t\tif test -n \"$save_progress\"\n\t\tthen\n\t\t\t\tSubmodulePath=`pwd`\n\t\t\t\tSubmodulePath=$SubmodulePath/\"$name\"\n\t\t\t\t\n\t\t\t\t#SubmodulePath=$(pwd echo\"'$name'\")\n\t\t\t\tsay \"'$SubmodulePath'\"\n\t\t\t\techo \"'$SubmodulePath'\" >> Test.txt\n\t\tfi\n\tdone\n}\n\nset_name_rev () {\n\trevname=$( (\n\t\tclear_local_git_env\n\t\tcd \"$1\" && {\n\t\t\tgit describe \"$2\" 2>/dev/null ||\n\t\t\tgit describe --tags \"$2\" 2>/dev/null ||\n\t\t\tgit describe --contains \"$2\" 2>/dev/null ||\n\t\t\tgit describe --all --always \"$2\"\n\t\t}\n\t) )\n\ttest -z \"$revname\" || revname=\" ($revname)\"\n}\n#\n# Show commit summary for submodules in index or working tree\n#\n# If '--cached' is given, show summary between index and given commit,\n# or between working tree and given commit\n#\n# $@ = [commit (default 'HEAD'),] requested paths (default all)\n#\ncmd_summary() {\n\tsummary_limit=-1\n\tfor_status=\n\tdiff_cmd=diff-index\n\n\t# parse $args after \"submodule ... summary\".\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t--cached)\n\t\t\tcached=\"$1\"\n\t\t\t;;\n\t\t--files)\n\t\t\tfiles=\"$1\"\n\t\t\t;;\n\t\t--for-status)\n\t\t\tfor_status=\"$1\"\n\t\t\t;;\n\t\t-n|--summary-limit)\n\t\t\tif summary_limit=$(($2 + 0)) 2>/dev/null && test \"$summary_limit\" = \"$2\"\n\t\t\tthen\n\t\t\t\t:\n\t\t\telse\n\t\t\t\tusage\n\t\t\tfi\n\t\t\tshift\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\ttest $summary_limit = 0 && return\n\n\tif rev=$(git rev-parse -q --verify --default HEAD ${1+\"$1\"})\n\tthen\n\t\thead=$rev\n\t\ttest $# = 0 || shift\n\telif test -z \"$1\" -o \"$1\" = \"HEAD\"\n\tthen\n\t\t# before the first commit: compare with an empty tree\n\t\thead=$(git hash-object -w -t tree --stdin </dev/null)\n\t\ttest -z \"$1\" || shift\n\telse\n\t\thead=\"HEAD\"\n\tfi\n\n\tif [ -n \"$files\" ]\n\tthen\n\t\ttest -n \"$cached\" &&\n\t\tdie \"--cached cannot be used with --files\"\n\t\tdiff_cmd=diff-files\n\t\thead=\n\tfi\n\n\tcd_to_toplevel\n\t# Get modified modules cared by user\n\tmodules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- \"$@\" |\n\t\tsane_egrep '^:([0-7]* )?160000' |\n\t\twhile read mod_src mod_dst sha1_src sha1_dst status name\n\t\tdo\n\t\t\t# Always show modules deleted or type-changed (blob<->module)\n\t\t\ttest $status = D -o $status = T && echo \"$name\" && continue\n\t\t\t# Also show added or modified modules which are checked out\n\t\t\tGIT_DIR=\"$name/.git\" git-rev-parse --git-dir >/dev/null 2>&1 &&\n\t\t\techo \"$name\"\n\t\tdone\n\t)\n\n\ttest -z \"$modules\" && return\n\n\tgit $diff_cmd $cached --ignore-submodules=dirty --raw $head -- $modules |\n\tsane_egrep '^:([0-7]* )?160000' |\n\tcut -c2- |\n\twhile read mod_src mod_dst sha1_src sha1_dst status name\n\tdo\n\t\tif test -z \"$cached\" &&\n\t\t\ttest $sha1_dst = 0000000000000000000000000000000000000000\n\t\tthen\n\t\t\tcase \"$mod_dst\" in\n\t\t\t160000)\n\t\t\t\tsha1_dst=$(GIT_DIR=\"$name/.git\" git rev-parse HEAD)\n\t\t\t\t;;\n\t\t\t100644 | 100755 | 120000)\n\t\t\t\tsha1_dst=$(git hash-object $name)\n\t\t\t\t;;\n\t\t\t000000)\n\t\t\t\t;; # removed\n\t\t\t*)\n\t\t\t\t# unexpected type\n\t\t\t\techo >&2 \"unexpected mode $mod_dst\"\n\t\t\t\tcontinue ;;\n\t\t\tesac\n\t\tfi\n\t\tmissing_src=\n\t\tmissing_dst=\n\n\t\ttest $mod_src = 160000 &&\n\t\t! GIT_DIR=\"$name/.git\" git-rev-parse -q --verify $sha1_src^0 >/dev/null &&\n\t\tmissing_src=t\n\n\t\ttest $mod_dst = 160000 &&\n\t\t! GIT_DIR=\"$name/.git\" git-rev-parse -q --verify $sha1_dst^0 >/dev/null &&\n\t\tmissing_dst=t\n\n\t\ttotal_commits=\n\t\tcase \"$missing_src,$missing_dst\" in\n\t\tt,)\n\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_src\"\n\t\t\t;;\n\t\t,t)\n\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_dst\"\n\t\t\t;;\n\t\tt,t)\n\t\t\terrmsg=\"  Warn: $name doesn't contain commits $sha1_src and $sha1_dst\"\n\t\t\t;;\n\t\t*)\n\t\t\terrmsg=\n\t\t\ttotal_commits=$(\n\t\t\tif test $mod_src = 160000 -a $mod_dst = 160000\n\t\t\tthen\n\t\t\t\trange=\"$sha1_src...$sha1_dst\"\n\t\t\telif test $mod_src = 160000\n\t\t\tthen\n\t\t\t\trange=$sha1_src\n\t\t\telse\n\t\t\t\trange=$sha1_dst\n\t\t\tfi\n\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\tgit rev-list --first-parent $range -- | wc -l\n\t\t\t)\n\t\t\ttotal_commits=\" ($(($total_commits + 0)))\"\n\t\t\t;;\n\t\tesac\n\n\t\tsha1_abbr_src=$(echo $sha1_src | cut -c1-7)\n\t\tsha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)\n\t\tif test $status = T\n\t\tthen\n\t\t\tif test $mod_dst = 160000\n\t\t\tthen\n\t\t\t\techo \"* $name $sha1_abbr_src(blob)->$sha1_abbr_dst(submodule)$total_commits:\"\n\t\t\telse\n\t\t\t\techo \"* $name $sha1_abbr_src(submodule)->$sha1_abbr_dst(blob)$total_commits:\"\n\t\t\tfi\n\t\telse\n\t\t\techo \"* $name $sha1_abbr_src...$sha1_abbr_dst$total_commits:\"\n\t\tfi\n\t\tif test -n \"$errmsg\"\n\t\tthen\n\t\t\t# Don't give error msg for modification whose dst is not submodule\n\t\t\t# i.e. deleted or changed to blob\n\t\t\ttest $mod_dst = 160000 && echo \"$errmsg\"\n\t\telse\n\t\t\tif test $mod_src = 160000 -a $mod_dst = 160000\n\t\t\tthen\n\t\t\t\tlimit=\n\t\t\t\ttest $summary_limit -gt 0 && limit=\"-$summary_limit\"\n\t\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\t\tgit log $limit --pretty='format:  %m %s' \\\n\t\t\t\t--first-parent $sha1_src...$sha1_dst\n\t\t\telif test $mod_dst = 160000\n\t\t\tthen\n\t\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\t\tgit log --pretty='format:  > %s' -1 $sha1_dst\n\t\t\telse\n\t\t\t\tGIT_DIR=\"$name/.git\" \\\n\t\t\t\tgit log --pretty='format:  < %s' -1 $sha1_src\n\t\t\tfi\n\t\t\techo\n\t\tfi\n\t\techo\n\tdone |\n\tif test -n \"$for_status\"; then\n\t\tif [ -n \"$files\" ]; then\n\t\t\techo \"# Submodules changed but not updated:\"\n\t\telse\n\t\t\techo \"# Submodule changes to be committed:\"\n\t\tfi\n\t\techo \"#\"\n\t\tsed -e 's|^|# |' -e 's|^# $|#|'\n\telse\n\t\tcat\n\tfi\n}\n#\n# List all submodules, prefixed with:\n#  - submodule not initialized\n#  + different revision checked out\n#\n# If --cached was specified the revision in the index will be printed\n# instead of the currently checked out revision.\n#\n# $@ = requested paths (default to all)\n#\ncmd_status()\n{\n\t# parse $args after \"submodule ... status\".\n\torig_args=\"$@\"\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\t;;\n\t\t--cached)\n\t\t\tcached=1\n\t\t\t;;\n\t\t--recursive)\n\t\t\trecursive=1\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\t\tshift\n\tdone\n\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\n\t\tname=$(module_name \"$path\") || exit\n\t\turl=$(git config submodule.\"$name\".url)\n\t\tdisplaypath=\"$prefix$path\"\n\t\tif test -z \"$url\" || ! test -d \"$path\"/.git -o -f \"$path\"/.git\n\t\tthen\n\t\t\tsay \"-$sha1 $displaypath\"\n\t\t\tcontinue;\n\t\tfi\n\t\tset_name_rev \"$path\" \"$sha1\"\n\t\tif git diff-files --ignore-submodules=dirty --quiet -- \"$path\"\n\t\tthen\n\t\t\tsay \" $sha1 $displaypath$revname\"\n\t\telse\n\t\t\tif test -z \"$cached\"\n\t\t\tthen\n\t\t\t\tsha1=$(clear_local_git_env; cd \"$path\" && git rev-parse --verify HEAD)\n\t\t\t\tset_name_rev \"$path\" \"$sha1\"\n\t\t\tfi\n\t\t\tsay \"+$sha1 $displaypath$revname\"\n\t\tfi\n\n\t\tif test -n \"$recursive\"\n\t\tthen\n\t\t\t(\n\t\t\t\tprefix=\"$displaypath/\"\n\t\t\t\tclear_local_git_env\n\t\t\t\tcd \"$path\" &&\n\t\t\t\tcmd_status $orig_args\n\t\t\t) ||\n\t\t\tdie \"Failed to recurse into submodule path '$path'\"\n\t\tfi\n\tdone\n}\n#\n# Sync remote urls for submodules\n# This makes the value for remote.$remote.url match the value\n# specified in .gitmodules.\n#\ncmd_sync()\n{\n\twhile test $# -ne 0\n\tdo\n\t\tcase \"$1\" in\n\t\t-q|--quiet)\n\t\t\tGIT_QUIET=1\n\t\t\tshift\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\tusage\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\t\tesac\n\tdone\n\tcd_to_toplevel\n\tmodule_list \"$@\" |\n\twhile read mode sha1 stage path\n\tdo\n\t\tname=$(module_name \"$path\")\n\t\turl=$(git config -f .gitmodules --get submodule.\"$name\".url)\n\n\t\t# Possibly a url relative to parent\n\t\tcase \"$url\" in\n\t\t./*|../*)\n\t\t\turl=$(resolve_relative_url \"$url\") || exit\n\t\t\t;;\n\t\tesac\n\n\t\tif test -e \"$path\"/.git\n\t\tthen\n\t\t(\n\t\t\tsay \"Synchronizing submodule url for '$name'\"\n\t\t\tgit config submodule.\"$name\".url \"$url\"\n\t\t\tclear_local_git_env\n\t\t\tcd \"$path\"\n\t\t\tremote=$(get_default_remote)\n\t\t\tgit config remote.\"$remote\".url \"$url\"\n\t\t)\n\t\tfi\n\tdone\n}\n\n# This loop parses the command line arguments to find the\n# subcommand name to dispatch.  Parsing of the subcommand specific\n# options are primarily done by the subcommand implementations.\n# Subcommand specific options such as --branch and --cached are\n# parsed here as well, for backward compatibility.\n\nwhile test $# != 0 && test -z \"$command\"\ndo\n\tcase \"$1\" in\n\tadd | foreach | init | update | status | summary | sync)\n\t\tcommand=$1\n\t\t;;\n\t-q|--quiet)\n\t\tGIT_QUIET=1\n\t\t;;\n\t-b|--branch)\n\t\tcase \"$2\" in\n\t\t'')\n\t\t\tusage\n\t\t\t;;\n\t\tesac\n\t\tbranch=\"$2\"; shift\n\t\t;;\n\t--cached)\n\t\tcached=\"$1\"\n\t\t;;\n\t--)\n\t\tbreak\n\t\t;;\n\t-*)\n\t\tusage\n\t\t;;\n\t*)\n\t\tbreak\n\t\t;;\n\tesac\n\tshift\ndone\n\n# No command word defaults to \"status\"\ntest -n \"$command\" || command=status\n\n# \"-b branch\" is accepted only by \"add\"\nif test -n \"$branch\" && test \"$command\" != add\nthen\n\tusage\nfi\n\n# \"--cached\" is accepted only by \"status\" and \"summary\"\nif test -n \"$cached\" && test \"$command\" != status -a \"$command\" != summary\nthen\n\tusage\nfi\n\n\"cmd_$command\" \"$@\"\n"},{"id":"154790","messageId":"20101029164055.GA28934@burratino","threadId":"25575","inReplyTo":"4CCAB20A.1000408@prevac.pl","subject":"Re: Restart submodule update --recursive","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-29T16:40:55Z","receivedAt":"2010-10-29T16:40:55Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi again,\n\nLukasz Palczewski wrote:\n> Jonathan Nieder wrote:\n\n>> [side note: if you use a newsreader, please reply by mail instead of\n>> through gmane so the Cc: list can be preserved.]\n>\n> Sorry, but I do not use it. I will send You a normal email.\n\nThanks.\n\n> I have added two options to git submodule update:\n> --save-progress\n> --resume-update\n> First one You can use, to save the ./.git/SubmoduleUpdateLog.log the\n> progress of updating:\n> git submodule update --recursive --save-progress\n> The second one is used for skipping updated submodules:\n> git submodule update --recursive --resume-update\n> \n> The downside of it is, that u can use only one --resume-update.\n\nDoes the combination\n\"git submodule update --recursive --save-progress --resume-update\"\nwork?\n\n> Let me know if this change will be in next version of git.\n\nI will leave that question to the submodule experts.  But note that\nthere is no need to wait: if you change the \". git-sh-setup\" line\nto\n\n\t. \"$(git --exec-path)/git-sh-setup\"\n\nthen if you install the modified script as git-mysubmodule anywhere on\nyour $PATH, it will be used to implement\n\n\tgit mysubmodule update --recursive --save-progress\n\n.  Of course you can run it directly as \"git-mysubmodule\", too.\n\ndiffs are easier to review.  If your change is for inclusion, it will\nalso need a Signed-off-by: line; see Documentation/SubmittingPatches.\n\n> cmd_update()\n> {\n[...]\n> \t\t--save-progress)\n> \t\t\tshift\n> \t\t\tsave_progress=1\n> \t\t\tif test -e ./.git/SubmoduleUpdateLog.log\n> \t\t\tthen\n> \t\t\t\trm ./.git/SubmoduleUpdateLog.log\n> \t\t\tfi\n\nSome current temporary files used by git:\n\n\t.git/rr-cache/*\n\t.git/gitk.cache\n\t.git/rebase-merge/*\n\t.git/rebase-apply/*\n\nThe\n\tif test -e $foo\n\tthen\n\t\trm $foo\n\tfi\n\nidiom can be written more simply as\n\n\trm -f $foo\n\nbut are you sure that is what you want?  Maybe it would be better\nto\n\n\t1) destroy progress when the update is completed\n\t2) always save updated progress when resuming\n\t3) complain when --save-progress would require clobbering\n\t   some existing progress\n\t4) provide an additional --reset-progress option to start\n\t   over\n\n?\n\nFWIW \"git am\" and \"git rebase\" already have the ability to resume\nwhere they left off, using options with these names:\n\n\tgit <foo> --continue\n\tgit <foo> --skip\n\tgit <foo> --abort\n\nThe --abort options undo the effect of the earlier runs.  \"git bisect\"\nalso keeps some state on progress.\n\n\tgit bisect (good|bad); # continue\n\tgit bisect skip\n\tgit bisect reset\n\n> \tmodule_list \"$@\" |\n> \twhile read mode sha1 stage path\n> \tdo\t\t\n> \t\tname=$(module_name \"$path\") || exit\n> \t\turl=$(git config submodule.\"$name\".url)\n> \t\tupdate_module=$(git config submodule.\"$name\".update)\n> \t\t\n> \t\tif test -n \"$submodule_resume\"\n> \t\tthen\n> \t\t\tSubmodulePathResume=`pwd`\n> \t\t\tSubmodulePathResume=$SubmodulePathResume/\"$name\"\n\nIt might be more idiomatic to say\n\n\tmodule_list \"$@\" |\n\t...\n\t\t\t(\n\t\t\t\tprefix=\"$prefix$path/\"\n\nThree benefits:\n\n - local variables tend to get short, lowercase names\n - this variable looks like a path, but using $name makes it not\n   one (if foo/bar is a submodule simple named \"bar\", for example)\n - using relative paths allows an update to be resumed after moving\n   a repository or just accessing it via a different path.\n\nThe subshell ensures the old prefix is restored when cmd_update\nreturns.  The same effect could also be achieved by saving the old\nprefix (in case it is important to save a few processes).\n\n> \t\t\t\n> \t\t\t#say $SubmodulePathResume\n> \t\t\tif test -e ./.git/SubmoduleUpdateLog.log\n\nWhat if I try to resume and there is no progress information?\nWould it make sense to keep the progress information at the toplevel,\nso one could run commands like \"submodule update --recursive\n--resumable\" in submodules without affecting the superproject state?\n\n\n> \t\t\tthen\n> \t\t\t\tAFile=`cat \"./.git/SubmoduleUpdateLog.log\" | grep \"$SubmodulePathResume\"`\n> \t\t\t\t\n> \t\t\t\t#say $AFile;\t\t\t\n> \t\t\t\tif test -n \"$AFile\"\n\nThe following could work if each submodule is written to\nsubmodule-update.log only if all its submodules have been updated\n(as in your current code):\n\n\t\tif git grep --no-index -q -F \"$prefix\" \"$GIT_DIR/submodule-update.log\"\n\t\tthen\n\t\t\tsay \"Skip...\n\t\t\tcontinue\n\t\tfi\n\nI'm not sure fgrep is portable, which is why I use \"git grep\" here.\n\nThis is slower than it could be.  Ideally one would only keep\nthe last updated submodule and chop the module_list output there,\ninstead of re-reading the list with each iteration (which is O(size of\ndirectory squared)).\n\nHope that helps,\nJonathan\n"},{"id":"154840","messageId":"212962199.646095.1288423075790.JavaMail.fmail@mwmweb046","threadId":"25575","inReplyTo":"4CCAB20A.1000408@prevac.pl","subject":"Re: Restart submodule update --recursive","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-10-30T07:17:55Z","receivedAt":"2010-10-30T07:17:55Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":">Let me know if this change will be in next version of git.\n\nSorry I'm coming late into this thread,but I'm still traveling.\n\nLukasz, maybe you could wait until I finish the recursive checkout I am\ncurrently working on? Because then there will be no need to run\n\"git submodule update\" anymore, but \"git checkout\" will update\nsubmodules recursively too. And it will only fail if the checkout would\noverwrite your local modifications, not just because the submodule is\nmodified in some way, and in this case it won't start at all instead of stopping\nsomewhere in between (you can test that new behavior by checking\nout the branch \"enhance_git_for_submodules\" of my github repo:\nhttp://github.com/jlehmann/git-submod-enhancements ).\n\nWould that solve your problem?\n"},{"id":"154954","messageId":"4CCFC94B.2010708@prevac.pl","threadId":"25575","inReplyTo":"212962199.646095.1288423075790.JavaMail.fmail@mwmweb046","subject":"Re: Restart submodule update --recursive","fromName":"Lukasz Palczewski","fromEmail":"l.palczewski@prevac.pl","sentAt":"2010-11-02T08:18:19Z","receivedAt":"2010-11-02T08:18:19Z","isPatch":false,"sender":{"key":"l.palczewski@prevac.pl","avatar":null},"body":"Jens Lehmann wrote:\n>> Let me know if this change will be in next version of git.\n> Sorry I'm coming late into this thread,but I'm still traveling.\n>\n> Lukasz, maybe you could wait until I finish the recursive checkout I am\n> currently working on? Because then there will be no need to run\n> \"git submodule update\" anymore, but \"git checkout\" will update\n> submodules recursively too. And it will only fail if the checkout would\n> overwrite your local modifications, not just because the submodule is\n> modified in some way, and in this case it won't start at all instead of stopping\n> somewhere in between (you can test that new behavior by checking\n> out the branch \"enhance_git_for_submodules\" of my github repo:\n> http://github.com/jlehmann/git-submod-enhancements ).\n>\n> Would that solve your problem?\n\nHi Jens,\nWell I will wait for it and see if it does, but it will not solve all \nthe problems.\nOnce I had a problem, when someone forgot to push a commit in the \nsubmodule, but pushed a commit in the main repository. Becouse of it, I \ncould not update that repository. If this problem occours, I will have \nto update all the submodules with the one command \"git submodules update \n--recursive\" (when someone finally pushes the submodule). If the \"git \ncheckout\" updates the rest ( not updated) submodules, but not check the \nones, that were updated earlier, then it will work for me.\n"},{"id":"154963","messageId":"4CCFF145.1060300@web.de","threadId":"25575","inReplyTo":"4CCFC94B.2010708@prevac.pl","subject":"Re: Restart submodule update --recursive","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-11-02T11:08:53Z","receivedAt":"2010-11-02T11:08:53Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 02.11.2010 09:18, schrieb Lukasz Palczewski:\n> Well I will wait for it and see if it does, but it will not solve all the problems.\n\nThanks, as we are moving more submodule functionality into the git\ncommands I would rather avoid adding new stuff to git-submodule.sh\nunless it is something not handled by that move.\n\n> Once I had a problem, when someone forgot to push a commit in the\n> submodule, but pushed a commit in the main repository.\n\nYes, this is a common problem. We'll add a test for that in \"git push\"\nsoon, then it won't be possible to do that by accident anymore.\n\n> Becouse of it, I could not update that repository. If this problem\n> occours, I will have to update all the submodules with the one\n> command \"git submodules update --recursive\" (when someone finally\n> pushes the submodule). If the \"git checkout\" updates the rest\n> ( not updated) submodules, but not check the ones, that were updated\n> earlier, then it will work for me.\n\nAs the functionality which is now done by \"git submodule update\"\nwill be split into recursive fetch and recursive checkout, you would\nhave to issue a \"git fetch --recurse-submodules\" to retrieve the\nmissing commits. But that shouldn't be necessary when \"git push\"\ntests for all submodule commits to be pushed too before it pushes\nthe superproject.\n"}]}