From: "Lars Hjemli" <hjemli@gmail.com>
To: "Junio C Hamano" <junkio@cox.net>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
git@vger.kernel.org
Subject: Re: [PATCH] Add git-submodule command
Date: Sat, 26 May 2007 11:39:22 +0200 [thread overview]
Message-ID: <8c5c35580705260239x4acf0318vfda3651fb315f8c5@mail.gmail.com> (raw)
In-Reply-To: <7v1wh4ped4.fsf@assigned-by-dhcp.cox.net>
On 5/26/07, Junio C Hamano <junkio@cox.net> wrote:
> Lars Hjemli <hjemli@gmail.com> writes:
>
> > With this entry in .gitmodules (and a commit reference in the index entry for
> > the path "git"), the command 'git submodule init' will clone the repository
> > at kernel.org into the directory "git".
> >
> > Signed-off-by: Lars Hjemli <hjemli@gmail.com>
> > ---
> >
> > On 5/26/07, Lars Hjemli <hjemli@gmail.com> wrote:
> >> I'll redo the patch, removing the branch-specific things, and try to
> >> shut up :)
>
> Hey, don't shut up. Starting small and covering corner cases
> incrementally is really the right approach.
Ok, my meds have kicked in and I'm ready for more ;-)
>
> > +status::
> > + Show the status of the submodules. This will print the sha1 of the
> > + currently checked out commit for each submodule, along with the
> > + submodule path and the output of gitlink:git-describe[1] for the
> > + sha1. Each sha1 will be prefixed with '-' if the submodule is not
> > + initialized and '+' if the currently checked out submodule commit
> > + does not match the sha1 found in the index of the containing
> > + repository. This command is the default command for git-submodule.
>
> (markup) probably you would want `` there for typewriter face.
Ok, will fix
>
> (wording) didn't we have "the name of the hash function is
> SHA-1" patch earlier? I'd personally prefer calling them
> "object names", though...
Some quick grepping wasn't helpfull:
~/src/git/Documentation$ git grep sha1 | wc -l
98
~/src/git/Documentation$ git grep SHA1 | wc -l
80
~/src/git/Documentation$ git grep SHA-1 | wc -l
22
Would you prefer SHA-1?
>
> Other than that, the command description is very nicely done,
> which means the design of the command set hence the semantics is
> cleanly done. Good job.
Thanks!
>
> > diff --git a/git-submodule.sh b/git-submodule.sh
> > new file mode 100755
> > index 0000000..247b1ee
> > --- /dev/null
> > +++ b/git-submodule.sh
> > @@ -0,0 +1,172 @@
> > ...
> > +#
> > +# print stuff on stdout unless -q was specified
> > +#
> > +say()
> > +{
> > + if test -z "$quiet"
> > + then
> > + echo -e "$@"
> > + fi
> > +}
>
> We tend to avoid "echo -e" (not POSIX). I do not see any string
> you feed to this function that you would _want_ backslash
> escaped sequences (actually I would suspect you would not want
> them).
I do use \t between submodule path and the result of git-describe, but
it's not really needed. I'll drop it.
>
> > +
> > +#
> > +# Run clone + checkout on missing submodules
> > +#
> > +# $@ = requested paths (default to all)
> > +#
> > +modules_init()
> > +{
> > + git ls-files --stage -- $@ | grep -e '^160000 ' |
>
> Did you mean "$@", i.e. inside double-quotes?
That looks right, yes
> > + test -d "$path/.git" && continue
> > +
> > + if test -d "$path"
> > + then
> > + rmdir "$path" 2>/dev/null ||
> > + die "Directory '$path' exist, but not as a submodule"
> > + fi
>
> Could the currently checked-out $path be a symlink to another
> directory, and what does the code do in such a case?
This I will have to test, but I _suspect_ it would fail on "test -e
path" _unless_ the "test -d $path/.git" kicks in.
>
> > +
> > + test -e "$path" &&
> > + die "A file already exist at path '$path'"
>
> "test -e" is a relatively new invention and I tended to stay
> away from it, but it should be safe to use these days...
Would you prefer separate -f and -l instead? Hmm, that would match up
nicely with your concern about symlinks ;-)
>
> > + url=$(GIT_CONFIG=.gitmodules git-config module."$path".url)
> > + test -z "$url" &&
> > + die "No url found for submodule '$path' in .gitmodules"
> > +
> > + git-clone "$url" "$path" ||
> > + die "Clone of submodule '$path' failed"
>
> "git-clone -n" please, as you will checkout something different
> in the next step anyway.
Nice, I hadn't noticed -n, will fix
>
> > +
> > + $(unset GIT_DIR && cd "$path" && git-checkout -q "$sha1") ||
> > + die "Checkout of submodule '$path' failed"
>
> Lose $() around this, as it is not producing a string which is
> the name of the command to run. You do want a subshell here
> because of chdir, so instead of losing $(), replace them with
> ().
Heh, there's always something new to learn on this list, thanks.
--
larsh
next prev parent reply other threads:[~2007-05-26 9:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-25 9:51 [PATCH] Add git-submodule command Lars Hjemli
2007-05-25 10:57 ` Johannes Schindelin
2007-05-25 12:24 ` Johannes Schindelin
2007-05-25 13:46 ` Lars Hjemli
2007-05-25 13:58 ` Johannes Schindelin
2007-05-25 14:16 ` Lars Hjemli
2007-05-25 14:47 ` Johannes Schindelin
2007-05-25 14:52 ` Lars Hjemli
2007-05-25 18:09 ` Lars Hjemli
2007-05-25 18:41 ` Johannes Schindelin
2007-05-25 19:31 ` Junio C Hamano
2007-05-25 20:29 ` Lars Hjemli
2007-05-25 20:52 ` Junio C Hamano
2007-05-25 22:01 ` Lars Hjemli
2007-05-26 0:17 ` Lars Hjemli
2007-05-26 0:48 ` Johannes Schindelin
2007-05-26 1:23 ` Junio C Hamano
2007-05-26 9:39 ` Lars Hjemli [this message]
2007-05-26 10:42 ` Johannes Schindelin
2007-05-26 13:56 ` Lars Hjemli
2007-05-26 14:37 ` Simon Hausmann
2007-05-26 14:48 ` Lars Hjemli
2007-05-25 20:30 ` Johannes Schindelin
2007-05-25 19:57 ` Linus Torvalds
2007-05-25 20:28 ` Johannes Schindelin
2007-05-25 22:33 ` 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=8c5c35580705260239x4acf0318vfda3651fb315f8c5@mail.gmail.com \
--to=hjemli@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=torvalds@linux-foundation.org \
/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: link
Be 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).