<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJzdVW1vmzAQ_jXwxQoiBvLygQ9pSTakLqmSqPsYOdgQr8Zm2KTLv98Zki5pujetmrRJFnC-8_nu4Z67raKHeJIbVqO6kZLLAmWCyKKXq7okBimJygPKuWAOvkVEUmR2TKKCm965nVWmDh6WqGYZ43vrhyDKdVazisjs4KHuEr1TtUFc7pk2vCCGK2nPcoOEUo8aCf7I7BWXUfQEl0wjVVl7VCrKcw6ytbOhIdUYzSm883av4HuIsQYHzHP8xPEn3XNlWAWnFARZ1Yo2GUMOHkmFvIvbumzHTnA85gz84-pEHKIMzJxgij4cZmDs7TqNJCXTFQG35UHqo_XwpvtgsiltVlrDqakVnlUIzdLlag1AnOTV9HYxT8421u_T5bl8t5i_2yzu1-livlkvNpOHRZpsPi4n9_cpKCarTbpcTu-mD5P5-hRH4gQ352jYne4jmiZnqV0D7wRJAGiMXqR7AuLF7iVai8ZUjfkelr-H2Av9X4ftGbDLJKZfKpYZRm0Z_je5_jDj7pkC7YcaQVIs40SIAwJWbQWDwuEZggo6khEYJdTTidpc_4xYb0Wqa8xeQe0atzdG7opS_Jdo9K_2EkjG_nFC6StpOtENLGi6IfRda3aJzGfU60Frz6H5gmkCC0wHsBDLdgq-cSr3RHCKuhMGxgxsHqvxWnVZZC6NAzoOxsQljYExFJO6UFCPTLhNLeKdMVVbmngGC4LbNVsvUyUIQuxPrx6U-CdgO4hc6wZ6I55FeDwO3F0ckqwfDMMoj-g29IP-IMQBw34-igZ9P8TEFWTLhI4tChhL9oRaFzaDKHH_PAIeYx9jH-7qj6JxEHkkp3gYZtvh0KdZPho4oQ_k5MKzfjxVF24dty63TaFBKbg2-psSyosXkrE2YIjQcCNY_NpgrlmpYKLDyLfy-TjmRneD2G2DjdtIvwKp53Dj>52993</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-format -lines removes a line outside of its range
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          argothiel
      </td>
    </tr>
</table>

<pre>
    After running clang-format on my file, and then git-clang-format, I'm receiving a discrepancy. After short investigation, it looks like the clang-format -lines option modifies the file outside of the given range.

Steps to reproduce (no .clang-format file):
```
$ cat > MyFile.h
namespace myns
{
enum class MyEnum {
  FIRST,
  SECOND,
  THIRD,
  LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};

}
^D
$ clang-format -lines=3:8 MyFile.h
$ cat MyFile.h
```
Output:
```
namespace myns
{
enum class MyEnum
{
  FIRST,
  SECOND,
  THIRD,
  LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};
}
```
Expected output:
```
namespace myns
{
enum class MyEnum
{
  FIRST,
  SECOND,
  THIRD,
  LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};

}
```

It's especially problematic for the git flow like this:
```
$ cat MyFile.h
namespace myns
{
enum class MyEnum {
    FIRST,
    SECOND,
    THIRD,
    LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};

}
$ clang-format -i MyFile.h
$ cat MyFile.h
namespace myns
{
enum class MyEnum {
  FIRST,
  SECOND,
  THIRD,
  LONG_OPTION_TO_AVOID_WRAPPING_AS_IRRELEVANT
};

}
$ git add MyFile.h
$ [[ $(git clang-format -q --diff) ]] && echo "Invalid formatting"
Invalid formatting
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdVVtv2jAU_jXJi0UUHG55yANtYIvUQQWoe0TGdoJXx85ih45_v2MCLZTuJlWTNslyfHyO7fN9OZeNZvtknFteo7pRSqgCUUlU0cl1XRKLtELlHuVCcg_fIqIYsluuUCFs59zOKTMPD0tUc8rFzt1DEBOG1rwiiu4D1D5itrq2SKgdN1YUxAqt3FlhkdT60SApHrl74tKLjhSKG6QrZ49KzUQuQHZ2zjWkG2sEg29-2CvEDnys4QIeeGHqheN2XlpewSkNTla1Zg3lyMMjpVFw8VqLNvai4zFvEB5HK-IeomDmRRP0aT8F42DbahQpuakIXFvulTlaD2_aBVdN6VAZA6cmTnhWITTNFssVEHGSl5Pb-Sw921h9zBbn8t189mE9v19l89l6NV-PH-ZZuv68GN_fZ6AYL9fZYjG5mzyMZ6uTH6kX3Zyz4XbaRX-SnkG7Jt6L0gjYGL2CeyLi1e4lW_PGVo39EZd_xtgr_V-n7ZmwSxCTbxWnljMXhv8N1p8ibucM0n5oEIDiVBAp9wiyaiM5BI6gCCLomIyQUVI_nVJbmF8l1nsl1TVnb7B2zds7M3eVUuK30uhfrSUAxv1xwtgbML3-DQwouj2ou87skpmvqNOB0p5D8QXTFAaYDmAgTrca1jhTOyIFQ-0JC20GNo_ReK26DDKfJRGLo5j4VljJk7c6TM1LDa0JepeTz_uKsKbtKH5Ty2RrbXWIYzyFAUi2zSagugRByt3p04F8-AKlAURhTAOFFE_7OI4jf5vk3TgfDCnHPO5hFvWjzSjGNM97A8a7oyj0JdlwaRJHGcaKP6HDFQ5uP_VFgkOMw27Y6476cdQPSM7wsEc3w2HIaD4aeL0Q8lDIwPkR6Lrw6-Tg0qYpDCilMNa8KCGSRKE4PzwH95PGQqNOSF1oyFgu_cPjycH573CEXE8">