git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add log.abbrev-commit config option
@ 2011-05-14 17:22 Jay Soffian
  2011-05-14 17:26 ` Jay Soffian
  2011-05-14 19:01 ` Jonathan Nieder
  0 siblings, 2 replies; 22+ messages in thread
From: Jay Soffian @ 2011-05-14 17:22 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, Junio C Hamano

Add log.abbrev-commit (and log.abbrevCommit synonym) config option as
a convenience for users who often use --abbrev-commit with git log and
git show (but not git whatchanged, as its output is more likely to be
parsed even though it is not technically plumbing).

Allow the option to be overridden via --no-abbrev-commit.

(Also, a drive-by spelling correction in git log's short help.)

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
 Documentation/config.txt  |    6 ++++++
 Documentation/git-log.txt |    3 +++
 builtin/log.c             |   17 +++++++++++++++--
 t/t4202-log.sh            |    8 ++++++++
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 285c7f73ca..85f00f6bb1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1314,6 +1314,12 @@ interactive.singlekey::
 	linkgit:git-checkout[1]. Note that this setting is silently
 	ignored if portable keystroke input is not available.
 
+log.abbrev-commit::
+log.abbrevCommit::
+	If true, act as if --abbrev-commit were specified on the command
+	line. May be overridden with --no-abbrev-commit. Note that this setting
+	is ignored by rev-list.
+
 log.date::
 	Set the default date-time mode for the 'log' command.
 	Setting a value for log.date is similar to using 'git log''s
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index de5c0d37a5..3061eec9b7 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -38,6 +38,9 @@ OPTIONS
 	Continue listing the history of a file beyond renames
 	(works only for a single file).
 
+--no-abbrev-commit::
+	Don't abbreviate commit name. Useful for overridding log.abbrevCommit.
+
 --no-decorate::
 --decorate[=short|full|no]::
 	Print out the ref names of any commits that are shown. If 'short' is
diff --git a/builtin/log.c b/builtin/log.c
index f6219909a7..cfac510b24 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -23,6 +23,7 @@
 /* Set a default date-time format for git log ("log.date" config variable) */
 static const char *default_date_mode = NULL;
 
+static int default_abbrev_commit = 0;
 static int default_show_root = 1;
 static int decoration_style;
 static int decoration_given;
@@ -77,6 +78,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
 		get_commit_format(fmt_pretty, rev);
 	rev->verbose_header = 1;
 	DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
+	rev->abbrev_commit = default_abbrev_commit;
 	rev->show_root_diff = default_show_root;
 	rev->subject_prefix = fmt_patch_subject_prefix;
 	DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
@@ -89,11 +91,13 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 			 struct rev_info *rev, struct setup_revision_opt *opt)
 {
 	struct userformat_want w;
-	int quiet = 0, source = 0;
+	int quiet = 0, source = 0, no_abbrev_commit = 0;
 
 	const struct option builtin_log_options[] = {
-		OPT_BOOLEAN(0, "quiet", &quiet, "supress diff output"),
+		OPT_BOOLEAN(0, "quiet", &quiet, "suppress diff output"),
 		OPT_BOOLEAN(0, "source", &source, "show source"),
+		OPT_BOOLEAN(0, "no-abbrev-commit", &no_abbrev_commit,
+			    "don't abbreviate commit name"),
 		{ OPTION_CALLBACK, 0, "decorate", NULL, NULL, "decorate options",
 		  PARSE_OPT_OPTARG, decorate_callback},
 		OPT_END()
@@ -129,6 +133,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 	if (source)
 		rev->show_source = 1;
 
+	if (no_abbrev_commit)
+		rev->abbrev_commit = 0;
+
 	/*
 	 * defeat log.decorate configuration interacting with --pretty=raw
 	 * from the command line.
@@ -323,6 +330,11 @@ static int git_log_config(const char *var, const char *value, void *cb)
 		return git_config_string(&fmt_pretty, var, value);
 	if (!strcmp(var, "format.subjectprefix"))
 		return git_config_string(&fmt_patch_subject_prefix, var, value);
+	if (!strcasecmp(var, "log.abbrevcommit") ||
+	    !strcasecmp(var, "log.abbrev-commit")) {
+		default_abbrev_commit = git_config_bool(var, value);
+		return 0;
+	}
 	if (!strcmp(var, "log.date"))
 		return git_config_string(&default_date_mode, var, value);
 	if (!strcmp(var, "log.decorate")) {
@@ -347,6 +359,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
 	struct setup_revision_opt opt;
 
 	git_config(git_log_config, NULL);
+	default_abbrev_commit = 0;
 
 	if (diff_use_color_default == -1)
 		diff_use_color_default = git_use_color_default;
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 2fcc31a6f3..83c6576feb 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -450,6 +450,14 @@ test_expect_success 'log.decorate configuration' '
 
 '
 
+test_expect_success 'log.abbrev-commit configuration' '
+	test_might_fail git config --remove-section log &&
+	git log --abbrev-commit >expect &&
+	git config log.abbrev-commit true &&
+	git log >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'show added path under "--follow -M"' '
 	# This tests for a regression introduced in v1.7.2-rc0~103^2~2
 	test_create_repo regression &&
-- 
1.7.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-05-18  1:05 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-14 17:22 [PATCH] Add log.abbrev-commit config option Jay Soffian
2011-05-14 17:26 ` Jay Soffian
2011-05-14 19:01 ` Jonathan Nieder
2011-05-14 19:35   ` Jay Soffian
2011-05-14 20:19     ` [PATCH] add, merge, diff: do not use strcasecmp to compare config variable names Jonathan Nieder
2011-05-15  1:53       ` Junio C Hamano
2011-05-14 20:47   ` [PATCH v2] Add log.abbrevCommit config variable Jay Soffian
2011-05-14 21:55     ` Jonathan Nieder
2011-05-14 22:22       ` Jay Soffian
2011-05-14 22:49         ` [PATCH v3] " Jay Soffian
2011-05-15 13:25           ` Jay Soffian
2011-05-15 22:42           ` Junio C Hamano
2011-05-16  5:53             ` Jay Soffian
2011-05-16  7:00               ` Jonathan Nieder
2011-05-16  7:18                 ` Jay Soffian
2011-05-17 17:03                 ` Junio C Hamano
2011-05-17 21:50                   ` Junio C Hamano
2011-05-18  1:05                     ` Jay Soffian
2011-05-17 18:50           ` Junio C Hamano
2011-05-17 19:08             ` Jay Soffian
2011-05-15  1:48   ` [PATCH] Add log.abbrev-commit config option Junio C Hamano
2011-05-16  8:24     ` Michael J Gruber

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).