@@ -87,7 +87,7 @@ Perhaps git-update-server-info needs to be run there?"
8787
8888quiet=
8989local=no
90- use_local=no
90+ use_local_hardlink=yes
9191local_shared=no
9292unset template
9393no_checkout=
@@ -108,9 +108,13 @@ while
108108 no_checkout=yes ;;
109109 * ,--na|* ,--nak|* ,--nake|* ,--naked|\
110110 * ,-b|* ,--b|* ,--ba|* ,--bar|* ,--bare) bare=yes ;;
111- * ,-l|* ,--l|* ,--lo|* ,--loc|* ,--loca|* ,--local) use_local=yes ;;
111+ * ,-l|* ,--l|* ,--lo|* ,--loc|* ,--loca|* ,--local)
112+ use_local_hardlink=yes ;;
113+ * ,--no-h|* ,--no-ha|* ,--no-har|* ,--no-hard|* ,--no-hardl|\
114+ * ,--no-hardli|* ,--no-hardlin|* ,--no-hardlink|* ,--no-hardlinks)
115+ use_local_hardlink=no ;;
112116 * ,-s|* ,--s|* ,--sh|* ,--sha|* ,--shar|* ,--share|* ,--shared)
113- local_shared=yes; use_local=yes ;;
117+ local_shared=yes; ;;
114118 1,--template) usage ;;
115119 * ,--template)
116120 shift ; template=" --template=$1 " ;;
249253rm -f " $GIT_DIR /CLONE_HEAD"
250254
251255# We do local magic only when the user tells us to.
252- case " $local , $use_local " in
253- yes,yes )
256+ case " $local " in
257+ yes)
254258 ( cd " $repo /objects" ) ||
255- die " -l flag seen but repository '$repo ' is not local ."
259+ die " cannot chdir to local '$repo /objects' ."
256260
257- case " $local_shared " in
258- no)
259- # See if we can hardlink and drop "l" if not.
260- sample_file=$( cd " $repo " && \
261- find objects -type f -print | sed -e 1q)
262-
263- # objects directory should not be empty since we are cloning!
264- test -f " $repo /$sample_file " || exit
265-
266- l=
267- if ln " $repo /$sample_file " " $GIT_DIR /objects/sample" 2> /dev/null
268- then
269- l=l
270- fi &&
271- rm -f " $GIT_DIR /objects/sample" &&
272- cd " $repo " &&
273- find objects -depth -print | cpio -pumd$l " $GIT_DIR /" || exit 1
274- ;;
275- yes)
276- mkdir -p " $GIT_DIR /objects/info"
277- echo " $repo /objects" >> " $GIT_DIR /objects/info/alternates"
278- ;;
279- esac
261+ if test " $local_shared " = yes
262+ then
263+ mkdir -p " $GIT_DIR /objects/info"
264+ echo " $repo /objects" >> " $GIT_DIR /objects/info/alternates"
265+ else
266+ l= &&
267+ if test " $use_local_hardlink " = yes
268+ then
269+ # See if we can hardlink and drop "l" if not.
270+ sample_file=$( cd " $repo " && \
271+ find objects -type f -print | sed -e 1q)
272+ # objects directory should not be empty because
273+ # we are cloning!
274+ test -f " $repo /$sample_file " || exit
275+ if ln " $repo /$sample_file " " $GIT_DIR /objects/sample" 2> /dev/null
276+ then
277+ rm -f " $GIT_DIR /objects/sample"
278+ l=l
279+ else
280+ echo >&2 " Warning: -l asked but cannot hardlink to $repo "
281+ fi
282+ fi &&
283+ cd " $repo " &&
284+ find objects -depth -print | cpio -pumd$l " $GIT_DIR /" || exit 1
285+ fi
280286 git-ls-remote " $repo " > " $GIT_DIR /CLONE_HEAD" || exit 1
281287 ;;
282288* )
0 commit comments