git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michal Suchánek" <msuchanek@suse.de>
To: git@vger.kernel.org
Subject: Re: Getting rid of "hint: Using 'master' as the name for the initial branch." when not initializing a repository with pygit
Date: Tue, 1 Feb 2022 20:59:13 +0100	[thread overview]
Message-ID: <20220201195913.GV3113@kunlun.suse.cz> (raw)
In-Reply-To: <20220201184128.GT3113@kunlun.suse.cz>

On Tue, Feb 01, 2022 at 07:41:28PM +0100, Michal Suchánek wrote:
> Hello,
> 
> I am running some tests of a project that uses pygit, and the test
> creates a test repository .. using pygit.
> 
> I noticed that in some environments the default branch warning is
> displayed and not others because the git version varies.
> 
> The warning is just noise in the test log so I would like to avoid it,
> and I would like to find a solution that works for git that predates the
> introduction of this warning and the option to silence it as well as
> the future git versions in which the default is subject to change.
> 
> AFAICT there is no clean way to do it. I can set up the global option to
> whatever but I don't want to do that just to run tests.
> 
> I could set the repo local option but before calling
> pygit2.init_repository() there is no repository to configure, and after
> it is too late because I expect the message to be printed by this call.
> 
> Also I cannot rely on pygit to have some latest bells and whistles
> because like git it varies across environments and the whole point of
> running the test in different environments is to verify that it works
> with whatever tool versions are avaialble there.

Actually, I found that the code uses a mix of pygit2 and direct git
calls, and it's the direct call to git init that prints the warning
which can be fixed trivially by using pygit:
@@ -460,7 +460,7 @@ class TestMergeTool(unittest.TestCase):
         self.ks_dir = tempfile.mkdtemp(prefix="gs_ks")
         os.chdir(self.ks_dir)
 
-        subprocess.check_call(("git", "init", "./",), stdout=subprocess.DEVNULL)
+        pygit2.init_repository("./")
         subprocess.check_call(
             ("git", "config", "--add", "mergetool.git-sort.cmd",
              "%s $LOCAL $BASE $REMOTE $MERGED" % (

which begs the question how would I fix it if I was not using pygit. The
git version that does not produce the warning also does not support -b
so it cannot be be universally used with git init. Is there some
reasonable waey to detect this?

Thanks

Michal

      parent reply	other threads:[~2022-02-01 19:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 18:41 Getting rid of "hint: Using 'master' as the name for the initial branch." when initializing a repository with pygit Michal Suchánek
2022-02-01 19:52 ` Taylor Blau
2022-02-01 20:02   ` Michal Suchánek
2022-02-01 20:15     ` Taylor Blau
2022-02-01 19:59 ` Michal Suchánek [this message]

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=20220201195913.GV3113@kunlun.suse.cz \
    --to=msuchanek@suse.de \
    --cc=git@vger.kernel.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).