From: Lars Hjemli <hjemli@gmail.com> To: Junio C Hamano <junkio@cox.net> Cc: git@vger.kernel.org Subject: [PATCH 1/2] git-submodule: move cloning into a separate function Date: Tue, 5 Jun 2007 11:29:11 +0200 [thread overview] Message-ID: <11810357522478-git-send-email-hjemli@gmail.com> (raw) Message-ID: <863f2ca67857bc2d09f46f1a5ef6f653d16d5256.1181034736.git.hjemli@gmail.com> (raw) In-Reply-To: <11810357523435-git-send-email-hjemli@gmail.com> This is just a simple refactoring of modules_init() with no change in functionality. Signed-off-by: Lars Hjemli <hjemli@gmail.com> --- git-submodule.sh | 44 ++++++++++++++++++++++++++++---------------- 1 files changed, 28 insertions(+), 16 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 6ed5a6c..a89ea88 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -25,6 +25,33 @@ say() fi } + +# +# Clone a submodule +# +module_clone() +{ + path=$1 + url=$2 + + # If there already is a directory at the submodule path, + # expect it to be empty (since that is the default checkout + # action) and try to remove it. + # Note: if $path is a symlink to a directory the test will + # succeed but the rmdir will fail. We might want to fix this. + if test -d "$path" + then + rmdir "$path" 2>/dev/null || + die "Directory '$path' exist, but is neither empty nor a git repository" + fi + + test -e "$path" && + die "A file already exist at path '$path'" + + git-clone -n "$url" "$path" || + die "Clone of submodule '$path' failed" +} + # # Run clone + checkout on missing submodules # @@ -40,20 +67,6 @@ modules_init() # repository test -d "$path"/.git && continue - # If there already is a directory at the submodule path, - # expect it to be empty (since that is the default checkout - # action) and try to remove it. - # Note: if $path is a symlink to a directory the test will - # succeed but the rmdir will fail. We might want to fix this. - if test -d "$path" - then - rmdir "$path" 2>/dev/null || - die "Directory '$path' exist, but is neither empty nor a git repository" - fi - - test -e "$path" && - die "A file already exist at path '$path'" - url=$(GIT_CONFIG=.gitmodules git-config module."$path".url) test -z "$url" && die "No url found for submodule '$path' in .gitmodules" @@ -69,8 +82,7 @@ modules_init() # logical modulename (if present) as key. But this would need # another fallback mechanism if the module wasn't named. - git-clone -n "$url" "$path" || - die "Clone of submodule '$path' failed" + module_clone "$path" "$url" || exit $? (unset GIT_DIR && cd "$path" && git-checkout -q "$sha1") || die "Checkout of submodule '$path' failed" -- 1.5.2.841.gc9eafb
WARNING: multiple messages have this Message-ID (diff)
From: Lars Hjemli <hjemli@gmail.com> To: Junio C Hamano <junkio@cox.net> Cc: Johannes Sixt <J.Sixt@eudaptics.com>, git@vger.kernel.org Subject: [PATCH 1/2] git-submodule: move cloning into a separate function Date: Wed, 6 Jun 2007 11:13:01 +0200 [thread overview] Message-ID: <1181121182725-git-send-email-hjemli@gmail.com> (raw) Message-ID: <863f2ca67857bc2d09f46f1a5ef6f653d16d5256.1181034736.git.hjemli@gmail.com> (raw) In-Reply-To: <7vira15uon.fsf@assigned-by-dhcp.cox.net> This is just a simple refactoring of modules_init() with no change in functionality. Signed-off-by: Lars Hjemli <hjemli@gmail.com> --- On 6/6/07, Junio C Hamano <junkio@cox.net> wrote: > This seems to be WS munged by your mailer. Ouch, I didn't notice... git-submodule.sh | 44 ++++++++++++++++++++++++++++---------------- 1 files changed, 28 insertions(+), 16 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 6ed5a6c..a89ea88 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -25,6 +25,33 @@ say() fi } + +# +# Clone a submodule +# +module_clone() +{ + path=$1 + url=$2 + + # If there already is a directory at the submodule path, + # expect it to be empty (since that is the default checkout + # action) and try to remove it. + # Note: if $path is a symlink to a directory the test will + # succeed but the rmdir will fail. We might want to fix this. + if test -d "$path" + then + rmdir "$path" 2>/dev/null || + die "Directory '$path' exist, but is neither empty nor a git repository" + fi + + test -e "$path" && + die "A file already exist at path '$path'" + + git-clone -n "$url" "$path" || + die "Clone of submodule '$path' failed" +} + # # Run clone + checkout on missing submodules # @@ -40,20 +67,6 @@ modules_init() # repository test -d "$path"/.git && continue - # If there already is a directory at the submodule path, - # expect it to be empty (since that is the default checkout - # action) and try to remove it. - # Note: if $path is a symlink to a directory the test will - # succeed but the rmdir will fail. We might want to fix this. - if test -d "$path" - then - rmdir "$path" 2>/dev/null || - die "Directory '$path' exist, but is neither empty nor a git repository" - fi - - test -e "$path" && - die "A file already exist at path '$path'" - url=$(GIT_CONFIG=.gitmodules git-config module."$path".url) test -z "$url" && die "No url found for submodule '$path' in .gitmodules" @@ -69,8 +82,7 @@ modules_init() # logical modulename (if present) as key. But this would need # another fallback mechanism if the module wasn't named. - git-clone -n "$url" "$path" || - die "Clone of submodule '$path' failed" + module_clone "$path" "$url" || exit (unset GIT_DIR && cd "$path" && git-checkout -q "$sha1") || die "Checkout of submodule '$path' failed" -- 1.5.2.841.gc9eafb
next prev parent reply other threads:[~2007-06-05 9:27 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-06-05 9:29 [PATCH 0/2] git-submodule: make it easier to use alternate urls Lars Hjemli [not found] ` <863f2ca67857bc2d09f46f1a5ef6f653d16d5256.1181034736.git.hjemli@gmail.com> 2007-06-05 9:29 ` Lars Hjemli [this message] 2007-06-05 10:40 ` [PATCH 1/2] git-submodule: move cloning into a separate function Johannes Sixt 2007-06-05 11:13 ` Lars Hjemli 2007-06-06 8:55 ` Junio C Hamano 2007-06-17 14:38 ` Sven Verdoolaege 2007-06-17 15:56 ` Lars Hjemli 2007-06-06 9:13 ` Lars Hjemli [not found] ` <c14730acf8a52a57250303c033ebec09bf960007.1181034736.git.hjemli@gmail.com> 2007-06-05 9:29 ` [PATCH 2/2] git-submodule: clone during update, not during init Lars Hjemli 2007-06-05 11:18 ` Lars Hjemli 2007-06-06 9:13 ` Lars Hjemli
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=11810357522478-git-send-email-hjemli@gmail.com \ --to=hjemli@gmail.com \ --cc=git@vger.kernel.org \ --cc=junkio@cox.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).