git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: Do not show 'patch' link in 'commit' view for merges
Date: Thu, 1 Oct 2009 09:36:23 +0200	[thread overview]
Message-ID: <200910010936.24789.jnareb@gmail.com> (raw)
In-Reply-To: <20091001031140.GA30094@coredump.intra.peff.net>

Dnia czwartek 1. października 2009 05:11, Jeff King napisał:
> On Wed, Sep 30, 2009 at 10:21:53PM +0200, Jakub Narebski wrote:
> 
> > Show 'patch' link in the 'commit' view only for commits which have
> > exactly one parent, otherwise call to git-format-patch would fail for
> > the hyperlinked 'patch' action.
> 
> Fail in what way? From my cursory reading of the code, it looks like the
> 'patch' action calls into git_commitdiff, which handles the multi-parent
> case.
> 
> I assume I'm reading wrong, since you obviously know gitweb much better
> than I do. :) But can you expand a little on the nature of the problem
> in the commit message?

Well, from the point of view of behavior, 'patch' link in 'commit' view
for a merge commit, e.g.
  gitweb.cgi/git.git/commit/833423ae071ffedb7fbca39789f14f9a45a3d1c4
leads to the 'patch' view
  git.git/patch/833423ae071ffedb7fbca39789f14f9a45a3d1c4
which leads to 'text/plain' output with the following contents:

  Reading git-format-patch failed


From the point of view of code, 'patch' view is handled by git_patch()
subroutine, which in turn calls git_commitdiff(-format => 'patch', -single=> 1);
git_commitdiff checks if 'patch' view is enabled feature, and then 
composes and calls the following command (I have skipped --git-dir=...):

  git format-patch --encoding=utf8 --stdout -1 --root <commit-id>

And git-format-patch produces no output for merge commit.  Then 
git_commitdiff dumps output of git-format-patch

	local $/ = undef;
	print <$fd>;

and somehow fails on closing filehandle

	close $fd
		or print "Reading git-format-patch failed\n";

Even if 'patch' view didn't fail, it is not a good idea to have link
to an empty page (or page with only error message).  Though probably
git_commitdiff could check if it is used for a merge commit...

-- 
Jakub Narebski
Poland

  reply	other threads:[~2009-10-01  7:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-30 20:21 [PATCH] gitweb: Do not show 'patch' link in 'commit' view for merges Jakub Narebski
2009-10-01  3:11 ` Jeff King
2009-10-01  7:36   ` Jakub Narebski [this message]
2009-10-01  7:55     ` Jeff King
2009-10-01  9:18       ` Jakub Narebski
2009-10-09 12:10         ` [PATCH v2] gitweb: Do not show 'patch' link for merge commits Jakub Narebski
2009-10-09 12:23           ` Jakub Narebski
2009-10-09 12:26             ` [PATCH v2 (amend)] " Jakub Narebski
2009-10-09 19:19               ` Jeff King
2009-10-10  0:56               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200910010936.24789.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).