{"thread":{"id":"8670","subject":"[RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","startedAt":"2007-06-21T04:53:33Z","lastAt":"2007-06-22T08:02:58Z","messageCount":8,"participants":["Shawn O. Pearce","Junio C Hamano","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"45464","messageId":"20070621045333.GB13977@spearce.org","threadId":"8670","inReplyTo":null,"subject":"[RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-06-21T04:53:33Z","receivedAt":"2007-06-21T04:53:33Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jakub Narebski proposed the idea of having a new --gui option for\ngit-blame that would start `git gui blame` with the arguments that\nwere given to git-blame on the command line.  This actually makes\na lot of sense, as some users may first reach for `git blame` and\nfind the handy `--gui` option, rather than looking for the blame\nsubcommand of `git gui`.\n\nTo keep things really simple in git-blame we require that the new\n--gui option be the first argument on the command line, and cannot\nbe combined with any other option.  If it is the first argument\nthen we punt our entire command line as-is into `git gui blame`,\nwhere that program's option parser will handle selecting out the\nrevision and path, if present.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n From Jakub Narebski <jnareb@gmail.com>:\n > or have \"git blame --gui\" invoke \"git gui blame\"\n\n Not a bad idea.  Here's an implementation that does that.\n Its simple and not very intrusive, but has the odd behavior that\n no option (like --contents) can be used along with it, because\n git-gui's own blame subcommand doesn't recognize them.  On the\n other hand it is a useful DWIMery for `git gui blame`.\n\n\n Documentation/git-blame.txt |    8 ++++++++\n builtin-blame.c             |   12 +++++++++++-\n 2 files changed, 19 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt\nindex 66f1203..96ff02d 100644\n--- a/Documentation/git-blame.txt\n+++ b/Documentation/git-blame.txt\n@@ -10,6 +10,7 @@ SYNOPSIS\n [verse]\n 'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]\n             [-S <revs-file>] [-M] [-C] [-C] [--since=<date>]\n+            [--gui]\n             [<rev> | --contents <file>] [--] <file>\n \n DESCRIPTION\n@@ -67,6 +68,13 @@ include::blame-options.txt[]\n \tIgnore whitespace when comparing parent's version and\n \tchild's to find where the lines came from.\n \n+--gui::\n+\tInstead of displaying the blame output on the text console,\n+\tstart git-gui's graphical blame viewer.  This option must\n+\tbe the first option supplied, and cannot be combined with\n+\tany other option described here, except the optional <rev>\n+\tand the required <file> arguments.\n+\n \n THE PORCELAIN FORMAT\n --------------------\ndiff --git a/builtin-blame.c b/builtin-blame.c\nindex f7e2c13..2f50a4a 100644\n--- a/builtin-blame.c\n+++ b/builtin-blame.c\n@@ -18,9 +18,10 @@\n #include \"cache-tree.h\"\n #include \"path-list.h\"\n #include \"mailmap.h\"\n+#include \"exec_cmd.h\"\n \n static char blame_usage[] =\n-\"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\\n\"\n+\"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [--gui] [commit] [--] file\\n\"\n \"  -c                  Use the same output mode as git-annotate (Default: off)\\n\"\n \"  -b                  Show blank SHA-1 for boundary commits (Default: off)\\n\"\n \"  -l                  Show long commit SHA1 (Default: off)\\n\"\n@@ -34,6 +35,7 @@ static char blame_usage[] =\n \"  -L n,m              Process only line range n,m, counting from 1\\n\"\n \"  -M, -C              Find line movements within and across files\\n\"\n \"  --incremental       Show blame entries as we find them, incrementally\\n\"\n+\"  --gui               Use git-gui's graphical blame viewer\\n\"\n \"  --contents file     Use <file>'s contents as the final image\\n\"\n \"  -S revs-file        Use revisions from revs-file instead of calling git-rev-list\\n\";\n \n@@ -2137,6 +2139,12 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \tconst char *contents_from = NULL;\n \n \tcmd_is_annotate = !strcmp(argv[0], \"annotate\");\n+\tif (!cmd_is_annotate && argc > 1 && !strcmp(argv[1], \"--gui\")) {\n+\t\targv[0] = \"gui\";\n+\t\targv[1] = \"blame\";\n+\t\texecv_git_cmd(argv);\n+\t\tdie(\"Cannot execute git-gui blame: %s\", strerror(errno));\n+\t}\n \n \tgit_config(git_blame_config);\n \tsave_commit_buffer = 0;\n@@ -2214,6 +2222,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\telse if (!strcmp(\"-p\", arg) ||\n \t\t\t !strcmp(\"--porcelain\", arg))\n \t\t\toutput_option |= OUTPUT_PORCELAIN;\n+\t\telse if (!strcmp(\"--gui\", arg))\n+\t\t\tdie(\"Cannot combine --gui with %s\", argv[i - 1]);\n \t\telse if (!strcmp(\"--\", arg)) {\n \t\t\tseen_dashdash = 1;\n \t\t\ti++;\n-- \n1.5.2.2.1050.g51a8b\n"},{"id":"45470","messageId":"7vtzt13k4o.fsf@assigned-by-dhcp.pobox.com","threadId":"8670","inReplyTo":"20070621045333.GB13977@spearce.org","subject":"Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-21T06:19:03Z","receivedAt":"2007-06-21T06:19:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> To keep things really simple in git-blame we require that the new\n> --gui option be the first argument on the command line, and cannot\n> be combined with any other option.  If it is the first argument\n> then we punt our entire command line as-is into `git gui blame`,\n> where that program's option parser will handle selecting out the\n> revision and path, if present.\n>\n>  Its simple and not very intrusive, but has the odd behavior that\n>  no option (like --contents) can be used along with it, because\n>  git-gui's own blame subcommand doesn't recognize them.  On the\n>  other hand it is a useful DWIMery for `git gui blame`.\n\nHmm.  Now, how does \"git-blame\" tell if there is usable git-gui\ninstalled with it?  Will we have \"git-gui --list-features\"?\n\nIn either case, I think this description is far less than optimum:\n\n> diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt\n> index 66f1203..96ff02d 100644\n> --- a/Documentation/git-blame.txt\n> +++ b/Documentation/git-blame.txt\n> @@ -10,6 +10,7 @@ SYNOPSIS\n>  [verse]\n>  'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]\n>              [-S <revs-file>] [-M] [-C] [-C] [--since=<date>]\n> +            [--gui]\n>              [<rev> | --contents <file>] [--] <file>\n\n\nIt essentially is two commands with different calling\nconventions.  I would probably do this instead if I were doing\nthis:\n\nSYNOPSIS\n--------\n[verse]\n'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]\n            [-S <revs-file>] [-M] [-C] [-C] [--since=<date>]\n            [<rev> | --contents <file>] [--] <file>\n'git-blame' --gui [<rev>] [--] <file>\n"},{"id":"45542","messageId":"20070622035652.GD17393@spearce.org","threadId":"8670","inReplyTo":"7vtzt13k4o.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-06-22T03:56:53Z","receivedAt":"2007-06-22T03:56:53Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> Hmm.  Now, how does \"git-blame\" tell if there is usable git-gui\n> installed with it?  Will we have \"git-gui --list-features\"?\n\nIt can run `git gui version` and check to see that it is >= 0.7.3.\n \n;-)\n\n\nI'm actually not sure we want to apply this patch, hence the RFC\nprefix I put on it.  Jakub suggested it, this crude implementation\nwas easy enough to hack together, so I posted a patch for someone\nto play with if they were so inclined.\n\nMaybe we should just put a link in the git-blame manual page to\nthe git-gui manual page:\n\ndiff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt\nindex 66f1203..599e10b 100644\n--- a/Documentation/git-blame.txt\n+++ b/Documentation/git-blame.txt\n@@ -36,6 +36,9 @@ $ git log --pretty=oneline -S'blame_usage'\n ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output\n -----------------------------------------------------------------------------\n \n+A powerful graphical viewer for the output of git-blame can be\n+accessed through the blame subcommand of gitlink:git-gui[1].\n+\n OPTIONS\n -------\n include::blame-options.txt[]\n@@ -184,7 +187,8 @@ commit commentary), a blame viewer won't ever care.\n \n SEE ALSO\n --------\n-gitlink:git-annotate[1]\n+gitlink:git-annotate[1],\n+gitlink:git-gui[1]\n \n AUTHOR\n ------\n\n-- \nShawn.\n"},{"id":"45544","messageId":"7vzm2sab63.fsf@assigned-by-dhcp.pobox.com","threadId":"8670","inReplyTo":"20070622035652.GD17393@spearce.org","subject":"Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-22T04:03:00Z","receivedAt":"2007-06-22T04:03:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Junio C Hamano <gitster@pobox.com> wrote:\n>> Hmm.  Now, how does \"git-blame\" tell if there is usable git-gui\n>> installed with it?  Will we have \"git-gui --list-features\"?\n>\n> It can run `git gui version` and check to see that it is >= 0.7.3.\n\nThis is only minor nuisance, but can we do something about this?\n\n $ git gui --version\n Application initialization failed: no display name and no $DISPLAY environment variable\n\nI know it is from wish, not you, so I wouldn't insist, though.\n \n"},{"id":"45547","messageId":"20070622044716.GG17393@spearce.org","threadId":"8670","inReplyTo":"7vzm2sab63.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-06-22T04:47:16Z","receivedAt":"2007-06-22T04:47:16Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> This is only minor nuisance, but can we do something about this?\n> \n>  $ git gui --version\n>  Application initialization failed: no display name and no $DISPLAY environment variable\n> \n> I know it is from wish, not you, so I wouldn't insist, though.\n\nActually that should be fixable.\n\nShould be as simple as using a Bourne shell script up front to\ncheck for \"z$1\" = zversion || \"z$1\" = z--version, and if so dump\nback the version, otherwise exec wish.  This is actually quite easy\nand won't change things for existing users.  I'll put a patch into\nmaint tonight for it.\n\n-- \nShawn.\n"},{"id":"45549","messageId":"7vps3oa7kf.fsf@assigned-by-dhcp.pobox.com","threadId":"8670","inReplyTo":"20070622044716.GG17393@spearce.org","subject":"Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-22T05:20:48Z","receivedAt":"2007-06-22T05:20:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Junio C Hamano <gitster@pobox.com> wrote:\n>> This is only minor nuisance, but can we do something about this?\n>> \n>>  $ git gui --version\n>>  Application initialization failed: no display name and no $DISPLAY environment variable\n>> \n>> I know it is from wish, not you, so I wouldn't insist, though.\n>\n> Actually that should be fixable.\n>\n> Should be as simple as using a Bourne shell script up front to\n> check for \"z$1\" = zversion || \"z$1\" = z--version, and if so dump\n> back the version, otherwise exec wish.  This is actually quite easy\n> and won't change things for existing users.  I'll put a patch into\n> maint tonight for it.\n\nIf this makes life any harder to people on Windows, especially\nminGW, I would suggest against it.\n"},{"id":"45550","messageId":"20070622053702.GH17393@spearce.org","threadId":"8670","inReplyTo":"7vps3oa7kf.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-06-22T05:37:02Z","receivedAt":"2007-06-22T05:37:02Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> > Junio C Hamano <gitster@pobox.com> wrote:\n> >> This is only minor nuisance, but can we do something about this?\n> >> \n> >>  $ git gui --version\n> >>  Application initialization failed: no display name and no $DISPLAY environment variable\n> >> \n> >> I know it is from wish, not you, so I wouldn't insist, though.\n> \n> If this makes life any harder to people on Windows, especially\n> minGW, I would suggest against it.\n\nIts already done.  I don't think it will make a difference either\nway right now.\n\nCurrently we still have to have a Bourne shell on both Cygwin\nand MINGW platforms to perform key actions, like say git-clone.\nThe startup cost of git-gui is also rather high there anyway, so\nthis extra if test in Bourne shell before we exec into Tcl isn't\ngoing to kill us.\n\nBesides, you can side-step the entire Bourne shell thing by just\nstarting git-gui in wish yourself.  E.g.\n\n  CALL /path/to/wish.exe /path/to/git-gui -- ...\n\n\nI'd like to come back and make git-gui easier to install, perhaps by\nmaking \"starpacks\" of git-gui and Git plumbing available for some\npopular systems (e.g. MINGW/Windows, Mac OS X).  Such starpacks\nwould give users an easy way to get git-gui (and thus basic Git)\nup and running quickly.  At that point I will need to revisit this\nbootstrap code anyway.\n\n-- \nShawn.\n"},{"id":"45555","messageId":"467B8232.B6BFDE4A@eudaptics.com","threadId":"8670","inReplyTo":"7vps3oa7kf.fsf@assigned-by-dhcp.pobox.com","subject":"Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-06-22T08:02:58Z","receivedAt":"2007-06-22T08:02:58Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano wrote:\n> \n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > Junio C Hamano <gitster@pobox.com> wrote:\n> >> This is only minor nuisance, but can we do something about this?\n> >>\n> >>  $ git gui --version\n> >>  Application initialization failed: no display name and no $DISPLAY environment variable\n> >>\n> >> I know it is from wish, not you, so I wouldn't insist, though.\n> >\n> > Actually that should be fixable.\n> >\n> > Should be as simple as using a Bourne shell script up front to\n> > check for \"z$1\" = zversion || \"z$1\" = z--version, and if so dump\n> > back the version, otherwise exec wish.  This is actually quite easy\n> > and won't change things for existing users.  I'll put a patch into\n> > maint tonight for it.\n> \n> If this makes life any harder to people on Windows, especially\n> minGW, I would suggest against it.\n\nThe MinGW port's exec wrapper looks at the shbang line and runs the\nshell. Hence, invocation as\n\n  git gui --version\n\nwill work even from CMD.EXE. But\n\n  git-gui --version\n\nwill only work from MSYS's rxvt.\n\n-- Hannes\n"}]}