Skip to main content

End of line in Git

Initially we had SVN, but then migrated to Git. Actually we had no idea about end of line issue, because we always worked on Windows. After some time we've noticed that specific commits changed the whole file, though some diff tools insisted that there are no differences.

First of all, it occurred that the order of revisions in git diff is important. It misled us, we started to think that those commits changed LF -> CRLF.
Finally,
git diff <parent_commit> <child_commit> --ws-error-highlight=new,old -- FileName.java
revealed the truth:



















Now we are thinking should we stay with "Windows-style everywhere" or migrate to "commit Unix-style".


Points to consider:
  1. There are tons of holly wars, but I couldn't find recommendation from Git. But it provides a way to change behavior.
  2. There is recommendation from GitHub to use LF in repository.
  3. Windows for git has three options, but neither one of them enforces CRLF. Though it is possible to enforce LF. If we use checkout as-is and commit as-is, there is always a chance that some developer has another setting.

Comments

Popular posts from this blog

Android Support Library + Maven + Eclipse

Допустим, мы хотим ActionBar в нашем android приложении. Но минимальная версия, которую мы хотим поддерживать, 2.3, и никакого ActionBar там ещё нет. Android Support Library позволяет использовать некоторые новые компоненты в старых версиях. В данном случае нам нужна Android Support Library  v7 appcompat. 1. Такой dependency в репозитории нет.  Maven Android SDK Deployer  позволяет помещать в локальный репозиторий dependency из локальной Android SDK. Если мы разрабатываем для android-4.3, то можем сгенерировать артефакты только для этой версии: mvn install -P 4.3 Кажется, для этого потребуется установить и версию sdk - 17. Если maven install упадет с ошибкой, то там будет написана причина. Если зайти в локальный репозиторий, то там появятся артефакты в папке: .m2\repository\android\support\compatibility-v7-appcompat\18 2. Подключим зависимости в pom.xml нашего app: <dependency> <groupId>android.support</groupId> <artifactId>compati...

Блочный, строчный, ...

Сборник советов: 1. Прижать элемент к нижнему краю контейнера: 2 . Две колонки: 3 . Что означает символ ">" в селекторе? Означает, что будут выбраны только прямые потомки. По-умному, direct descendant combinator. Иными словами, если есть: То "div a {color: blue;}" изменит цвет всех ссылок, а "div > a {color: blue;}" - только первой и третьей. 4 . TODO

Hibernate

1. Hibernate Session . Javadoc называет её главным интерфейсом между java-приложением и Hibernate. Иногда её называют единицей работы или логической транзакцией. Основная функция сессии - обеспечить операции создания, чтения, удаления объектов. Объекты могут находиться в одном из 3 состояний (см. 2) Сессия создается с помощью SessionFactory. SessionFactory знает конфигурацию ORM, её внутреннее состояния immutable. При вызове Configuration().configure() загружается файл hibernate.cfg.xml. После того, как конфигурация загружена, можно изменить настройки программно. Данные корректировки возможны только до создания экземпляра фабрики сессий. // Initialize the Hibernate environment Configuration cfg = new Configuration().configure(); // Create the session factory ServiceRegistryBuilder srb = new ServiceRegistryBuilder(); ServiceRegistry sr = srb.applySettings(cfg.getProperties()).buildServiceRegistry(); SessionFactory factory = cfg.buildSessionFactory(sr); // Obtain the new session obj...