Hi all, in GNU sed I want to attach each commit with an exact version of gnulib, because otherwise the bootstrapping shell script (used to compile a decent sed without using configure) most likely won't work.
This is a natural use case for git's submodule feature; the attached patch makes the bootstrap script use submodules to check out gnulib. To enable it, you just have to use rm -fr gnulib git submodule add git://git.sv.gnu.org/gnulib.git gnulib git submodule init git submodule update and commit the result. Actually, after the patch it's enough that you rerun bootstrap (possibly with --gnulib-srcdir, more on this later) after the first two commands above. As part of the release, or when one has time to spare, one must remember to do also cd gnulib git checkout master git pull cd .. git commit -a -m'update gnulib tip' The patch supports --gnulib-srcdir too; in that case clones will use the global URL for gnulib will remain the one registered in the project, typically git://git.sv.gnu.org/gnulib.git, but the checked out copy will use the path specified for --gnulib-srcdir. In this case --gnulib-srcdir should point to a full clone, not just a shallow one or a copy without the .git metadata. Tested on sed's repository. Ok? Paolo 2008-09-29 Paolo Bonzini <[EMAIL PROTECTED]> * build-aux/bootstrap: Use git's submodules if the project includes a registered submodule named gnulib.
diff --git a/build-aux/bootstrap b/build-aux/bootstrap index 3c0de90..7a66cd3 100755 --- a/build-aux/bootstrap +++ b/build-aux/bootstrap @@ -233,11 +233,20 @@ cleanup_gnulib() { exit $status } +git_modules_config () { + GIT_CONFIG_LOCAL=.gitmodules git config "$@" +} + # Get gnulib files. case ${GNULIB_SRCDIR--} in -) - if [ ! -d gnulib ]; then + if git_modules_config submodule.gnulib.url >/dev/null; then + echo "$0: getting gnulib files..." + git submodule init || exit $@ + git submodule update || exit $@ + + elif [ ! -d gnulib ]; then echo "$0: getting gnulib files..." trap cleanup_gnulib 1 2 13 15 @@ -248,6 +257,19 @@ case ${GNULIB_SRCDIR--} in trap - 1 2 13 15 fi GNULIB_SRCDIR=gnulib + ;; +*) + # Redirect the gnulib submodule to the directory on the command line + # if possible. + if test -d $GNULIB_SRCDIR/.git && \ + git_modules_config submodule.gnulib.url >/dev/null; then + git submodule init + git config --replace-all submodule.gnulib.url "`cd $GNULIB_SRCDIR && pwd`" + echo "$0: getting gnulib files..." + git submodule update || exit $@ + GNULIB_SRCDIR=gnulib + fi + ;; esac gnulib_tool=$GNULIB_SRCDIR/gnulib-tool