Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. View files at specific git revisions in Qt Creator
Forum Updated to NodeBB v4.3 + New Features

View files at specific git revisions in Qt Creator

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 2 Posters 609 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SuperSelrak
    wrote on 20 Feb 2023, 14:36 last edited by SuperSelrak
    #1

    Hello, I want to view specific file revisions as per Git in Qt Creator.

    Git is integrated in Qt Creator but there is no command to do that as far as I can tell.

    In Git I would type :

    git show <revision>:<path/to/file.ext>

    A specific pager can be set for git show, but Qt Creator cannot receive the standard output directly (can it ?). Therefore I created a specific Git command where I dumped the output of git show to an aptly-named temp file and opened that in Qt Creator, then deleted it (thanks to Qt Creator's -block argument)

    In my .gitconfig :

    showq = "!f() { tmp=$(echo "$1")_$(basename $2) ; git show $1:$2 > "$tmp" ; /c/Tool/DasteWinEnv3.0/Qt/Tools/QtCreator/bin/qtcreator.exe -block "$tmp" ; rm "$tmp";}; f"
    

    This has one drawback : If the Qt Creator instance that I have open is found (which is what I want), it won't come in focus (rather, the Qt Creator icon in the taskbar will simply blink). If the instance isn't found (which happens but which I don't wnat, see other question) then a new one opens, and at least comes in focus.

    Can I get the best of both worlds ?

    Any other, better ideas ?

    A 1 Reply Last reply 8 Feb 2024, 20:46
    0
    • S SuperSelrak
      20 Feb 2023, 14:36

      Hello, I want to view specific file revisions as per Git in Qt Creator.

      Git is integrated in Qt Creator but there is no command to do that as far as I can tell.

      In Git I would type :

      git show <revision>:<path/to/file.ext>

      A specific pager can be set for git show, but Qt Creator cannot receive the standard output directly (can it ?). Therefore I created a specific Git command where I dumped the output of git show to an aptly-named temp file and opened that in Qt Creator, then deleted it (thanks to Qt Creator's -block argument)

      In my .gitconfig :

      showq = "!f() { tmp=$(echo "$1")_$(basename $2) ; git show $1:$2 > "$tmp" ; /c/Tool/DasteWinEnv3.0/Qt/Tools/QtCreator/bin/qtcreator.exe -block "$tmp" ; rm "$tmp";}; f"
      

      This has one drawback : If the Qt Creator instance that I have open is found (which is what I want), it won't come in focus (rather, the Qt Creator icon in the taskbar will simply blink). If the instance isn't found (which happens but which I don't wnat, see other question) then a new one opens, and at least comes in focus.

      Can I get the best of both worlds ?

      Any other, better ideas ?

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 8 Feb 2024, 20:46 last edited by
      #2

      Hi @SuperSelrak,

      I know this answer comes late, but what you want is possible in the file log (Tools > Git > Current File > Log, or Alt+G Alt+L) and then right click on the revision, selecting "Show file xxx on revision yyy".

      Regards

      Qt has to stay free or it will die.

      S 1 Reply Last reply 2 Oct 2024, 16:46
      1
      • A aha_1980
        8 Feb 2024, 20:46

        Hi @SuperSelrak,

        I know this answer comes late, but what you want is possible in the file log (Tools > Git > Current File > Log, or Alt+G Alt+L) and then right click on the revision, selecting "Show file xxx on revision yyy".

        Regards

        S Offline
        S Offline
        SuperSelrak
        wrote on 2 Oct 2024, 16:46 last edited by
        #3

        @aha_1980 Good one, but 1. I want to be able to do this from the Git Bash however I want and 2. speaking of however I want to git log view only shows the parent of the current HEAD, in my case I often precisely want to see how the file looks like on an unrelated branch or something.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 3 Oct 2024, 16:44 last edited by
          #4

          Regarding 2: That is a good point, I've pushed https://codereview.qt-project.org/c/qt-creator/qt-creator/+/595464 to allow showing a log for all branches. That should solve your problem.

          Regarding 1: Have you alread tried adding the -client-Option?

          Attempt to connect to already running first instance
          

          Regards

          Qt has to stay free or it will die.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved