{"thread":{"id":"43531","subject":"[RFC/PATCH] git-show: also handle blobs","startedAt":"2006-12-03T18:54:52Z","lastAt":"2006-12-03T19:03:30Z","messageCount":2,"participants":["Johannes Schindelin","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295310","messageId":"Pine.LNX.4.63.0612031952050.28348@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43531","inReplyTo":null,"subject":"[RFC/PATCH] git-show: also handle blobs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-03T18:54:52Z","receivedAt":"2006-12-03T18:54:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nNow you can say \"git show v1.4.4.1:Makefile\" and it pipes the requested \ncontents into your favourite pager.\n\nWhile at it, the manpage for -show is updated; it no longer pipes \nanything, but rather uses the internal revision walking machinery. Better \nnot mention it at all.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tThis combines the \"wouldn't it be nice to have git-cat or\n\tgit-less\" wishes with \"we do not want to clutter up the\n\tnamespace any more.\n\n\tIf people like this approach, we could easily enhance this patch \n\tto be a synonym for \"-p cat-file -p\" for _every_ non-commit on the \n\tcommand line.\n\n Documentation/git-show.txt |   11 +++++------\n builtin-log.c              |   12 ++++++++++++\n 2 files changed, 17 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-show.txt b/Documentation/git-show.txt\nindex 4c880a8..9d4e93e 100644\n--- a/Documentation/git-show.txt\n+++ b/Documentation/git-show.txt\n@@ -3,7 +3,7 @@ git-show(1)\n \n NAME\n ----\n-git-show - Show one commit with difference it introduces\n+git-show - Show one blob or one commit with difference it introduces\n \n \n SYNOPSIS\n@@ -12,11 +12,10 @@ SYNOPSIS\n \n DESCRIPTION\n -----------\n-Shows commit log and textual diff for a single commit.  The\n-command internally invokes 'git-rev-list' piped to\n-'git-diff-tree', and takes command line options for both of\n-these commands. It also presents the merge commit in a special\n-format as produced by 'git-diff-tree --cc'.\n+Shows a commit or blob. In case of a commit it shows the\n+log message and textual diff for a single commit. It also\n+presents the merge commit in a special format as produced by\n+'git-diff-tree --cc'.\n \n This manual page describes only the most frequently used options.\n \ndiff --git a/builtin-log.c b/builtin-log.c\nindex 7acf5d3..c252c40 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -85,6 +85,18 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \trev.ignore_merges = 0;\n \trev.no_walk = 1;\n \tcmd_log_init(argc, argv, prefix, &rev);\n+\tif (rev.pending.nr == 1\n+\t\t\t&& rev.pending.objects[0].item->type == OBJ_BLOB) {\n+\t\tunsigned long size;\n+\t\tchar type[20];\n+\t\tvoid *buf = read_sha1_file(rev.pending.objects[0].item->sha1,\n+\t\t\t\ttype, &size);\n+\t\tif (!buf)\n+\t\t\treturn error(\"Could not read blob?\");\n+\t\tfwrite(buf, size, 1, stdout);\n+\t\tfree(buf);\n+\t\treturn 0;\n+\t}\n \treturn cmd_log_walk(&rev);\n }\n \n-- \n1.4.4.1.g317bd\n"},{"id":"296716","messageId":"ekv721$5el$1@sea.gmane.org","threadId":"43531","inReplyTo":"Pine.LNX.4.63.0612031952050.28348@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [RFC/PATCH] git-show: also handle blobs","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-03T19:03:30Z","receivedAt":"2006-12-03T19:03:30Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Johannes Schindelin wrote:\n\n>  \n>  DESCRIPTION\n>  -----------\n> -Shows commit log and textual diff for a single commit.  The\n> -command internally invokes 'git-rev-list' piped to\n> -'git-diff-tree', and takes command line options for both of\n> -these commands. It also presents the merge commit in a special\n> -format as produced by 'git-diff-tree --cc'.\n> +Shows a commit or blob. In case of a commit it shows the\n> +log message and textual diff for a single commit. It also\n> +presents the merge commit in a special format as produced by\n> +'git-diff-tree --cc'.\n>  \n>  This manual page describes only the most frequently used options.\n>  \n\nThis loses the information that you can use all the options\nof git-diff-tree and all the options of git-rev-list in git-show.\n\nBut I agre that technical information should not be in DESCRIPTION\nsection of manpage... perhaps later, if it is needed.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"}]}