git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCHv2 2/2] git-patch-id: do not trip over "no newline" markers
Date: Fri, 18 Feb 2011 05:40:35 -0500	[thread overview]
Message-ID: <20110218104035.GA7262@sigill.intra.peff.net> (raw)
In-Reply-To: <4D5E278F.2010509@drmicha.warpmail.net>

On Fri, Feb 18, 2011 at 09:02:23AM +0100, Michael J Gruber wrote:

> > Wow, that's pretty obscure. I wonder if the test should be factored out
> > into line_is_no_newline_at_end_of_file() (or surely there is some more
> > sensible name), and used by both apply and patch-id. Along with a nice
> > comment (which I see apply already has) describing what in the world the
> > magic number 12 means.
> 
> So, where do you suggest it should go? As far as I can see, we have two
> places reading these markers (the above builtins) and two places writing
> them (diff.c, xdiff/xutils.c), at least for git-core.

I think you could ignore the writers, as they are much more
straightforward.  But...

> (git-gui's diff.tcl has its own strict check etc.)

Ugh. Factoring that out with the C code would not be easy. :)

> I would opt for putting a more detailed explanation in the commit
> message (reasoning + ref. to apply.c) rather then trying to factor this.

I think that's OK. It's not a lot of code, it's just very non-obvious.
So a comment is probably as good as a refactor.

> After all, our code is largely undocumented as far as inline
> documentation goes (it has frustrated me a few times), and the more
> comprehensive documentation are the commit messages which git blame
> points you to.

Yeah, it is sometimes annoying. On the other hand, you know that a
comment in the commit log cannot be stale, because you are viewing it in
context (well, it can be, but theoretically you have the tools to
determine that).

I'm not sure what the right balance is. I tend to write inline comments
for small non-obvious things (e.g., why a variable is being strdup'd),
and describe the bigger picture in the commit message (e.g., why a
particular algorithm was chosen).

But it has only been a few years that we've had version control systems
where history browsing wasn't absolutely horrendous. Maybe in another
decade or so there will be best practices for this sort of thing. :)

-Peff

  parent reply	other threads:[~2011-02-18 10:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16 14:56 Why does git-patch-id(1) sometimes print two lines, one of which has commit = 0000000000000000000000000000000000000000 Ævar Arnfjörð Bjarmason
2011-02-16 16:11 ` Michael J Gruber
2011-02-16 16:55   ` [PATCH 1/2] git-patch-id: test for "no newline" markers Michael J Gruber
2011-02-16 16:55     ` [PATCH 2/2] git-patch-id: do not trip over " Michael J Gruber
2011-02-16 20:05       ` Junio C Hamano
2011-02-17  7:44         ` [PATCHv2 1/2] git-patch-id: test for " Michael J Gruber
2011-02-17  7:44           ` [PATCHv2 2/2] git-patch-id: do not trip over " Michael J Gruber
2011-02-18  4:16             ` Jeff King
2011-02-18  8:02               ` Michael J Gruber
2011-02-18 10:12                 ` [PATCHv3 1/2] git-patch-id: test for " Michael J Gruber
2011-02-18 10:12                   ` [PATCHv3 2/2] git-patch-id: do not trip over " Michael J Gruber
2011-02-18 10:41                     ` Jeff King
2011-02-18 10:43                       ` Michael J Gruber
2011-02-18 10:47                         ` Jeff King
2011-02-18 14:29                     ` Jakub Narebski
2011-02-18 10:40                 ` Jeff King [this message]
2011-02-17 11:55           ` [PATCHv2 1/2] git-patch-id: test for " Jakub Narebski
2011-02-17 12:11             ` Michael J Gruber

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20110218104035.GA7262@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).