Paul Smith <paul@xxxxxxxxxxxxxxxxx> writes: > Allow new workdirs to be created in an empty directory (similar to "git > clone"). Provide more error checking and clean up on failure. > > Signed-off-by: Paul Smith <paul@xxxxxxxxxxxxxxxxx> > --- > > Hopefully this doesn't contain unwanted stylistic changes. ;-) Unwanted, no, but unrelated yes. > > +failed () { > + die "unable to create new workdir \"$new_workdir\"!" > +} Use '$new_workdir' instead to match the existing message below? > -# don't recreate a workdir over an existing repository > -if test -e "$new_workdir" > +# make sure the links in the workdir have full paths to the original repo > +git_dir=$(cd "$git_dir" && pwd) || exit 1 > + > +# don't recreate a workdir over an existing directory, unless it's empty > +if test -d "$new_workdir" > then > - die "destination directory '$new_workdir' already exists." > + if test $(ls -a1 "$new_workdir/." | wc -l) -ne 2 > + then > + die "destination directory '$new_workdir' is not empty." > + fi > + cleandir="$new_workdir/.git" > +else > + cleandir="$new_workdir" > fi The comment in the original is somewhat misleading, but "test -e" was "test -e" and not "test -d" to stop when an existing file was given by mistake as $new_workdir, I think. I do not know what happens in the new code in that case. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html