Skip to content

Commit

Permalink
Make "git clone" a lot more user-friendly
Browse files Browse the repository at this point in the history
This silently adds the ".git" directory component if needed, so you
don't need to state it explicitly for the source.  Also, it turns the
source into an absolute pathname when local, so that you can use
relative pathnames without losing sight of the source when we cd into
the destination.
  • Loading branch information
Linus Torvalds committed Jul 8, 2005
1 parent 51cb06c commit ba375ac
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions git-clone-script
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ usage() {
exit 1
}

get_repo_base() {
(cd "$1" && (cd .git ; pwd)) 2> /dev/null
}

use_local=no
while
case "$#,$1" in
Expand All @@ -22,7 +26,15 @@ do
shift
done

# Turn the source into an absolute path if
# it is local
repo="$1"
local=no
if base=$(get_repo_base "$repo"); then
repo="$base"
local=yes
fi

dir="$2"
mkdir "$dir" &&
D=$(
Expand All @@ -31,8 +43,8 @@ D=$(
test -d "$D" || usage

# We do local magic only when the user tells us to.
case "$use_local" in
yes)
case "$local,$use_local" in
yes,yes)
( cd "$repo/objects" ) || {
repo="$repo/.git"
( cd "$repo/objects" ) || {
Expand Down

0 comments on commit ba375ac

Please sign in to comment.