mirror of
https://github.com/git/git.git
synced 2024-10-28 04:49:43 +01:00
Merge branch 'wm/shortlog-hash'
Teaches 'shortlog' to explicitly use SHA-1 when operating outside of a repository. * wm/shortlog-hash: builtin/shortlog: explicitly set hash algo when there is no repo
This commit is contained in:
commit
55d12c24d7
2 changed files with 16 additions and 0 deletions
|
@ -407,6 +407,18 @@ int cmd_shortlog(int argc,
|
|||
|
||||
struct parse_opt_ctx_t ctx;
|
||||
|
||||
/*
|
||||
* NEEDSWORK: Later on we'll call parse_revision_opt which relies on
|
||||
* the hash algorithm being set but since we are operating outside of a
|
||||
* Git repository we cannot determine one. This is only needed because
|
||||
* parse_revision_opt expects hexsz for --abbrev which is irrelevant
|
||||
* for shortlog outside of a git repository. For now explicitly set
|
||||
* SHA1, but ideally the parsing machinery would be split between
|
||||
* git/nongit so that we do not have to do this.
|
||||
*/
|
||||
if (nongit && !the_hash_algo)
|
||||
repo_set_hash_algo(the_repository, GIT_HASH_SHA1);
|
||||
|
||||
git_config(git_default_config, NULL);
|
||||
shortlog_init(&log);
|
||||
repo_init_revisions(the_repository, &rev, prefix);
|
||||
|
|
|
@ -143,6 +143,10 @@ test_expect_success 'shortlog from non-git directory refuses extra arguments' '
|
|||
test_grep "too many arguments" out
|
||||
'
|
||||
|
||||
test_expect_success 'shortlog --author from non-git directory does not segfault' '
|
||||
nongit git shortlog --author=author </dev/null
|
||||
'
|
||||
|
||||
test_expect_success 'shortlog should add newline when input line matches wraplen' '
|
||||
cat >expect <<\EOF &&
|
||||
A U Thor (2):
|
||||
|
|
Loading…
Reference in a new issue