From: Jay Soffian <hidden> Date: 2016-06-15 22:51:14
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 <redacted>
---
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(-)
@@ -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
@@ -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
@@ -23,6 +23,7 @@/* Set a default date-time format for git log ("log.date" config variable) */staticconstchar*default_date_mode=NULL;+staticintdefault_abbrev_commit=0;staticintdefault_show_root=1;staticintdecoration_style;staticintdecoration_given;
@@ -450,6 +450,14 @@ test_expect_success 'log.decorate configuration' ''+test_expect_success'log.abbrev-commit configuration''+test_might_failgitconfig--remove-sectionlog&&+gitlog--abbrev-commit>expect&&+gitconfiglog.abbrev-committrue&&+gitlog>actual&&+test_cmpexpectactual+'+ test_expect_success'show added path under "--follow -M"''# This tests for a regression introduced in v1.7.2-rc0~103^2~2test_create_reporegression&&
From: Jay Soffian <hidden> Date: 2016-06-15 22:51:14
On Sat, May 14, 2011 at 1:22 PM, Jay Soffian [off-list ref] 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.
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.
@@ -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.
@@ -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?
quoted hunk
--- 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) */staticconstchar*default_date_mode=NULL;+staticintdefault_abbrev_commit=0;staticintdefault_show_root=1;staticintdecoration_style;
Style: we try to avoid unnecessary zero initializers for variables in
the BSS section.
[...]
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.
[...]
quoted hunk
@@ -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.
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
From: Jay Soffian <hidden> Date: 2016-06-15 22:51:14
On Sat, May 14, 2011 at 3:01 PM, Jonathan Nieder [off-list ref] 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.
quoted
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.
quoted hunk
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").
quoted
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.
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.
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
quoted
--- 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.
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.
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.
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.
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:51:14
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 [off-list ref]
Signed-off-by: Jonathan Nieder <redacted>
---
Jay Soffian wrote:
On Sat, May 14, 2011 at 3:01 PM, Jonathan Nieder [off-list ref] wrote:
quoted
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,7 +347,7 @@ int git_xmerge_style = -1;intgit_xmerge_config(constchar*var,constchar*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"))
From: Jay Soffian <hidden> Date: 2016-06-15 22:51:14
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 <redacted>
---
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(-)
@@ -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
@@ -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.
@@ -23,6 +23,7 @@/* Set a default date-time format for git log ("log.date" config variable) */staticconstchar*default_date_mode=NULL;+staticintdefault_abbrev_commit;staticintdefault_show_root=1;staticintdecoration_style;staticintdecoration_given;
From: Jonathan Nieder <hidden> Date: 2016-06-15 22:51:14
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.
From: Jay Soffian <hidden> Date: 2016-06-15 22:51:14
On Sat, May 14, 2011 at 5:55 PM, Jonathan Nieder [off-list ref] wrote:
Jay Soffian wrote:
quoted
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.
From: Jay Soffian <hidden> Date: 2016-06-15 22:51:14
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 <redacted>
---
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(-)
@@ -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
@@ -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.
@@ -23,6 +23,7 @@/* Set a default date-time format for git log ("log.date" config variable) */staticconstchar*default_date_mode=NULL;+staticintdefault_abbrev_commit;staticintdefault_show_root=1;staticintdecoration_style;staticintdecoration_given;
From: Jay Soffian <hidden> Date: 2016-06-15 22:51:14
On Sat, May 14, 2011 at 6:49 PM, Jay Soffian [off-list ref] 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 <redacted>
---
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 <redacted>