git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Joachim Durchholz <jo@durchholz.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Detect invalid submodule names from script?
Date: Mon, 17 Jul 2017 10:49:58 -0700	[thread overview]
Message-ID: <CAGZ79kYvup5yOqsgbphwvQe-2sKfXO3a8E1S548WLOXRp4SB_g@mail.gmail.com> (raw)
In-Reply-To: <41004589-4a98-2084-b542-51b7458f607b@durchholz.org>

On Mon, Jul 17, 2017 at 4:17 AM, Joachim Durchholz <jo@durchholz.org> wrote:
> Hi all
>
> I'm hacking some script that calls into git, and I need to detect whether a
> repository was configured with a submodule name that will work on "git
> submodule init" and friends.

There is no such a thing as "git submodule valid-name" unfortunately.
Looking through "git submodule add", I think it is safe to assume
that any string valid as a subsection in git-config is a valid submodule name.
Our man page says:

    Subsection names are case sensitive and can contain any characters
    except newline (doublequote " and backslash can be included by escaping
    them as \" and \\, respectively).

I am not sure about the quality of submodule shell code to handle the quotations
for double quote and backslash correctly, so I would suggest not using them,
either.

> I *can* run a git init and see whether it works, but I need to be 100% sure
> that the error was due to an invalid submodule name and not something else.
> Bonus points for every version of git for which it works.

I do not think Git offers a universal solution across versions except actually
running "submodule init" and then making an educated guess if the error
comes from bad naming or something else.

This sounds like you're taking user input or otherwise untrustworthy data
as submodule names?

Thanks,
Stefan

>
> Any suggestions?
> Thanks!
>
> Regards,
> Jo

  reply	other threads:[~2017-07-17 17:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 11:17 Detect invalid submodule names from script? Joachim Durchholz
2017-07-17 17:49 ` Stefan Beller [this message]
2017-07-17 18:31   ` Joachim Durchholz

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGZ79kYvup5yOqsgbphwvQe-2sKfXO3a8E1S548WLOXRp4SB_g@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --cc=jo@durchholz.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).