View files at specific git revisions in Qt Creator
-
wrote on 20 Feb 2023, 14:36 last edited by SuperSelrak
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 ofgit 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 ?
-
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 ofgit 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 ?
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
-
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
wrote on 2 Oct 2024, 16:46 last edited by@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.
-
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