* [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
@ 2007-06-21 4:53 Shawn O. Pearce
2007-06-21 6:19 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Shawn O. Pearce @ 2007-06-21 4:53 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jakub Narebski
Jakub Narebski proposed the idea of having a new --gui option for
git-blame that would start `git gui blame` with the arguments that
were given to git-blame on the command line. This actually makes
a lot of sense, as some users may first reach for `git blame` and
find the handy `--gui` option, rather than looking for the blame
subcommand of `git gui`.
To keep things really simple in git-blame we require that the new
--gui option be the first argument on the command line, and cannot
be combined with any other option. If it is the first argument
then we punt our entire command line as-is into `git gui blame`,
where that program's option parser will handle selecting out the
revision and path, if present.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
From Jakub Narebski <jnareb@gmail.com>:
> or have "git blame --gui" invoke "git gui blame"
Not a bad idea. Here's an implementation that does that.
Its simple and not very intrusive, but has the odd behavior that
no option (like --contents) can be used along with it, because
git-gui's own blame subcommand doesn't recognize them. On the
other hand it is a useful DWIMery for `git gui blame`.
Documentation/git-blame.txt | 8 ++++++++
builtin-blame.c | 12 +++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index 66f1203..96ff02d 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -10,6 +10,7 @@ SYNOPSIS
[verse]
'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
[-S <revs-file>] [-M] [-C] [-C] [--since=<date>]
+ [--gui]
[<rev> | --contents <file>] [--] <file>
DESCRIPTION
@@ -67,6 +68,13 @@ include::blame-options.txt[]
Ignore whitespace when comparing parent's version and
child's to find where the lines came from.
+--gui::
+ Instead of displaying the blame output on the text console,
+ start git-gui's graphical blame viewer. This option must
+ be the first option supplied, and cannot be combined with
+ any other option described here, except the optional <rev>
+ and the required <file> arguments.
+
THE PORCELAIN FORMAT
--------------------
diff --git a/builtin-blame.c b/builtin-blame.c
index f7e2c13..2f50a4a 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -18,9 +18,10 @@
#include "cache-tree.h"
#include "path-list.h"
#include "mailmap.h"
+#include "exec_cmd.h"
static char blame_usage[] =
-"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"
+"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"
" -c Use the same output mode as git-annotate (Default: off)\n"
" -b Show blank SHA-1 for boundary commits (Default: off)\n"
" -l Show long commit SHA1 (Default: off)\n"
@@ -34,6 +35,7 @@ static char blame_usage[] =
" -L n,m Process only line range n,m, counting from 1\n"
" -M, -C Find line movements within and across files\n"
" --incremental Show blame entries as we find them, incrementally\n"
+" --gui Use git-gui's graphical blame viewer\n"
" --contents file Use <file>'s contents as the final image\n"
" -S revs-file Use revisions from revs-file instead of calling git-rev-list\n";
@@ -2137,6 +2139,12 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
const char *contents_from = NULL;
cmd_is_annotate = !strcmp(argv[0], "annotate");
+ if (!cmd_is_annotate && argc > 1 && !strcmp(argv[1], "--gui")) {
+ argv[0] = "gui";
+ argv[1] = "blame";
+ execv_git_cmd(argv);
+ die("Cannot execute git-gui blame: %s", strerror(errno));
+ }
git_config(git_blame_config);
save_commit_buffer = 0;
@@ -2214,6 +2222,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
else if (!strcmp("-p", arg) ||
!strcmp("--porcelain", arg))
output_option |= OUTPUT_PORCELAIN;
+ else if (!strcmp("--gui", arg))
+ die("Cannot combine --gui with %s", argv[i - 1]);
else if (!strcmp("--", arg)) {
seen_dashdash = 1;
i++;
--
1.5.2.2.1050.g51a8b
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
2007-06-21 4:53 [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame Shawn O. Pearce
@ 2007-06-21 6:19 ` Junio C Hamano
2007-06-22 3:56 ` Shawn O. Pearce
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2007-06-21 6:19 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Jakub Narebski
"Shawn O. Pearce" <spearce@spearce.org> writes:
> To keep things really simple in git-blame we require that the new
> --gui option be the first argument on the command line, and cannot
> be combined with any other option. If it is the first argument
> then we punt our entire command line as-is into `git gui blame`,
> where that program's option parser will handle selecting out the
> revision and path, if present.
>
> Its simple and not very intrusive, but has the odd behavior that
> no option (like --contents) can be used along with it, because
> git-gui's own blame subcommand doesn't recognize them. On the
> other hand it is a useful DWIMery for `git gui blame`.
Hmm. Now, how does "git-blame" tell if there is usable git-gui
installed with it? Will we have "git-gui --list-features"?
In either case, I think this description is far less than optimum:
> diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
> index 66f1203..96ff02d 100644
> --- a/Documentation/git-blame.txt
> +++ b/Documentation/git-blame.txt
> @@ -10,6 +10,7 @@ SYNOPSIS
> [verse]
> 'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
> [-S <revs-file>] [-M] [-C] [-C] [--since=<date>]
> + [--gui]
> [<rev> | --contents <file>] [--] <file>
It essentially is two commands with different calling
conventions. I would probably do this instead if I were doing
this:
SYNOPSIS
--------
[verse]
'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
[-S <revs-file>] [-M] [-C] [-C] [--since=<date>]
[<rev> | --contents <file>] [--] <file>
'git-blame' --gui [<rev>] [--] <file>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
2007-06-21 6:19 ` Junio C Hamano
@ 2007-06-22 3:56 ` Shawn O. Pearce
2007-06-22 4:03 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Shawn O. Pearce @ 2007-06-22 3:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jakub Narebski
Junio C Hamano <gitster@pobox.com> wrote:
> Hmm. Now, how does "git-blame" tell if there is usable git-gui
> installed with it? Will we have "git-gui --list-features"?
It can run `git gui version` and check to see that it is >= 0.7.3.
;-)
I'm actually not sure we want to apply this patch, hence the RFC
prefix I put on it. Jakub suggested it, this crude implementation
was easy enough to hack together, so I posted a patch for someone
to play with if they were so inclined.
Maybe we should just put a link in the git-blame manual page to
the git-gui manual page:
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index 66f1203..599e10b 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -36,6 +36,9 @@ $ git log --pretty=oneline -S'blame_usage'
ea4c7f9bf69e781dd0cd88d2bccb2bf5cc15c9a7 git-blame: Make the output
-----------------------------------------------------------------------------
+A powerful graphical viewer for the output of git-blame can be
+accessed through the blame subcommand of gitlink:git-gui[1].
+
OPTIONS
-------
include::blame-options.txt[]
@@ -184,7 +187,8 @@ commit commentary), a blame viewer won't ever care.
SEE ALSO
--------
-gitlink:git-annotate[1]
+gitlink:git-annotate[1],
+gitlink:git-gui[1]
AUTHOR
------
--
Shawn.
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
2007-06-22 3:56 ` Shawn O. Pearce
@ 2007-06-22 4:03 ` Junio C Hamano
2007-06-22 4:47 ` Shawn O. Pearce
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2007-06-22 4:03 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Jakub Narebski
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Junio C Hamano <gitster@pobox.com> wrote:
>> Hmm. Now, how does "git-blame" tell if there is usable git-gui
>> installed with it? Will we have "git-gui --list-features"?
>
> It can run `git gui version` and check to see that it is >= 0.7.3.
This is only minor nuisance, but can we do something about this?
$ git gui --version
Application initialization failed: no display name and no $DISPLAY environment variable
I know it is from wish, not you, so I wouldn't insist, though.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
2007-06-22 4:03 ` Junio C Hamano
@ 2007-06-22 4:47 ` Shawn O. Pearce
2007-06-22 5:20 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Shawn O. Pearce @ 2007-06-22 4:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jakub Narebski
Junio C Hamano <gitster@pobox.com> wrote:
> This is only minor nuisance, but can we do something about this?
>
> $ git gui --version
> Application initialization failed: no display name and no $DISPLAY environment variable
>
> I know it is from wish, not you, so I wouldn't insist, though.
Actually that should be fixable.
Should be as simple as using a Bourne shell script up front to
check for "z$1" = zversion || "z$1" = z--version, and if so dump
back the version, otherwise exec wish. This is actually quite easy
and won't change things for existing users. I'll put a patch into
maint tonight for it.
--
Shawn.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
2007-06-22 4:47 ` Shawn O. Pearce
@ 2007-06-22 5:20 ` Junio C Hamano
2007-06-22 5:37 ` Shawn O. Pearce
2007-06-22 8:02 ` Johannes Sixt
0 siblings, 2 replies; 8+ messages in thread
From: Junio C Hamano @ 2007-06-22 5:20 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git, Jakub Narebski
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Junio C Hamano <gitster@pobox.com> wrote:
>> This is only minor nuisance, but can we do something about this?
>>
>> $ git gui --version
>> Application initialization failed: no display name and no $DISPLAY environment variable
>>
>> I know it is from wish, not you, so I wouldn't insist, though.
>
> Actually that should be fixable.
>
> Should be as simple as using a Bourne shell script up front to
> check for "z$1" = zversion || "z$1" = z--version, and if so dump
> back the version, otherwise exec wish. This is actually quite easy
> and won't change things for existing users. I'll put a patch into
> maint tonight for it.
If this makes life any harder to people on Windows, especially
minGW, I would suggest against it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
2007-06-22 5:20 ` Junio C Hamano
@ 2007-06-22 5:37 ` Shawn O. Pearce
2007-06-22 8:02 ` Johannes Sixt
1 sibling, 0 replies; 8+ messages in thread
From: Shawn O. Pearce @ 2007-06-22 5:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jakub Narebski
Junio C Hamano <gitster@pobox.com> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> > Junio C Hamano <gitster@pobox.com> wrote:
> >> This is only minor nuisance, but can we do something about this?
> >>
> >> $ git gui --version
> >> Application initialization failed: no display name and no $DISPLAY environment variable
> >>
> >> I know it is from wish, not you, so I wouldn't insist, though.
>
> If this makes life any harder to people on Windows, especially
> minGW, I would suggest against it.
Its already done. I don't think it will make a difference either
way right now.
Currently we still have to have a Bourne shell on both Cygwin
and MINGW platforms to perform key actions, like say git-clone.
The startup cost of git-gui is also rather high there anyway, so
this extra if test in Bourne shell before we exec into Tcl isn't
going to kill us.
Besides, you can side-step the entire Bourne shell thing by just
starting git-gui in wish yourself. E.g.
CALL /path/to/wish.exe /path/to/git-gui -- ...
I'd like to come back and make git-gui easier to install, perhaps by
making "starpacks" of git-gui and Git plumbing available for some
popular systems (e.g. MINGW/Windows, Mac OS X). Such starpacks
would give users an easy way to get git-gui (and thus basic Git)
up and running quickly. At that point I will need to revisit this
bootstrap code anyway.
--
Shawn.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame
2007-06-22 5:20 ` Junio C Hamano
2007-06-22 5:37 ` Shawn O. Pearce
@ 2007-06-22 8:02 ` Johannes Sixt
1 sibling, 0 replies; 8+ messages in thread
From: Johannes Sixt @ 2007-06-22 8:02 UTC (permalink / raw)
To: git
Junio C Hamano wrote:
>
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>
> > Junio C Hamano <gitster@pobox.com> wrote:
> >> This is only minor nuisance, but can we do something about this?
> >>
> >> $ git gui --version
> >> Application initialization failed: no display name and no $DISPLAY environment variable
> >>
> >> I know it is from wish, not you, so I wouldn't insist, though.
> >
> > Actually that should be fixable.
> >
> > Should be as simple as using a Bourne shell script up front to
> > check for "z$1" = zversion || "z$1" = z--version, and if so dump
> > back the version, otherwise exec wish. This is actually quite easy
> > and won't change things for existing users. I'll put a patch into
> > maint tonight for it.
>
> If this makes life any harder to people on Windows, especially
> minGW, I would suggest against it.
The MinGW port's exec wrapper looks at the shbang line and runs the
shell. Hence, invocation as
git gui --version
will work even from CMD.EXE. But
git-gui --version
will only work from MSYS's rxvt.
-- Hannes
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-06-22 8:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21 4:53 [RFC PATCH 2/2] Teach git-blame --gui how to start git-gui blame Shawn O. Pearce
2007-06-21 6:19 ` Junio C Hamano
2007-06-22 3:56 ` Shawn O. Pearce
2007-06-22 4:03 ` Junio C Hamano
2007-06-22 4:47 ` Shawn O. Pearce
2007-06-22 5:20 ` Junio C Hamano
2007-06-22 5:37 ` Shawn O. Pearce
2007-06-22 8:02 ` Johannes Sixt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).