summaryrefslogtreecommitdiff
path: root/git-submodule.sh
AgeCommit message (Collapse)Author
2012-12-19submodule add: If --branch is given, record it in .gitmodulesW. Trevor King
This allows you to easily record a submodule.<name>.branch option in .gitmodules when you add a new submodule. With this patch, $ git submodule add -b <branch> <repository> [<path>] $ git config -f .gitmodules submodule.<path>.branch <branch> reduces to $ git submodule add -b <branch> <repository> [<path>] This means that future calls to $ git submodule update --remote ... will get updates from the same branch that you used to initialize the submodule, which is usually what you want. Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-19submodule update: add --remote for submodule's upstream changesW. Trevor King
The current `update` command incorporates the superproject's gitlinked SHA-1 ($sha1) into the submodule HEAD ($subsha1). Depending on the options you use, it may checkout $sha1, rebase the $subsha1 onto $sha1, or merge $sha1 into $subsha1. This helps you keep up with changes in the upstream superproject. However, it's also useful to stay up to date with changes in the upstream subproject. Previous workflows for incorporating such changes include the ungainly: $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull' With this patch, all of the useful functionality for incorporating superproject changes can be reused to incorporate upstream subproject updates. When you specify --remote, the target $sha1 is replaced with a $sha1 of the submodule's origin/master tracking branch. If you want to merge a different tracking branch, you can configure the `submodule.<name>.branch` option in `.gitmodules`. You can override the `.gitmodules` configuration setting for a particular superproject by configuring the option in that superproject's default configuration (using the usual configuration hierarchy, e.g. `.git/config`, `~/.gitconfig`, etc.). Previous use of submodule.<name>.branch ======================================= Because we're adding a new configuration option, it's a good idea to check if anyone else is already using the option. The foreach-pull example above was described by Ævar in commit f030c96d8643fa0a1a9b2bd9c2f36a77721fb61f Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Date: Fri May 21 16:10:10 2010 +0000 git-submodule foreach: Add $toplevel variable Gerrit uses the same interpretation for the setting, but because Gerrit has direct access to the subproject repositories, it updates the superproject repositories automatically when a subproject changes. Gerrit also accepts the special value '.', which it expands into the superproject's branch name. Although the --remote functionality is using `submodule.<name>.branch` slightly differently, the effect is the same. The foreach-pull example uses the option to record the name of the local branch to checkout before pulls. The tracking branch to be pulled is recorded in `.git/modules/<name>/config`, which was initialized by the module clone during `submodule add` or `submodule init`. Because the branch name stored in `submodule.<name>.branch` was likely the same as the branch name used during the initial `submodule add`, the same branch will be pulled in each workflow. Implementation details ====================== In order to ensure a current tracking branch state, `update --remote` fetches the submodule's remote repository before calculating the SHA-1. However, I didn't change the logic guarding the existing fetch: if test -z "$nofetch" then # Run fetch only if $sha1 isn't present or it # is not reachable from a ref. (clear_local_git_env; cd "$path" && ( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) && test -z "$rev") || git-fetch)) || die "$(eval_gettext "Unable to fetch in submodule path '\$path'")" fi There will not be a double-fetch, because the new $sha1 determined after the `--remote` triggered fetch should always exist in the repository. If it doesn't, it's because some racy process removed it from the submodule's repository and we *should* be re-fetching. Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-12submodule: add get_submodule_config helper funtionW. Trevor King
Several submodule configuration variables (e.g. fetchRecurseSubmodules) are read from .gitmodules with local overrides from the usual git config files. This shell function mimics that logic to help initialize configuration variables in git-submodule.sh. Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-21Merge branch 'wtk/submodule-doc-fixup'Junio C Hamano
* wtk/submodule-doc-fixup: git-submodule: wrap branch option with "<>" in usage strings.
2012-11-15Merge branch 'ph/submodule-sync-recursive'Junio C Hamano
Adds "--recursive" option to submodule sync. * ph/submodule-sync-recursive: Add tests for submodule sync --recursive Teach --recursive to submodule sync
2012-11-09Merge branch 'ph/maint-submodule-status-fix'Jeff King
Cleans up some leftover bits from an earlier submodule change. * ph/maint-submodule-status-fix: submodule status: remove unused orig_* variables t7407: Fix recursive submodule test
2012-11-04Merge branch 'sz/maint-submodule-reference-arg'Jeff King
* sz/maint-submodule-reference-arg: submodule add: fix handling of --reference=<repo> option
2012-10-29Merge branch 'jl/submodule-add-by-name'Jeff King
If you remove a submodule, in order to keep the repository so that "git checkout" to an older commit in the superproject history can resurrect the submodule, the real repository will stay in $GIT_DIR of the superproject. A later "git submodule add $path" to add a different submodule at the same path will fail. Diagnose this case a bit better, and if the user really wants to add an unrelated submodule at the same path, give the "--name" option to give it a place in $GIT_DIR of the superproject that does not conflict with the original submodule. * jl/submodule-add-by-name: submodule add: Fail when .git/modules/<name> already exists unless forced Teach "git submodule add" the --name option
2012-10-29Teach --recursive to submodule syncPhil Hord
The submodule sync command was somehow left out when --recursive was added to the other submodule commands. Teach sync to handle the --recursive switch by recursing when we're in a submodule we are sync'ing. Change the report during sync to show submodule-path instead of submodule-name to be consistent with the other submodule commands and to help recursed paths make sense. Signed-off-by: Phil Hord <hordp@cisco.com> Acked-By: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Jeff King <peff@peff.net>
2012-10-29submodule status: remove unused orig_* variablesJens Lehmann
When renaming orig_args to orig_flags in 98dbe63d (submodule: only preserve flags across recursive status/update invocations) the call site of the recursive cmd_status was forgotten. At that place orig_args is still passed into the recursion, which is always empty since then. This did not break anything because the orig_flags logic is not needed at all when a function from the submodule script is called with eval, as that inherits all the variables set by the option parsing done in the first level of the recursion. Now that we know that orig_flags and orig_args aren't needed at all, let's just remove them from cmd_status(). Thanks-to: Phil Hord <hordp@cisco.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Jeff King <peff@peff.net>
2012-10-26submodule add: fix handling of --reference=<repo> optionStefan Zager
Doing a shift here is wrong because there is no extra argument to consume when "--reference=<repo>" is used (note the '=' instead of a space). Signed-off-by: Stefan Zager <szager@google.com> Signed-off-by: Jeff King <peff@peff.net>
2012-10-25git-submodule: wrap branch option with "<>" in usage strings.W. Trevor King
Use "-b <branch>" instead of "-b branch". This brings the usage strings in line with other options, e.g. "--reference <repository>". Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Jeff King <peff@peff.net>
2012-10-02Merge branch 'rr/maint-submodule-unknown-cmd' into maintJunio C Hamano
"git submodule frotz" was not diagnosed as "frotz" being an unknown subcommand to "git submodule"; the user instead got a complaint that "git submodule status" was run with an unknown path "frotz". * rr/maint-submodule-unknown-cmd: submodule: if $command was not matched, don't parse other args
2012-09-30submodule add: Fail when .git/modules/<name> already exists unless forcedJens Lehmann
When adding a new submodule it can happen that .git/modules/<name> already contains a submodule repo, e.g. when a submodule is removed from the work tree and another submodule is added at the same path. But then the work tree of the submodule will be populated using the existing repository and not the one the user provided, which results in an incorrect work tree. On the other hand the user might reactivate a submodule removed earlier, then reusing that .git directory is the Right Thing to do. As git can't decide what is the case, error out and tell the user she should use either use a different name for the submodule with the "--name" option or can reuse the .git directory for the newly added submodule by providing the --force option (which only makes sense when the upstream matches, so the error message lists all remotes of .git/modules/<name>). In one test in t7406 the --force option had to be added to "git submodule add", as that test re-adds a formerly removed submodule. Reported-by: Jonathan Johnson <me@jondavidjohn.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-30Merge branch 'rr/maint-submodule-unknown-cmd'Junio C Hamano
* rr/maint-submodule-unknown-cmd: submodule: if $command was not matched, don't parse other args
2012-09-30Teach "git submodule add" the --name optionJens Lehmann
"git submodule add" initializes the name of a submodule to its path. This was ok as long as the .git directory lived inside the submodule's work tree, but since 1.7.8 it is stored in the .git/modules/<name> directory of the superproject, making the submodule name survive the removal of the submodule's work tree. This leads to problems when the user tries to add a different submodule at the same path - and thus the same name - later, as that will happily try to restore the submodule from the old repository instead of the one the user specified and will lead to a checkout of the wrong repository. Add the new "--name" option to let the user provide a name for the submodule. This enables the user to solve this conflict without having to remove .git/modules/<name> by hand (which is no viable solution as it makes it impossible to checkout a commit that records the old submodule and populate it, as that will still check out the new submodule for the same reason). To achieve that the submodule's name is added to the parameter list of the module_clone() helper function. This makes it possible to remove the call of module_name() there because both callers of module_clone() already know the name and can provide it as argument number two. Reported-by: Jonathan Johnson <me@jondavidjohn.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-25submodule: if $command was not matched, don't parse other argsRamkumar Ramachandra
"git submodule" command DWIMs the command line and assumes a unspecified action word for 'status' action. This is a UI mistake that leads to a confusing behaviour. A mistyped command name is instead treated as a request for 'status' of the submodule with that name, e.g. $ git submodule show error: pathspec 'show' did not match any file(s) known to git. Did you forget to 'git add'? Stop DWIMming an unknown or mistyped subcommand name as pathspec given to unspelled "status" subcommand. "git submodule" without any argument is still interpreted as "git submodule status", but its value is questionable. Adjust t7400 to match, and stop advertising the default subcommand being 'status' which does not help much in practice, other than promoting laziness and confusion. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-11Sync with 1.7.11.6Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-11Merge branch 'sz/submodule-force-update' into maint-1.7.11Junio C Hamano
* sz/submodule-force-update: Make 'git submodule update --force' always check out submodules.
2012-09-03Merge branch 'sz/submodule-force-update'Junio C Hamano
"git submodule update --force" used to leave the working tree of the submodule intact when there were local changes. It is more intiutive to make "--force" a sign to run "checkout -f" to overwrite them. * sz/submodule-force-update: Make 'git submodule update --force' always check out submodules.
2012-08-29Merge branch 'hv/submodule-path-unmatch'Junio C Hamano
* hv/submodule-path-unmatch: Let submodule command exit with error status if path does not exist
2012-08-24Make 'git submodule update --force' always check out submodules.Stefan Zager
Currently, it will only do a checkout if the sha1 registered in the containing repository doesn't match the HEAD of the submodule, regardless of whether the submodule is dirty. As discussed on the mailing list, the '--force' flag is a strong indicator that the state of the submodule is suspect, and should be reset to HEAD. Signed-off-by: Stefan Zager <szager@google.com> Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-14Let submodule command exit with error status if path does not existHeiko Voigt
Various subcommands of the "git submodule" command exited with 0 status even though the path given by the user did not exist. The reason behind that was that they all pipe the output of module_list into the while loop which then does the action on the paths specified by the commandline. Since the exit code of the command on the upstream side of the pipe is ignored by the shell, the status code of "ls-files --error-unmatch" nor "module_list" was not propagated. In case ls-files returns with an error code, we write a special string that is not possible in non error situations, and no other output, so that the downstream can detect the error and die with an error code. The error message that there is an unmatched pathspec comes through stderr directly from ls-files. So the user still gets a hint whats going on. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-31Merge branch 'jx/i18n-1.7.11'Junio C Hamano
Add i18n support for scripted Porcelains, and mark strings in merge(-recursive), am, and rebase for i18n. * jx/i18n-1.7.11: i18n: merge-recursive: mark strings for translation Remove dead code which contains bad gettext block i18n: am: mark more strings for translation rebase: remove obsolete and unused LONG_USAGE which breaks xgettext i18n: Rewrite gettext messages start with dash i18n: rebase: mark messages for translation i18n: New keywords for xgettext extraction from sh
2012-07-30Merge branch 'jl/maint-1.7.10-recurse-submodules-with-symlink' into maintJunio C Hamano
When "git submodule add" clones a submodule repository, it can get confused where to store the resulting submodule repository in the superproject's .git/ directory when there is a symbolic link in the path to the current directory. * jl/maint-1.7.10-recurse-submodules-with-symlink: submodules: don't stumble over symbolic links when cloning recursively
2012-07-27i18n: Rewrite gettext messages start with dashJiang Xin
Gettext message in a shell script should not start with '-', one workaround is adding '--' between gettext and the message, like: gettext -- "--exec option ..." But due to a bug in the xgettext extraction, xgettext can not extract the actual message for this case. Rewriting the message is a simpler and better solution. Reported-by: Vincent van Ravesteijn <vfr@lyx.org> Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Stefano Lattarini <stefano.lattarini@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-25git-submodule: work with GIT_DIR/GIT_WORK_TREEDaniel Graña
The combination of GIT_DIR and GIT_WORK_TREE can be used to manage files in one directory hierarchy while keeping the repository that keeps track of them outside the directory hierarchy. For example: git init --bare /path/to/there alias dotfiles="GIT_DIR=/path/to/there GIT_WORK_TREE=/path/to/here git" cd /path/to/here dotfiles add file dotfiles commit -a -m "add /path/to/here/file" ... lets you manage files under /path/to/here/ in the repository located at /path/to/there. git-submodule however fails to add submodules, as it is confused by GIT_DIR and GIT_WORK_TREE environment variables when it tries to work in the submodule, like so: dotfiles submodule add http://path.to/submodule fatal: working tree '/path/to/here' already exists. Simply unsetting the environment where the command works on the submodule is sufficient to fix this, as it has set things up so that GIT_DIR and GIT_WORK_TREE do not even have to point at the repository and the working tree of the submodule. Signed-off-by: Daniel Graña <dangra@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-22Merge branch 'jl/maint-1.7.10-recurse-submodules-with-symlink'Junio C Hamano
When "git submodule add" clones a submodule repository, it can get confused where to store the resulting submodule repository in the superproject's .git/ directory when there is a symbolic link in the path to the current directory. * jl/maint-1.7.10-recurse-submodules-with-symlink: submodules: don't stumble over symbolic links when cloning recursively
2012-07-12submodules: don't stumble over symbolic links when cloning recursivelyJens Lehmann
Since 69c3051 (submodules: refactor computation of relative gitdir path) cloning a submodule recursively fails for nested submodules when a symbolic link is part of the path to the work tree of the superproject. This happens when module_clone() tries to find the relative paths between the work tree and the git dir. When a symbolic link in current $PWD points to a directory that is at a different level, then determining the number of "../" needed to traverse to the superproject's work tree leads to a wrong result. As there is no portable way to say "pwd -P", use cd_to_toplevel to remove the link from $PWD, which fixes this problem. A test for this issue has been added to t7406. Reported-by: Bob Halley <halley@play-bow.org> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-28Merge branch 'js/submodule-relative'Junio C Hamano
Teach "git submodule" deal with nested submodule structure where a module is contained within a module whose origin is specified as a relative URL to its superproject's origin.
2012-06-25git-submodule.sh: fix filename in comment.Michał Górny
Signed-off-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-06submodule: fix handling of superproject origin URLs like foo, ./foo and ↵Jon Seymour
./foo/bar Currently git submodule init and git submodule sync fail with an error if the superproject origin URL is of the form foo but succeed if the superproject origin URL is of the form ./foo or ./foo/bar or foo/bar. This change makes handling of the foo case behave like the handling of the ./foo case and also ensures that superfluous leading and embedded ./'s are removed from the resulting derived URLs. Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-06submodule: fix sync handling of some relative superproject origin URLsJon Seymour
When the origin URL of the superproject is itself relative, git submodule sync configures the remote.origin.url configuration property of the submodule with a path that is relative to the work tree of the superproject rather than the work tree of the submodule. To fix this an 'up_path' that navigates from the work tree of the submodule to the work tree of the superproject needs to be prepended to the URL otherwise calculated. Correct handling of superproject origin URLs like foo, ./foo and ./foo/bar is left to a subsequent patch since an additional change is required to handle these cases. The documentation of resolve_relative_url() is expanded to give a more thorough description of the function's objective. Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-29submodules: print "registered for path" message only onceJens Lehmann
Since 2cd9de3e (submodule add: always initialize .git/config entry) the message "Submodule '\$name' (\$url) registered for path '\$sm_path'" is printed every time cmd_init() is called, e.g. each time "git submodule update" is used with the --init option. This was not intended and leads to bogus output which can confuse users and build systems. Apart from that the $url variable was not set after the first run which did the actual initialization and only "()" was printed in subsequent runs where "($url)" was meant to inform the user about the upstream repo. Fix that by moving the say command in question into the if block where the url is initialized, restoring the behavior that was in place before the 2cd9de3e commit. While at it also remove the comment which still describes the logic used before 2cd9de3e and add a comment about how things work now. Reported-by: Nicolas Viennot and Sid Nair <nicolas@viennot.com> Reported-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-23Merge branch 'rj/submodule-mswin-path'Junio C Hamano
By Ramsay Jones * rj/submodule-mswin-path: git-submodule.sh: Don't use $path variable in eval_gettext string
2012-04-18git-submodule.sh: Don't use $path variable in eval_gettext stringRamsay Jones
The eval_gettext (and eval_gettextln) i18n shell functions call git-sh-i18n--envsubst to process the variable references in the string parameter. Unfortunately, environment variables are case insensitive on windows, which leads to failure on cygwin when eval_gettext exports $path. Commit df599e9 (Windows: teach getenv to do a case-sensitive search, 06-06-2011) attempts to solve this problem on MinGW by overriding the system getenv() function to allow git-sh-i18n--envsubst to read $path rather than $PATH from the environment. However, this commit does not address cygwin at all and, furthermore, does not fix all problems on MinGW. In particular, when executing test #38 in t7400-submodule-basic.sh, an 'git-sh-i18n-envsubst.exe - Unable To Locate Component' dialog pops up saying that the application "failed to start because libiconv2.dll was not found." After studying the voluminous trace output from the process monitor, it is clear that the system is attempting to use $path, rather than $PATH, to search for the DLL file. (Note that, after dismissing the dialog, the test passes anyway!) As an alternative, we finesse the problem by renaming the $path variable to $sm_path (submodule path). This fixes the problem on MinGW along with all test failures on cygwin (t7400.{7,32,34}, t7406.3 and t7407.{2,6}). We note that the foreach subcommand provides $path to user scripts (ie it is part of the API), so we can't simply rename it to $sm_path. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Tested-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-09Avoid bug in Solaris xpg4/sed as used in submoduleBen Walton
The sed provided by Solaris in /usr/xpg4/bin has a bug whereby an unanchored regex using * for zero or more repetitions sees two separate matches fed to the substitution engine in some cases. This is evidenced by: $ for sed in /usr/xpg4/bin/sed /usr/bin/sed /opt/csw/gnu/sed; do \ echo 'ab' | $sed -e 's|[a]*|X|g'; \ done XXbX XbX XbX This bug was triggered during a git submodule clone operation as exercised in the setup stage of t5526-fetch-submodules when using the default SANE_TOOL_PATH for Solaris. It led to paths such as ..../.. being used in the submodule .git gitdir reference. Using the expression 's|\([^/]*\(/*\)\)|..\2|g' provides the desired result with all three three tested sed implementations but is harder to read. As we do not need to handle fully qualified paths though, the expression could actually be [^/]+ which isn't properly handled either. Instead, use [^/][^/]*, as suggested by Andreas Schwab, which works on all three tested sed implementations. The new expression is semantically different than the original one. It will not place a leading '..' on a fully qualified path as the original expression did. All of the paths being passed through this regex are relative and did not rely on this behaviour so it's a safe change. Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-05submodules: fix ambiguous absolute paths under WindowsJohannes Sixt
Under Windows the "git rev-parse --git-dir" and "pwd" commands may return either drive-letter-colon or POSIX style paths. This makes module_clone() behave badly because it expects absolute paths to always start with a '/'. Fix that by always converting the "c:/" notation into "/c/" when computing the relative paths from gitdir to the submodule work tree and back. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-05submodules: refactor computation of relative gitdir pathJens Lehmann
In module_clone() the rel_gitdir variable was computed differently when "git rev-parse --git-dir" returned a relative path than when it returned an absolute path. This is not optimal, as different code paths are used depending on the return value of that command. Fix that by reusing the differing path components computed for setting the core.worktree config setting, which leaves a single code path for setting both instead of having three and makes the code much shorter. This also fixes the bug that in the computation of how many directories have to be traversed up to hit the root directory of the submodule the name of the submodule was used where the path should have been used. This lead to problems after renaming submodules into another directory level. Even though the "(cd $somewhere && pwd)" approach breaks the flexibility of symlinks, that is no issue here as we have to have one relative path pointing from the work tree to the gitdir and another pointing back, which will never work anyway when a symlink along one of those paths is changed because the directory it points to was moved. Also add a test moving a submodule into a deeper directory to catch any future breakage here and to document what has to be done when a submodule needs to be moved until git mv learns to do that. Simply moving it to the new location doesn't work, as the core.worktree and possibly the gitfile setting too will be wrong. So it has to be removed from filesystem and index, then the new location has to be added into the index and the .gitmodules file has to be updated. After that a git submodule update will check out the submodule at the new location. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-05submodules: always use a relative path from gitdir to work treeJens Lehmann
Since recently a submodule with name <name> has its git directory in the .git/modules/<name> directory of the superproject while the work tree contains a gitfile pointing there. To make that work the git directory has the core.worktree configuration set in its config file to point back to the work tree. That core.worktree is an absolute path set by the initial clone of the submodule. A relative path is preferable here because it allows the superproject to be moved around without invalidating that setting, so compute and set that relative path after cloning or reactivating the submodule. This also fixes a bug when moving a submodule around inside the superproject, as the current code forgot to update the setting to the new submodule work tree location. Enhance t7400 to ensure that future versions won't re-add absolute paths by accident and that moving a superproject won't break submodules. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-05submodules: always use a relative path to gitdirJens Lehmann
Since recently a submodule with name <name> has its git directory in the .git/modules/<name> directory of the superproject while the work tree contains a gitfile pointing there. When the submodule git directory needs to be cloned because it is not found in .git/modules/<name> the clone command will write an absolute path into the gitfile. When no clone is necessary the git directory will be reactivated by the git-submodule.sh script by writing a relative path into the gitfile. This is inconsistent, as the behavior depends on the submodule having been cloned before into the .git/modules of the superproject. A relative path is preferable here because it allows the superproject to be moved around without invalidating the gitfile. We do that by always writing the relative path into the gitfile, which overwrites the absolute path the clone command may have written there. This is only the first step to make superprojects movable again like they were before the separate-git-dir approach was introduced. The second step is to use a relative path in core.worktree too. Enhance t7400 to ensure that future versions won't re-add absolute paths by accident. While at it also replace an if/else construct evaluating the presence of the 'reference' option with a single line of bash code. Reported-by: Antony Male <antony.male@gmail.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-01-24submodule add: fix breakage when re-adding a deep submoduleJens Lehmann
Since recently a submodule with name <name> has its git directory in the .git/modules/<name> directory of the superproject while the work tree contains a gitfile pointing there. When the same submodule is added on a branch where it wasn't present so far (it is not found in the .gitmodules file), the name is not initialized from the path as it should. This leads to a wrong path entered in the gitfile when the .git/modules/<name> directory is found, as this happily uses the - now empty - name. It then always points only a single directory up, even if we have a path deeper in the directory hierarchy. Fix that by initializing the name of the submodule early in module_clone() if module_name() returned an empty name and add a test to catch that bug. Reported-by: Jehan Bing <jehan@orb.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-26Merge branch 'tc/submodule-clone-name-detection'Junio C Hamano
* tc/submodule-clone-name-detection: submodule::module_clone(): silence die() message from module_name() submodule: whitespace fix
2011-10-21submodule::module_clone(): silence die() message from module_name()Tay Ray Chuan
The die() message that may occur in module_name() is not really relevant to the user when called from module_clone(); the latter handles the "failure" (no submodule mapping) anyway. Analysis of other callsites is left to future work. Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-21submodule: whitespace fixTay Ray Chuan
Replace SPs with TAB. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-10Merge branch 'fg/submodule-git-file-git-dir'Junio C Hamano
* fg/submodule-git-file-git-dir: Move git-dir for submodules rev-parse: add option --resolve-git-dir <path> Conflicts: cache.h git-submodule.sh
2011-08-25Merge branch 'js/i18n-scripts'Junio C Hamano
* js/i18n-scripts: submodule: take advantage of gettextln and eval_gettextln. stash: take advantage of eval_gettextln pull: take advantage of eval_gettextln git-am: take advantage of gettextln and eval_gettextln. gettext: add gettextln, eval_gettextln to encode common idiom
2011-08-23Move git-dir for submodulesFredrik Gustafsson
Move git-dir for submodules into $GIT_DIR/modules/[name_of_submodule] of the superproject. This is a step towards being able to delete submodule directories without loosing the information from their .git directory as that is now stored outside the submodules work tree. This is done relying on the already existent .git-file functionality. When adding or updating a submodule whose git directory is found under $GIT_DIR/modules/[name_of_submodule], don't clone it again but simply point the .git-file to it and remove the now stale index file from it. The index will be recreated by the following checkout. This patch will not affect already cloned submodules at all. Tests that rely on .git being a directory have been fixed. Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com> Mentored-by: Jens Lehmann <Jens.Lehmann@web.de> Mentored-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-08Merge branch 'jl/submodule-update-quiet'Junio C Hamano
* jl/submodule-update-quiet: submodule: update and add must honor --quiet flag
2011-08-08submodule: take advantage of gettextln and eval_gettextln.Jon Seymour
Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>