All of lore.kernel.org
 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

* Re: [PATCH] Add log.abbrev-commit config option
  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
  1 sibling, 0 replies; 22+ messages in thread
From: Jay Soffian @ 2011-05-14 17:26 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, Junio C Hamano

On Sat, May 14, 2011 at 1:22 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> +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.
> +

The last sentence should probably read:

   Honored by the 'log' and 'show' commands.

j.

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

* Re: [PATCH] Add log.abbrev-commit config option
  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
                     ` (2 more replies)
  1 sibling, 3 replies; 22+ messages in thread
From: Jonathan Nieder @ 2011-05-14 19:01 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, Junio C Hamano

Hi,

I like the idea.

Jay Soffian wrote:

> Add log.abbrev-commit (and log.abbrevCommit synonym)

Why two options?  It would be more conventional to provide just
log.abbrevCommit.  The existing "[add] ignore-errors" is explained in
the manual to be a mistake and "[add] ignoreerrors" is the fixed
version; adding more configuration variables with dashes in the name
would seem to make guessing variable names even more hit-or-miss.

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

Hm, that wouldn't have been my hunch.  Are you aware of any scripts
that parse "git whatchanged" output?

More worrying is "git log --format=raw".  I think as long as we're
cautious about rolling this out slowly and noticing breakage early it
should be okay.  It might even be nice to find out if there are
scripts or tests that care deeply about "git log"'s output format
(which would be more reliable if they had been written to use
"git rev-list | git diff-tree -s --stdin").

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

Good idea anyway.  Once parse_revision_opt learns to use parse_options
these negated options would be automatic (though that's a long way
away).

Unfortunately this wouldn't help scripts much until the option has
been around for a while.  Maybe it would be safer to have two patches
--- one to add --no-abbrev-commit which could be included in "maint"
and widely deployed, and one to add the new configuration only after
--no-abbrev-commit can be relied on?  But on the other hand, scripts
can be updated today to use rev-list | diff-tree, so maybe that's not
worth the trouble.

People using git by hand would certainly appreciate
--no-abbrev-commit, I suspect.  Thanks for thinking about these
things.

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

Style: most of that page is written from the point of view of the
user, like:

	Tells 'git apply' how to handle whitespace.  Set this to
	"ignore" if you don't want to be bothered.  See
	linkgit:git-apply[1] for details.

So maybe something like:

	Whether to abbreviate hexadecimal commit object names in
	output from the 'log' family of commands.  The number of
	digits shown is determined by the `--abbrev` command-line
	option and `core.abbrev` configuration variable.  Can be
	overridden on the command line by --abbrev-commit /
	--no-abbrev-commit.  The default is false.
 +
 This does not affect the 'git diff-tree' and 'git rev-list'
 commands.

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

Also useful for overriding --abbrev-commit from aliases. :)

Shouldn't it be documented next to --abbrev-commit?

> --- 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;

Style: we try to avoid unnecessary zero initializers for variables in
the BSS section.

[...]
> @@ -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"),

What happens if I do

	git log --no-abbrev-commit --abbrev-commit

?  How about

	git log --no-abbrev-commit --no-no-abbrev-commit --abbrev-commit

? :)  The behavior should be nicer if this is implemented in revision.c.

[...]
> @@ -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")) {

No need to use strcasecmp --- the vars passed to config functions
already have the section and variable names in lowercase.

> @@ -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;

Puzzling as mentioned above.

> --- 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
> +'

To avoid polluting the configuration, it would be nicest to do:

	git config log.abbrev-commit true &&
	test_when_finished "git config --unset log.abbrev-commit" &&
	git log >actual &&

though it looks like some tests already protect themselves.

Just because I'm curious: what happens if you do

	git config log.abbrev-commit true

in test_create_repo in test-lib.sh?  (I.e., are there many tests that
would be confused by this?)  Tests tend to be more picky than user
scripts about the output of git but it might still be an ok way to
get a vague sense of the impact.

Hope that helps, and thanks for a pleasant read.

Regards,
Jonathan

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

* Re: [PATCH] Add log.abbrev-commit config option
  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-14 20:47   ` [PATCH v2] Add log.abbrevCommit config variable Jay Soffian
  2011-05-15  1:48   ` [PATCH] Add log.abbrev-commit config option Junio C Hamano
  2 siblings, 1 reply; 22+ messages in thread
From: Jay Soffian @ 2011-05-14 19:35 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Junio C Hamano

On Sat, May 14, 2011 at 3:01 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Why two options?  It would be more conventional to provide just
> log.abbrevCommit.  The existing "[add] ignore-errors" is explained in
> the manual to be a mistake

Ah, okay.

>> 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).
>
> Hm, that wouldn't have been my hunch.  Are you aware of any scripts
> that parse "git whatchanged" output?

Yes, I've seen it in post-receive hooks, however, that's typically in
bare repos where I suppose it's unlikely for the user to set
log.abbrevCommit, so maybe I was just being overly cautious.

> More worrying is "git log --format=raw".  I think as long as we're
> cautious about rolling this out slowly and noticing breakage early it
> should be okay.  It might even be nice to find out if there are
> scripts or tests that care deeply about "git log"'s output format
> (which would be more reliable if they had been written to use
> "git rev-list | git diff-tree -s --stdin").
>
>> Allow the option to be overridden via --no-abbrev-commit.
>
> Good idea anyway.  Once parse_revision_opt learns to use parse_options
> these negated options would be automatic (though that's a long way
> away).
>
> Unfortunately this wouldn't help scripts much until the option has
> been around for a while.  Maybe it would be safer to have two patches
> --- one to add --no-abbrev-commit which could be included in "maint"
> and widely deployed, and one to add the new configuration only after
> --no-abbrev-commit can be relied on?  But on the other hand, scripts
> can be updated today to use rev-list | diff-tree, so maybe that's not
> worth the trouble.

I think that's overkill. Thinking through it more, this would only
break any scripts:

a) that are parsing whatchanged output; and
b) the user sets log.abbrevCommit w/o updating his script

> People using git by hand would certainly appreciate
> --no-abbrev-commit, I suspect.

That's why I added it.

>> --- 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.
>
> Style: most of that page is written from the point of view of the
> user
>
> [...]
>
> So maybe something like:
>
>        Whether to abbreviate hexadecimal commit object names in
>        output from the 'log' family of commands.  The number of
>        digits shown is determined by the `--abbrev` command-line
>        option and `core.abbrev` configuration variable.  Can be
>        overridden on the command line by --abbrev-commit /
>        --no-abbrev-commit.  The default is false.
>  +
>  This does not affect the 'git diff-tree' and 'git rev-list'
>  commands.

I thought I phrased it like the nearby options in config.txt. and that
sounds overly verbose to me, but I'll take another look.

>> --- 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.
>
> Also useful for overriding --abbrev-commit from aliases. :)
>
> Shouldn't it be documented next to --abbrev-commit?

As I implemented it, --no-abbrev-commit is only honored from within
log.c, so I didn't want it to show up in the rev-list man page.

But, see below where I address your question about why I didn't
implement --no-abbrev-commit in revision.c

>> --- 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;
>
> Style: we try to avoid unnecessary zero initializers for variables in
> the BSS section.

Okay.

> [...]
>> @@ -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"),
>
> What happens if I do
>
>        git log --no-abbrev-commit --abbrev-commit
>
> ?  How about
>
>        git log --no-abbrev-commit --no-no-abbrev-commit --abbrev-commit
>
> ? :)  The behavior should be nicer if this is implemented in revision.c.


It was a thinko to put it in log.c. I added --no-abbrev-commit
thinking of its primary use case to override log.abbrevCommit. But
obviously it's more generally useful in revision.c (even though that
doesn't honor log.abbrevCommit), since it can still be used to
override earlier CLI options that might enable abbreviation.

I'll move it. Then I can document the option next to --abbrev-commit
where it makes sense.

> [...]
>> @@ -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")) {
>
> No need to use strcasecmp --- the vars passed to config functions
> already have the section and variable names in lowercase.

Okay, it was a cut-and-paste from ignore-errors I think.

>> @@ -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;
>
> Puzzling as mentioned above.

Will drop.

>> --- 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
>> +'
>
> To avoid polluting the configuration, it would be nicest to do:
>
>        git config log.abbrev-commit true &&
>        test_when_finished "git config --unset log.abbrev-commit" &&
>        git log >actual &&
>
> though it looks like some tests already protect themselves.


Other tests in t4202 protect themselves at the start, I emulated that behavior.


> Just because I'm curious: what happens if you do
>
>        git config log.abbrev-commit true
>
> in test_create_repo in test-lib.sh?  (I.e., are there many tests that
> would be confused by this?)  Tests tend to be more picky than user
> scripts about the output of git but it might still be an ok way to
> get a vague sense of the impact.

I'll let you know. :-)

> Hope that helps, and thanks for a pleasant read.

Thanks for the quick review.

j.

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

* [PATCH] add, merge, diff: do not use strcasecmp to compare config variable names
  2011-05-14 19:35   ` Jay Soffian
@ 2011-05-14 20:19     ` Jonathan Nieder
  2011-05-15  1:53       ` Junio C Hamano
  0 siblings, 1 reply; 22+ messages in thread
From: Jonathan Nieder @ 2011-05-14 20:19 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, Junio C Hamano

The config machinery already makes section and variable names
lowercase when parsing them, so using strcasecmp for comparison just
feels wasteful.  No noticeable change intended.

Noticed-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Jay Soffian wrote:
> On Sat, May 14, 2011 at 3:01 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:

>> No need to use strcasecmp --- the vars passed to config functions
>> already have the section and variable names in lowercase.
>
> Okay, it was a cut-and-paste from ignore-errors I think.

Good catch.

 builtin/add.c     |    4 ++--
 merge-recursive.c |    6 +++---
 xdiff-interface.c |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index 704141f..e57abdd 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -331,8 +331,8 @@ static struct option builtin_add_options[] = {
 
 static int add_config(const char *var, const char *value, void *cb)
 {
-	if (!strcasecmp(var, "add.ignoreerrors") ||
-	    !strcasecmp(var, "add.ignore-errors")) {
+	if (!strcmp(var, "add.ignoreerrors") ||
+	    !strcmp(var, "add.ignore-errors")) {
 		ignore_add_errors = git_config_bool(var, value);
 		return 0;
 	}
diff --git a/merge-recursive.c b/merge-recursive.c
index ecb1806..07ad1a3 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1721,15 +1721,15 @@ int merge_recursive_generic(struct merge_options *o,
 static int merge_recursive_config(const char *var, const char *value, void *cb)
 {
 	struct merge_options *o = cb;
-	if (!strcasecmp(var, "merge.verbosity")) {
+	if (!strcmp(var, "merge.verbosity")) {
 		o->verbosity = git_config_int(var, value);
 		return 0;
 	}
-	if (!strcasecmp(var, "diff.renamelimit")) {
+	if (!strcmp(var, "diff.renamelimit")) {
 		o->diff_rename_limit = git_config_int(var, value);
 		return 0;
 	}
-	if (!strcasecmp(var, "merge.renamelimit")) {
+	if (!strcmp(var, "merge.renamelimit")) {
 		o->merge_rename_limit = git_config_int(var, value);
 		return 0;
 	}
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 164581f..0e2c169 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -347,7 +347,7 @@ int git_xmerge_style = -1;
 
 int git_xmerge_config(const char *var, const char *value, void *cb)
 {
-	if (!strcasecmp(var, "merge.conflictstyle")) {
+	if (!strcmp(var, "merge.conflictstyle")) {
 		if (!value)
 			die("'%s' is not a boolean", var);
 		if (!strcmp(value, "diff3"))
-- 
1.7.5.1

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

* [PATCH v2] Add log.abbrevCommit config variable
  2011-05-14 19:01 ` Jonathan Nieder
  2011-05-14 19:35   ` Jay Soffian
@ 2011-05-14 20:47   ` Jay Soffian
  2011-05-14 21:55     ` Jonathan Nieder
  2011-05-15  1:48   ` [PATCH] Add log.abbrev-commit config option Junio C Hamano
  2 siblings, 1 reply; 22+ messages in thread
From: Jay Soffian @ 2011-05-14 20:47 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, Jonathan Nieder, Junio C Hamano

Add log.abbrevCommit config variable as a convenience for users who
often use --abbrev-commit with git log and friends. Allow the option
to be overridden with --no-abbrev-commit.

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

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
Addresses Jonathan's feedback.

> Just because I'm curious: what happens if you do
> 
>        git config log.abbrev-commit true
> 
> in test_create_repo in test-lib.sh?  (I.e., are there many tests that
> would be confused by this?)  Tests tend to be more picky than user
> scripts about the output of git but it might still be an ok way to
> get a vague sense of the impact.

As expected, it breaks all the tests which rely on the output of show,
whatchanged, and log not having abbreviated commit names. They could
all be adjusted to pass '--no-abbrev-commit', but I think that's
pointless churn.

 Documentation/config.txt         |    5 +++++
 Documentation/pretty-options.txt |    5 +++++
 builtin/log.c                    |    8 +++++++-
 revision.c                       |    2 ++
 t/t4202-log.sh                   |   12 ++++++++++++
 5 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 285c7f73ca..8a3a1d08f7 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1314,6 +1314,11 @@ interactive.singlekey::
 	linkgit:git-checkout[1]. Note that this setting is silently
 	ignored if portable keystroke input is not available.
 
+log.abbrevCommit::
+	If true, makes linkgit:git-log[1], linkgit:git-show[1], and
+	linkgit:git-whatchanged[1] assume `\--abbrev-commit`. You may
+	override this option with `\--no-abbrev-commit`.
+
 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/pretty-options.txt b/Documentation/pretty-options.txt
index d5c977262a..2a3dc8664f 100644
--- a/Documentation/pretty-options.txt
+++ b/Documentation/pretty-options.txt
@@ -19,6 +19,11 @@ configuration (see linkgit:git-config[1]).
 This should make "--pretty=oneline" a whole lot more readable for
 people using 80-column terminals.
 
+--no-abbrev-commit::
+	Show the full 40-byte hexadecimal commit object name. This negates
+	`--abbrev-commit` and those options which imply it such as
+	"--oneline". It also overrides the 'log.abbrevCommit' variable.
+
 --oneline::
 	This is a shorthand for "--pretty=oneline --abbrev-commit"
 	used together.
diff --git a/builtin/log.c b/builtin/log.c
index f6219909a7..540d1a473a 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;
 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);
@@ -92,7 +94,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 	int quiet = 0, source = 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"),
 		{ OPTION_CALLBACK, 0, "decorate", NULL, NULL, "decorate options",
 		  PARSE_OPT_OPTARG, decorate_callback},
@@ -323,6 +325,10 @@ 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 (!strcmp(var, "log.abbrevcommit")) {
+		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")) {
diff --git a/revision.c b/revision.c
index a7cf79bf2e..86028917e1 100644
--- a/revision.c
+++ b/revision.c
@@ -1429,6 +1429,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 			revs->abbrev = 40;
 	} else if (!strcmp(arg, "--abbrev-commit")) {
 		revs->abbrev_commit = 1;
+	} else if (!strcmp(arg, "--no-abbrev-commit")) {
+		revs->abbrev_commit = 0;
 	} else if (!strcmp(arg, "--full-diff")) {
 		revs->diff = 1;
 		revs->full_diff = 1;
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 2fcc31a6f3..a53a86a989 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -450,6 +450,18 @@ test_expect_success 'log.decorate configuration' '
 
 '
 
+test_expect_success 'log.abbrev-commit configuration' '
+	test_might_fail git config --remove-section log &&
+	test_when_finished "git config --unset log.abbrevCommit" &&
+	git log >expect.full &&
+	git log --abbrev-commit >expect.abbrev &&
+	git config log.abbrevCommit true &&
+	git log >actual.abbrev &&
+	test_cmp expect.abbrev actual.abbrev &&
+	git log --no-abbrev-commit >actual.full &&
+	test_cmp expect.full actual.full
+'
+
 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.1.290.g2f216.dirty

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

* Re: [PATCH v2] Add log.abbrevCommit config variable
  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
  0 siblings, 1 reply; 22+ messages in thread
From: Jonathan Nieder @ 2011-05-14 21:55 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, Junio C Hamano

Jay Soffian wrote:

> Add log.abbrevCommit config variable as a convenience for users who
> often use --abbrev-commit with git log and friends. Allow the option
> to be overridden with --no-abbrev-commit.

Based on a quick google code search, this will break scripts. :/
For example, tig uses "git log --pretty=raw" to get revision lists,
including expecting 40-digit commit ids.

But aside from that, this looks good to me.  I'm not sure what to
suggest: go out and spread the word about diff-tree? suppress this
configuration when --pretty or --format is passed?  There's no obvious
good answer.

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

* Re: [PATCH v2] Add log.abbrevCommit config variable
  2011-05-14 21:55     ` Jonathan Nieder
@ 2011-05-14 22:22       ` Jay Soffian
  2011-05-14 22:49         ` [PATCH v3] " Jay Soffian
  0 siblings, 1 reply; 22+ messages in thread
From: Jay Soffian @ 2011-05-14 22:22 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Junio C Hamano

On Sat, May 14, 2011 at 5:55 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Jay Soffian wrote:
>
>> Add log.abbrevCommit config variable as a convenience for users who
>> often use --abbrev-commit with git log and friends. Allow the option
>> to be overridden with --no-abbrev-commit.
>
> Based on a quick google code search, this will break scripts. :/
> For example, tig uses "git log --pretty=raw" to get revision lists,
> including expecting 40-digit commit ids.

Hmfph.

> But aside from that, this looks good to me.  I'm not sure what to
> suggest: go out and spread the word about diff-tree? suppress this
> configuration when --pretty or --format is passed?  There's no obvious
> good answer.

Ah, see:

- 635530a2fc (log --pretty/--oneline: ignore log.decorate, 2010-04-06)
- 4f62c2bc57 (log.decorate: only ignore it under "log --pretty=raw", 2010-04-08)

So I'll do the same thing for log.abbrevCommit.

j.

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

* [PATCH v3] Add log.abbrevCommit config variable
  2011-05-14 22:22       ` Jay Soffian
@ 2011-05-14 22:49         ` Jay Soffian
  2011-05-15 13:25           ` Jay Soffian
                             ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Jay Soffian @ 2011-05-14 22:49 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, Jonathan Nieder, Junio C Hamano

Add log.abbrevCommit config variable as a convenience for users who
often use --abbrev-commit with git log and friends. Allow the option
to be overridden with --no-abbrev-commit.

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

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
Changes from v2: ignore log.abbrevCommit when given --pretty=raw

 Documentation/config.txt         |    5 +++++
 Documentation/pretty-options.txt |    5 +++++
 builtin/log.c                    |   14 +++++++++++++-
 revision.c                       |    3 +++
 revision.h                       |    1 +
 t/t4202-log.sh                   |   15 +++++++++++++++
 6 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 285c7f73ca..8a3a1d08f7 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1314,6 +1314,11 @@ interactive.singlekey::
 	linkgit:git-checkout[1]. Note that this setting is silently
 	ignored if portable keystroke input is not available.
 
+log.abbrevCommit::
+	If true, makes linkgit:git-log[1], linkgit:git-show[1], and
+	linkgit:git-whatchanged[1] assume `\--abbrev-commit`. You may
+	override this option with `\--no-abbrev-commit`.
+
 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/pretty-options.txt b/Documentation/pretty-options.txt
index d5c977262a..2a3dc8664f 100644
--- a/Documentation/pretty-options.txt
+++ b/Documentation/pretty-options.txt
@@ -19,6 +19,11 @@ configuration (see linkgit:git-config[1]).
 This should make "--pretty=oneline" a whole lot more readable for
 people using 80-column terminals.
 
+--no-abbrev-commit::
+	Show the full 40-byte hexadecimal commit object name. This negates
+	`--abbrev-commit` and those options which imply it such as
+	"--oneline". It also overrides the 'log.abbrevCommit' variable.
+
 --oneline::
 	This is a shorthand for "--pretty=oneline --abbrev-commit"
 	used together.
diff --git a/builtin/log.c b/builtin/log.c
index f6219909a7..460fc15d8f 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;
 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);
@@ -92,7 +94,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 	int quiet = 0, source = 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"),
 		{ OPTION_CALLBACK, 0, "decorate", NULL, NULL, "decorate options",
 		  PARSE_OPT_OPTARG, decorate_callback},
@@ -137,6 +139,12 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 	    && rev->commit_format == CMIT_FMT_RAW)
 		decoration_style = 0;
 
+	/* ditto for log.abbrevCommit */
+	if (!rev->abbrev_commit_given && rev->abbrev_commit
+	    && rev->commit_format == CMIT_FMT_RAW)
+		rev->abbrev_commit = 0;
+
+
 	if (decoration_style) {
 		rev->show_decorations = 1;
 		load_ref_decorations(decoration_style);
@@ -323,6 +331,10 @@ 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 (!strcmp(var, "log.abbrevcommit")) {
+		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")) {
diff --git a/revision.c b/revision.c
index a7cf79bf2e..be74bf92f5 100644
--- a/revision.c
+++ b/revision.c
@@ -1429,6 +1429,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 			revs->abbrev = 40;
 	} else if (!strcmp(arg, "--abbrev-commit")) {
 		revs->abbrev_commit = 1;
+		revs->abbrev_commit_given = 1;
+	} else if (!strcmp(arg, "--no-abbrev-commit")) {
+		revs->abbrev_commit = 0;
 	} else if (!strcmp(arg, "--full-diff")) {
 		revs->diff = 1;
 		revs->full_diff = 1;
diff --git a/revision.h b/revision.h
index bca9947977..5e1f5c7e8f 100644
--- a/revision.h
+++ b/revision.h
@@ -90,6 +90,7 @@ struct rev_info {
 			show_notes_given:1,
 			pretty_given:1,
 			abbrev_commit:1,
+			abbrev_commit_given:1,
 			use_terminator:1,
 			missing_newline:1,
 			date_mode_explicit:1;
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 2fcc31a6f3..9e8afd65a2 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -450,6 +450,21 @@ test_expect_success 'log.decorate configuration' '
 
 '
 
+test_expect_success 'log.abbrev-commit configuration' '
+	test_might_fail git config --remove-section log &&
+	test_when_finished "git config --unset log.abbrevCommit" &&
+	git log >expect.full &&
+	git log --pretty=raw >expect.raw &&
+	git log --abbrev-commit >expect.abbrev &&
+	git config log.abbrevCommit true &&
+	git log >actual.abbrev &&
+	test_cmp expect.abbrev actual.abbrev &&
+	git log --no-abbrev-commit >actual.full &&
+	test_cmp expect.full actual.full &&
+	git log --pretty=raw >actual.raw &&
+	test_cmp expect.raw actual.raw
+'
+
 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.1.290.g992321

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

* Re: [PATCH] Add log.abbrev-commit config option
  2011-05-14 19:01 ` Jonathan Nieder
  2011-05-14 19:35   ` Jay Soffian
  2011-05-14 20:47   ` [PATCH v2] Add log.abbrevCommit config variable Jay Soffian
@ 2011-05-15  1:48   ` Junio C Hamano
  2011-05-16  8:24     ` Michael J Gruber
  2 siblings, 1 reply; 22+ messages in thread
From: Junio C Hamano @ 2011-05-15  1:48 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Jay Soffian, git

Jonathan Nieder <jrnieder@gmail.com> writes:

> Hm, that wouldn't have been my hunch.  Are you aware of any scripts
> that parse "git whatchanged" output?
>
> More worrying is "git log --format=raw".

Both are very sane worries. I am not interested at all in queuing this
change without any careful migration consideration.

Thanks.

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

* Re: [PATCH] add, merge, diff: do not use strcasecmp to compare config variable names
  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
  0 siblings, 0 replies; 22+ messages in thread
From: Junio C Hamano @ 2011-05-15  1:53 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Jay Soffian, git

Jonathan Nieder <jrnieder@gmail.com> writes:

> The config machinery already makes section and variable names
> lowercase when parsing them, so using strcasecmp for comparison just
> feels wasteful.  No noticeable change intended.

A quick "grep 'strcasecmp(va*r*, "[^"]*\.' yields exactly the ones covered
by this patch.

Thanks, I've been meaning to change these while reading merge-recursive.

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  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-17 18:50           ` Junio C Hamano
  2 siblings, 0 replies; 22+ messages in thread
From: Jay Soffian @ 2011-05-15 13:25 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, Jonathan Nieder, Junio C Hamano

On Sat, May 14, 2011 at 6:49 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> Add log.abbrevCommit config variable as a convenience for users who
> often use --abbrev-commit with git log and friends. Allow the option
> to be overridden with --no-abbrev-commit.
>
> (Also, a drive-by spelling correction in git log's short help.)
>
> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
> ---
> Changes from v2: ignore log.abbrevCommit when given --pretty=raw

Which I meant to mention in the commit message. Updated commit message:

---

Add log.abbrevCommit config variable

Add log.abbrevCommit config variable as a convenience for users who
often use --abbrev-commit with git log and friends. Allow the option
to be overridden with --no-abbrev-commit. Per 635530a2fc and 4f62c2bc57,
the config variable is ignored when log is given "--pretty=raw".

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

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  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-17 18:50           ` Junio C Hamano
  2 siblings, 1 reply; 22+ messages in thread
From: Junio C Hamano @ 2011-05-15 22:42 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, Jonathan Nieder

Jay Soffian <jaysoffian@gmail.com> writes:

> @@ -137,6 +139,12 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
>  	    && rev->commit_format == CMIT_FMT_RAW)
>  		decoration_style = 0;
>  
> +	/* ditto for log.abbrevCommit */
> +	if (!rev->abbrev_commit_given && rev->abbrev_commit
> +	    && rev->commit_format == CMIT_FMT_RAW)
> +		rev->abbrev_commit = 0;
> +
> +

I am not entirely happy about this change. The "ditto" refers to an ugly
workaround we had to add with 4f62c2b (log.decorate: only ignore it under
"log --pretty=raw", 2010-04-08) only because it was too late to revert the
change in 72d9b22 (Merge branch 'sd/log-decorate', 2010-05-08) that was
about to become part of 1.7.2-rc0 release. If we knew better, we probably
wouldn't have added the log.decorate variable that requires this hack that
requires us to say that 'log --pretty=raw' is special.

If we stop before adding a new configuration, we do not have to repeat the
same mistake we made earlier.

I dunno.

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  2011-05-15 22:42           ` Junio C Hamano
@ 2011-05-16  5:53             ` Jay Soffian
  2011-05-16  7:00               ` Jonathan Nieder
  0 siblings, 1 reply; 22+ messages in thread
From: Jay Soffian @ 2011-05-16  5:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jonathan Nieder

On Sun, May 15, 2011 at 6:42 PM, Junio C Hamano <gitster@pobox.com> wrote:
> I am not entirely happy about this change. The "ditto" refers to an ugly
> workaround we had to add with 4f62c2b (log.decorate: only ignore it under
> "log --pretty=raw", 2010-04-08) only because it was too late to revert the
> change in 72d9b22 (Merge branch 'sd/log-decorate', 2010-05-08) that was
> about to become part of 1.7.2-rc0 release. If we knew better, we probably
> wouldn't have added the log.decorate variable that requires this hack that
> requires us to say that 'log --pretty=raw' is special.
>
> If we stop before adding a new configuration, we do not have to repeat the
> same mistake we made earlier.
>
> I dunno.

I disagree that log.decorate is a mistake and that the workaround is
ugly. It would be nice if we didn't need the workaround, but I don't
think we should have to tie our hands because there are scripts that
are parsing git log's output. I think it's a pragmatic solution to
remaining backwards compatible while still being able to provide new
functionality.

FWIW, I use log.decorate, and I'd like to be able to use log.abbrevCommit.

j.

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  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
  0 siblings, 2 replies; 22+ messages in thread
From: Jonathan Nieder @ 2011-05-16  7:00 UTC (permalink / raw)
  To: Jay Soffian; +Cc: Junio C Hamano, git

Jay Soffian wrote:
> On Sun, May 15, 2011 at 6:42 PM, Junio C Hamano <gitster@pobox.com> wrote:

>> I am not entirely happy about this change. The "ditto" refers to an ugly
>> workaround we had to add with 4f62c2b (log.decorate: only ignore it under
>> "log --pretty=raw", 2010-04-08) only because it was too late to revert the
>> change in 72d9b22 (Merge branch 'sd/log-decorate', 2010-05-08) that was
>> about to become part of 1.7.2-rc0 release. If we knew better, we probably
>> wouldn't have added the log.decorate variable that requires this hack that
>> requires us to say that 'log --pretty=raw' is special.
>>
>> If we stop before adding a new configuration, we do not have to repeat the
>> same mistake we made earlier.
>>
>> I dunno.
>
> I disagree that log.decorate is a mistake and that the workaround is
> ugly.

I suppose part of what Junio is saying is that by the time the commits
referenced above were written, git had already broken some scripts
(including gitk) and those changes were part of a desparate attempt to
contain the damage.  So they are not a great example to look to for
the sort of smooth transition it is possible to set up proactively.

For example, maybe (after fixing the scripts we already know about,
such as tig) we could add the log.abbrevcommit variable right away but
advertise it as experimental:

	*Warning* This option is experimental and will break your
	scripts.  It is only provided to give script authors a
	chance to test this functionality and fix their scripts
	before the feature is advertised in earnest.

One transition plan could look like this:

 1. In the release notes to v1.7.6, mention that there is a change
    on the horizon that would break people's scripts and encourage
    script authors to switch to "rev-list | diff-tree -s --stdin"
    if their scripts depend on the details of "git log" format
    (in particular, if their scripts do not work correctly after
    s/log/log --abbrev-commit/).  Introduce the log.abbrevcommit
    variable to help people test, guarded by a compile-time
    option and disabled by default.

 2. In v1.7.7, introduce the log.abbrevcommit variable, advertised
    as "This will break your system --- don't use it unless you
    are trying to find such breakage and fix it".

 3. In v1.8.0, introduce the variable in earnest and recommend
    that people use it.

I think step 1 is going too far --- it should be possible to give
users rope like this without worrying that they are going to be
irresponsible about it.

Now, returning to "log --pretty=raw".  Is it plumbing or not?  It
would be nice to advertise whichever way it is decided (I guess it is
de facto plumbing) in the "git log" reference documentation and to
follow that decision in cases like this one.

Thanks for some food for thought.

Ciao,
Jonathan

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  2011-05-16  7:00               ` Jonathan Nieder
@ 2011-05-16  7:18                 ` Jay Soffian
  2011-05-17 17:03                 ` Junio C Hamano
  1 sibling, 0 replies; 22+ messages in thread
From: Jay Soffian @ 2011-05-16  7:18 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Junio C Hamano, git

On Mon, May 16, 2011 at 3:00 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> I suppose part of what Junio is saying is that by the time the commits
> referenced above were written, git had already broken some scripts
> (including gitk) and those changes were part of a desparate attempt to
> contain the damage.  So they are not a great example to look to for
> the sort of smooth transition it is possible to set up proactively.

Well, then why wasn't the change simply reverted?

> For example, maybe (after fixing the scripts we already know about,
> such as tig) we could add the log.abbrevcommit variable right away but
> advertise it as experimental:
>
>        *Warning* This option is experimental and will break your
>        scripts.  It is only provided to give script authors a
>        chance to test this functionality and fix their scripts
>        before the feature is advertised in earnest.
>
> One transition plan could look like this:
>
>  1. In the release notes to v1.7.6, mention that there is a change
>    on the horizon that would break people's scripts and encourage
>    script authors to switch to "rev-list | diff-tree -s --stdin"
>    if their scripts depend on the details of "git log" format
>    (in particular, if their scripts do not work correctly after
>    s/log/log --abbrev-commit/).  Introduce the log.abbrevcommit
>    variable to help people test, guarded by a compile-time
>    option and disabled by default.
>
>  2. In v1.7.7, introduce the log.abbrevcommit variable, advertised
>    as "This will break your system --- don't use it unless you
>    are trying to find such breakage and fix it".
>
>  3. In v1.8.0, introduce the variable in earnest and recommend
>    that people use it.
>
> I think step 1 is going too far --- it should be possible to give
> users rope like this without worrying that they are going to be
> irresponsible about it.
>
> Now, returning to "log --pretty=raw".  Is it plumbing or not?  It
> would be nice to advertise whichever way it is decided (I guess it is
> de facto plumbing) in the "git log" reference documentation and to
> follow that decision in cases like this one.

To my mind, we call "--pretty=raw" de-facto plumbing and keep the
change as is. Though perhaps, there is a cleaner implementation if we
say that --pretty=raw is indeed plumbing.

> Thanks for some food for thought.

And here I thought this was a simple one. :-(

j.

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

* Re: [PATCH] Add log.abbrev-commit config option
  2011-05-15  1:48   ` [PATCH] Add log.abbrev-commit config option Junio C Hamano
@ 2011-05-16  8:24     ` Michael J Gruber
  0 siblings, 0 replies; 22+ messages in thread
From: Michael J Gruber @ 2011-05-16  8:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jonathan Nieder, Jay Soffian, git

Junio C Hamano venit, vidit, dixit 15.05.2011 03:48:
> Jonathan Nieder <jrnieder@gmail.com> writes:
> 
>> Hm, that wouldn't have been my hunch.  Are you aware of any scripts
>> that parse "git whatchanged" output?
>>
>> More worrying is "git log --format=raw".
> 
> Both are very sane worries. I am not interested at all in queuing this
> change without any careful migration consideration.
> 
> Thanks.

Another instance of "config for option". Note that, again, it has the
same potential problems as a general approach...

Michael

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  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
  1 sibling, 1 reply; 22+ messages in thread
From: Junio C Hamano @ 2011-05-17 17:03 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Jay Soffian, git

Jonathan Nieder <jrnieder@gmail.com> writes:

> Jay Soffian wrote:
>> On Sun, May 15, 2011 at 6:42 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
>>> I am not entirely happy about this change. The "ditto" refers to an ugly
>>> workaround we had to add with 4f62c2b (log.decorate: only ignore it under
>>> "log --pretty=raw", 2010-04-08) only because it was too late to revert the
>>> change in 72d9b22 (Merge branch 'sd/log-decorate', 2010-05-08) that was
>>> about to become part of 1.7.2-rc0 release. If we knew better, we probably
>>> wouldn't have added the log.decorate variable that requires this hack that
>>> requires us to say that 'log --pretty=raw' is special.
>>>
>>> If we stop before adding a new configuration, we do not have to repeat the
>>> same mistake we made earlier.
>>>
>>> I dunno.
>>
>> I disagree that log.decorate is a mistake and that the workaround is
>> ugly.
>
> I suppose part of what Junio is saying is that by the time the commits
> referenced above were written, git had already broken some scripts
> (including gitk) and those changes were part of a desparate attempt to
> contain the damage.  So they are not a great example to look to for
> the sort of smooth transition it is possible to set up proactively.

Thanks for rephasing.

> One transition plan could look like this:
> ...
> Now, returning to "log --pretty=raw".  Is it plumbing or not?  It
> would be nice to advertise whichever way it is decided (I guess it is
> de facto plumbing) in the "git log" reference documentation and to
> follow that decision in cases like this one.
>
> Thanks for some food for thought.

Although I find the cop-out "if you set this variable, some third-party
tools may break---please do not complain to us, but send bug reports to
these third-party folks" somewhat attractive, I am reluctant to take that
position. I suspect some projects do work that way, and if it works for
them, it may turn out that we wouldn't get much flak doing so ourselves,
but still...

But having slept on this, I would agree that it is a pragmatic solution to
declare "pretty=raw _is_ special" and keep it that way.  Let's queue v3
from Jay and see what happens.

Thanks.

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  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-17 18:50           ` Junio C Hamano
  2011-05-17 19:08             ` Jay Soffian
  2 siblings, 1 reply; 22+ messages in thread
From: Junio C Hamano @ 2011-05-17 18:50 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, Jonathan Nieder

Jay Soffian <jaysoffian@gmail.com> writes:

> @@ -137,6 +139,12 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
>  	    && rev->commit_format == CMIT_FMT_RAW)
>  		decoration_style = 0;
>  
> +	/* ditto for log.abbrevCommit */
> +	if (!rev->abbrev_commit_given && rev->abbrev_commit
> +	    && rev->commit_format == CMIT_FMT_RAW)
> +		rev->abbrev_commit = 0;
> +
> +

This is not exactly "ditto"; the lines before this hunk look like this:

	/*
	 * defeat log.decorate configuration interacting with --pretty=raw
	 * from the command line.
	 */
	if (!decoration_given && rev->pretty_given
	    && rev->commit_format == CMIT_FMT_RAW)
		decoration_style = 0;

The check for pretty-given and commit-format being raw is to catch only
the case where the command line said --pretty=raw, excluding any case the
commit-format is set to raw without any explicit --pretty=raw on the
command line.  So at the logical level, this one should be read as if it
was written like this:

	if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
        	/* "log --pretty=raw" is special */
        	if (!decoration_given)
			decoration_style = 0;
	}

even though the existing one makes it look as if checking decoration-given
and pretty-given together when commit-format is set to raw.

Care to explain why your check has to be different?  If there is no reason
to use a different logic, then a natural thing to do is to rewrite the
existing decoration logic and add yours like this:

	if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
        	/* "log --pretty=raw" is special */
        	if (!decoration_given)
			decoration_style = 0;
		if (!abbrev_commit_given)
			rev->abbrev_commit = 0;
	}

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  2011-05-17 18:50           ` Junio C Hamano
@ 2011-05-17 19:08             ` Jay Soffian
  0 siblings, 0 replies; 22+ messages in thread
From: Jay Soffian @ 2011-05-17 19:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jonathan Nieder

On Tue, May 17, 2011 at 2:50 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Care to explain why your check has to be different?

It doesn't. I thought through it poorly.

> If there is no reason
> to use a different logic, then a natural thing to do is to rewrite the
> existing decoration logic and add yours like this:
>
>        if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
>                /* "log --pretty=raw" is special */
>                if (!decoration_given)
>                        decoration_style = 0;
>                if (!abbrev_commit_given)
>                        rev->abbrev_commit = 0;
>        }

It would be lovely if you could squash that in.

Thanks,

j.

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  2011-05-17 17:03                 ` Junio C Hamano
@ 2011-05-17 21:50                   ` Junio C Hamano
  2011-05-18  1:05                     ` Jay Soffian
  0 siblings, 1 reply; 22+ messages in thread
From: Junio C Hamano @ 2011-05-17 21:50 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

> But having slept on this, I would agree that it is a pragmatic solution to
> declare "pretty=raw _is_ special" and keep it that way.  Let's queue v3
> from Jay and see what happens.

Having looked at this a bit more, there seems to be a special case in
cmd_log_reflog() that the command wants to default to abbrevCommit.

I haven't applied v3 (nor my fix-up in the discussion) yet, as this is not
my itch, but have you tested all commands from "log" family with your
patch, including "git reflog"?

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

* Re: [PATCH v3] Add log.abbrevCommit config variable
  2011-05-17 21:50                   ` Junio C Hamano
@ 2011-05-18  1:05                     ` Jay Soffian
  0 siblings, 0 replies; 22+ messages in thread
From: Jay Soffian @ 2011-05-18  1:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Tue, May 17, 2011 at 5:50 PM, Junio C Hamano <gitster@pobox.com> wrote:
> I haven't applied v3 (nor my fix-up in the discussion) yet, as this is not
> my itch, but have you tested all commands from "log" family with your
> patch, including "git reflog"?

Gah. Thank you for catching that, I had checked it (I think) with v1.
I should've added a test then, which I've done for v4. Sending
shortly.

j.

^ permalink raw reply	[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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.