git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Rostislav Krasny <rosti.bsd@gmail.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>,
	Rostislav Krasny <rosti.bsd@gmail.com>,
	git@vger.kernel.org
Subject: Re: Incorrect and inconsistent End-Of-Line characters in .gitmodules after "git submodule set-branch --branch <branch_name>"
Date: Sun, 18 Jul 2021 00:22:38 +0300	[thread overview]
Message-ID: <CANt7McHrYhSe3JsS8UKX8NgsUajwxQY4h9KTtXkEXdd0Be_+yw@mail.gmail.com> (raw)
In-Reply-To: <YPHgUuxqmKFkbEku@camp.crustytoothpaste.net>

On Fri, Jul 16, 2021 at 10:39 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2021-07-15 at 21:55:07, Rostislav Krasny wrote:
> > Hello,
> >
> > Originally this bug was reported in the Git for Windows project and
> > contains two screenshots:
> > https://github.com/git-for-windows/git/issues/3321
> > Johannes Schindelin (dscho) is convinced that this is not a
> > Windows-specific issue. Following is a brief description of this bug
> > as I've faced it:
> >
> > After running the "git submodule set-branch --branch master -- ms1"
> > I've noticed that the .gitmodules file is encoded with both DOS and
> > UNIX End-of-Line characters simultaneously: all original lines use DOS
> > EOL characters but the added "branch = master" line uses UNIX EOL.
>
> What behavior are you expecting to see here?  Are you expecting Git to
> write carriage returns when the file already uses carriage returns?
> What about when the file already contains mixed endings?

I expect it to be consistent, like the vi editor in the Git for
Windows distribution.

If the vi editor is used to create a new file or a file in the UNIX
EOL format it continues to use this format.
If the vi editor is used to edit an already existing file with the DOS
EOL format it continues to use that format.
Now if the "core.autocrlf" option is enabled (and in Git for Windows
it's enabled by default) all local copies of textual files are always
converted into the DOS format of EOL.

For example:

$ vi .gitignore
$ git add .gitignore
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory

> Are you committing CRLF line endings into the repository, or are they
> just created by core.autocrlf=true (or some .gitattributes setting)?

In Git for Windows "core.autocrlf=true" is the default configuration.

> Does this cause a functional problem with Git (or maybe another tool),
> or is it just aesthetically displeasing?

I don't know, at least in the vi editor it looks broken because of all
those '^M' symbols.

I would like to take this opportunity to ask: why cloning a repository
that contains submodules sets this repository branch to its default
(master, main, whatever) but all submodules are set into a detached
HEAD mode instead of their default branches? This is actually the
reason I started to check what happens with the .gitmodules file. What
is the point in such an inconsistent behavior? There are a lot of
questions about that in Google and it seems most of the users expect
different behavior.

  reply	other threads:[~2021-07-17 21:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 21:55 Incorrect and inconsistent End-Of-Line characters in .gitmodules after "git submodule set-branch --branch <branch_name>" Rostislav Krasny
2021-07-16 19:38 ` brian m. carlson
2021-07-17 21:22   ` Rostislav Krasny [this message]
2021-07-21  7:26     ` Why do submodules detach HEAD? (was Re: Incorrect and inconsistent End-Of-Line characters in .gitmodules ...) Atharva Raykar
2021-07-21 22:42       ` Philippe Blain
2021-08-05 13:59       ` Rostislav Krasny
2021-08-05 18:38         ` Atharva Raykar
2021-07-17 17:05 ` Incorrect and inconsistent End-Of-Line characters in .gitmodules after "git submodule set-branch --branch <branch_name>" Torsten =?unknown-8bit?Q?B=C3=B6gershausen?=
2021-07-17 22:42   ` Rostislav Krasny
2021-07-18  5:32     ` Torsten =?unknown-8bit?Q?B=C3=B6gershausen?=

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=CANt7McHrYhSe3JsS8UKX8NgsUajwxQY4h9KTtXkEXdd0Be_+yw@mail.gmail.com \
    --to=rosti.bsd@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sandals@crustytoothpaste.net \
    /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).