git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Jay Soffian <jaysoffian@gmail.com>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH v3 3/4] commit.c: replace some literal strings with constants
Date: Wed, 16 Feb 2011 23:19:19 -0600	[thread overview]
Message-ID: <20110217051919.GA7740@elie> (raw)
In-Reply-To: <1297916325-89688-4-git-send-email-jaysoffian@gmail.com>

Jay Soffian wrote:

> I converted these per
> http://article.gmane.org/gmane.comp.version-control.git/167015
>
> Maybe this should be the last patch in the series; it's questionable to
> me whether it's even worth doing.

What have I wrought?  I think this makes the code much less readable.

> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -626,13 +632,13 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  		format_commit_message(commit, "fixup! %s\n\n",
>  				      &sb, &ctx);
>  		hook_arg1 = "message";
> -	} else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
> -		if (strbuf_read_file(&sb, git_path("MERGE_MSG"), 0) < 0)
> -			die_errno("could not read MERGE_MSG");
> +	} else if (!stat(git_path(merge_msg), &statbuf)) {
> +		if (strbuf_read_file(&sb, git_path(merge_msg), 0) < 0)
> +			die_errno("could not read %s", merge_msg);

So now a person needs to look earlier in the file to see that
merge_msg means "MERGE_MSG" rather than being something that
can vary.

Yes, commit_editmsg has the same problem.  If I get to choose[*] then
cache.h would contain something like

	#define MERGE_HEAD_FILE "MERGE_HEAD"
	#define PREPARED_COMMIT_MESSAGE_FILE "MERGE_MSG"
	#define <description of SQUASH_MSG goes here> "SQUASH_MSG"

and commit.c or cache.h would contain something like

	#define EDITABLE_COMMIT_MESSAGE_FILE "COMMIT_EDITMSG"

and those symbolic names would be used throughout builtin code to
name those files.  So we would get

 (1) documentation of what filenames are special to git, collected
     in one place
 (2) protection against typos

without losing

 (3) names that look like constants

Jonathan

[*] and I shouldn't!  What I like should matter much less than what is
right.

  reply	other threads:[~2011-02-17  5:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17  4:18 [PATCH v3 0/4] CHERRY_PICK_HEAD Jay Soffian
2011-02-17  4:18 ` [PATCH v3 1/4] Introduce CHERRY_PICK_HEAD Jay Soffian
2011-02-17 20:01   ` Junio C Hamano
2011-02-17 22:32     ` Jonathan Nieder
2011-02-20  2:29     ` Jay Soffian
2011-02-20  2:48       ` Jonathan Nieder
2011-02-20  6:43       ` Junio C Hamano
2011-02-17 21:56   ` Junio C Hamano
2011-02-17 22:42     ` Jay Soffian
2011-02-17 22:48       ` Jonathan Nieder
2011-02-17  4:18 ` [PATCH v3 2/4] bash: teach __git_ps1 about CHERRY_PICK_HEAD Jay Soffian
2011-02-17  4:18 ` [PATCH v3 3/4] commit.c: replace some literal strings with constants Jay Soffian
2011-02-17  5:19   ` Jonathan Nieder [this message]
2011-02-17  5:50     ` [PATCH] Teach commit about CHERRY_PICK_HEAD Jay Soffian
2011-02-18  0:29       ` Jonathan Nieder
2011-02-17  5:49   ` [PATCH v3 3/4] commit.c: replace some literal strings with constants Junio C Hamano
2011-02-17  4:18 ` [PATCH v3 4/4] Teach commit about CHERRY_PICK_HEAD Jay Soffian

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=20110217051919.GA7740@elie \
    --to=jrnieder@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jaysoffian@gmail.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.
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).