Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-13782

"Revert Chunk" of Git Diff fails due to wrong -p argument

    XMLWordPrintable

Details

    • 18b1d9270d49a49c713cf75dffad9cdcf3a93edd

    Description

      Steps to reproduce:

      1. Open a file in a Git repository
      2. Make a modification (anything)
      3. Get the diff (e.g., Alt+G, D)
      4. Right-click on the chunk, select Revert Chunk
      5. Confirm

      Expected result: the reversal succeeds and the change is backed out of the repository.

      Actual result: the change remains, the "General Messages" pane shows:

      "/usr/bin/patch" failed (exit code 1).
      Executing in /home/thiago/src/qt/qt5/qtbase: /usr/bin/patch -p0 -R
      can't find file to patch at input line 3
      Perhaps you used the wrong -p or --strip option?
      The text leading up to this was:
      --------------------------
      |--- w/src/dbus/qdbusintegrator.cpp
      |+++ w/src/dbus/qdbusintegrator.cpp
      --------------------------
      

      Note how the patch has a "w/" that shouldn't be there. To get away from it, one would need to use -p1, but Creator psased -p0 to patch.

      It's possible that Creator assumes that Git always prints "a/" and "b/", which is an incorrect assumption. From git-config(1):

             diff.mnemonicprefix
                 If set, git diff uses a prefix pair that is different from the standard "a/" and "b/" depending on what is being
                 compared. When this configuration is in effect, reverse diff output also swaps the order of the prefixes:
      
                 git diff
                     compares the (i)ndex and the (w)ork tree;
      
                 git diff HEAD
                     compares a (c)ommit and the (w)ork tree;
      
                 git diff --cached
                     compares a (c)ommit and the (i)ndex;
      
                 git diff HEAD:file1 file2
                     compares an (o)bject and a (w)ork tree entity;
      
                 git diff --no-index a b
                     compares two non-git things (1) and (2).
      
             diff.noprefix
                 If set, git diff does not show any source or destination prefix.
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            thiago Thiago Macieira
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes