Uploaded image for project: 'Sourcetree for Windows'
  1. Sourcetree for Windows
  2. SRCTREEWIN-1859

Undesired conversion of line endings of whole file when discarding selected lines (CR-LF to LF)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Low Low
    • 3.4.20
    • None
    • None
    • None
    • Windows 7 64-bit
      SourceTree 1.5.2.0

      When discarding selected changes from a file, either a hunk or selected line(s), SourceTree does the discard and then converts all linebreaks in the complete file from CRLF (Windows) to LF.

      Steps to Reproduce

      I used a fresh created repository so everyone should be able to reproduce the steps on the own computer.

      • Create new repository
      • Set autocrlf=false in .git/config to make sure the files are commited as-is.
      • Create a file with CRLF line endings, add some text in four or five lines.
        • Commit the file.
      • Now we need to use a clone where autocrlf=true. This is simply done by another change in .git/config manually. The effect is the same as cloning the repository on a machine where autocrlf=true globally.
      • Change a line in the file
      • In SourceTree, click on Discard Hunk

      Expected: The changes are simply discarded, no changes are in working copy.
      Actual: The changes are discarded, but all line endings have been converted to LF.

      Note that this does not happen when discarding the whole file.

      Comments on expectations

      You may state that the error is caused due to inconsistent use of autocrlf throughout the repository clones. But actions on my clone should be independent of what was checked in by others. I have clear expectations on the autocrlf functionality:

      • on checking out every LF is converted into CRLF
      • CRLF line endings are preserved (not converted into CRCRLF)
      • on commiting every CRLF is converted back into LF

      These auto-changes have impact on the actions checkout and commit. I do not expect SourceTree to mess with my working copy on discard actions other than the assigned task. Instead in the above case, I expect that SourceTree discards the hunk (or selected lines) and reinstates the content of the file which is currently in the repository. That leaves two possibilities how it can be done:

      1. reinstate the original content without regarding autocrlf, which could leave me (for LF formatted files) with LF endings – not desirable
      2. checkout the original content with autocrlf applying afterwards (LF to CRLF), which would give me the content but with CRLF line endings

      SourceTree does none of the above. Instead it seems to apply the reverse autocrlf action after discarding the changes. The contents are prepared for a commit (everything in LF), where I expect the contents prepared to as after a checkout (everything in CRLF).

      Additional comments

      This issue is the same as SRCTREEWIN-988 which was closed with "resolved locally" or (in my understanding) "cannot reproduce" by a developer. So I tried to provide the steps that use a fresh repository. Please ask if questions are left.

      Also SRCTREEWIN-1635 seems to describe this bug, but misses the exact circumstances. It was stated as an error with SVN to Git conversion and no further reason was declared. This is not valid here because I used a new repository.

              sstreeting Steve Streeting (Inactive)
              466dc0e9a716 Rainer Grabbe
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: