Re: feature request: better support for typos
I believe They mean that if you type clone --branch mister, it should ask if you meant to clone --branch master instead, or something. Basically if you type a non existent branch name, calculate edit distance for each branch name, probably either using a timeout or edit distance to stop if something is too different from any branch so you don't run for too long, and then, if a branch is within a certain edit distance from the typo, suggest it. Lawrence On Sat, Aug 15, 2015 at 2:12 AM, Duy Nguyen pclo...@gmail.com wrote: On Sat, Aug 8, 2015 at 1:12 AM, Ralf Thielow ralf.thie...@gmail.com wrote: Hi, when a user made a typo, Git is not good in guessing what the user could have meant, except for git commands. I think this is an area with room for improvements. Let's look into branches. When I clone --branch and make a typo, Git could show me what branch I could have meant. It's the same when I try to merge or track a branch. Good candidate for those micro-projects next year. It might even be possible to show suggestions for options for all Git commands. You mean if you type --brnch it should suggest --branch? I was bugged about this and wanted to do something, only to realize in most cases git would show git cmd -h, which does a much better job because it would explain what --branch is for as well. What I'm trying to say is, there are arguments with a limited amount of possible values that Git know, so Git can show suggestions when the user made a typo for such an argument. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- About Me: http://about.me/lawrencesiebert Constantly Coding: http://constantcoding.blogspot.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] --count feature for git shortlog
On Fri, Jul 3, 2015 at 10:31 AM, Junio C Hamano gits...@pobox.com wrote: John Keeping j...@keeping.me.uk writes: On Tue, Jun 30, 2015 at 02:10:49PM +0200, Johannes Schindelin wrote: On 2015-06-29 18:46, Lawrence Siebert wrote: I appreciate your help. Okay, That all makes sense. I would note that something like: git shortlog -s $FILENAME: | cut -f 1 | paste -sd+ - | bc seems like it run much faster then: git log --oneline $FILENAME | wc -l How does it compare to `git rev-list -- $FILENAME | wc -l`? Or even `git rev-list --count HEAD -- $FILENAME`. Ahh, OK. I didn't know we already had rev-list --count. Then please disregard the suggestion to add the option to log; it still holds true that the option does not belong to shortlog, but I do think how many changes were made to this path statistics driven by a script should use rev-list plumbing, and if it already has --count option, that is perfect ;-) Thanks. Junio, I think, respectfully, there is still a benefit to adding it as a feature to log, in that more Git users know of and use log than rev-list. I hadn't heard of rev-list before joining this mailing list. That means log --count will get used more. That also means that more eyeballs will hit --count with bug reports and better tests; I've already seen 2-3 suggestions for log --count tests that rev-list --count also doesn't have tests for. I would like to keep working on implementing log --count, sharing code with rev-list where possible so they both are improved, unless you are saying you won't merge. Thanks, Lawrence -- About Me: http://about.me/lawrencesiebert Constantly Coding: http://constantcoding.blogspot.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] list-object: add get_commit_count function
Mattieu, Understood. I don't suppose there is any commonly code formatting tool to automate formatting in the git style, is there? Thanks, Lawrence On Fri, Jul 3, 2015 at 12:24 AM, Matthieu Moy matthieu@grenoble-inp.fr wrote: Lawrence Siebert lawrencesieb...@gmail.com writes: +void get_commit_count(struct rev_info * revs) { Please, write struct rev_info *revs (stick * to revs). +void get_commit_count(struct rev_info * revs); Likewise. -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- About Me: http://about.me/lawrencesiebert Constantly Coding: http://constantcoding.blogspot.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/4] log: add --count option to git log
traverse_commit_list requires a function to be passed to it. That said, after further review it can probably pass NULL and have it work fine. If not, I'll use your naming convention. `git rev-list --count` (or actually `git rev-list --count HEAD`, which this borrows the code from, produces a single value, a numeric count. I think walking the entire list is necessary to get the final value, which is what we want with --count. Thanks, Lawrence Siebert On Fri, Jul 3, 2015 at 12:29 AM, Matthieu Moy matthieu@grenoble-inp.fr wrote: Lawrence Siebert lawrencesieb...@gmail.com writes: +static void show_object(struct object *obj, + const struct name_path *path, const char *component, + void *cb_data) +{ + return; +} It seems streange to me to have a function named show_object when it does not show anything. Maybe name it null_travers_cb to make it clear it's a callback and it does nothing? Not a strong objection though, it's only a static function. +static void show_commit(struct commit *commit, void *data) +{ + struct rev_info *revs = (struct rev_info *)data; + if (commit-object.flags PATCHSAME) + revs-count_same++; + else if (commit-object.flags SYMMETRIC_LEFT) + revs-count_left++; + else + revs-count_right++; + if (commit-parents) { + free_commit_list(commit-parents); + commit-parents = NULL; + } + free_commit_buffer(commit); +} + static int cmd_log_walk(struct rev_info *rev) { struct commit *commit; int saved_nrl = 0; int saved_dcctc = 0; + if (rev-count) { + prepare_revision_walk(rev); + traverse_commit_list(rev, show_commit, show_object, rev); + get_commit_count(rev); + } I didn't test, but it seems this does a full graph traversal before starting the output. A very important property of git log is that it starts showing revisions immediately, even when ran on a very long history (it shows the first screen immediately and continues working in the background while the first page is displayed in the pager). Is it the case? If so, it should be changed. If not, perhaps explain why in the commit message. -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- About Me: http://about.me/lawrencesiebert Constantly Coding: http://constantcoding.blogspot.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/4] log --count: added test
Matthieu, Ok, I'll fix that. I think I can also add tests, I can look at the tests for rev-list --count, with the understanding that I saw somebody else had made changes for the --use-bitmap-index option, and I am basing off of master for this, and thus don't feel comfortable with --use-bitmap-index at this time. If it's acceptable practice, I'll just squash everything I do on this feature and it's tests into one commit with a more detailed comment, and send the patch for that. I wasn't sure about how much history I should save, and how much I should split stuff up, so I appreciate your clarification. Thank you for your time, Lawrence Siebert On Fri, Jul 3, 2015 at 12:34 AM, Matthieu Moy matthieu@grenoble-inp.fr wrote: Lawrence Siebert lawrencesieb...@gmail.com writes: added test comparing output between git log --count HEAD and git rev-list --count HEAD Unless there is a very long list of tests, I'd rather see this squashed with PATCH 2/4. As a reviewer I prefer having code and tests in the same place. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- t/t4202-log.sh | 7 +++ 1 file changed, 7 insertions(+) diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 1b2e981..35f8d82 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -871,4 +871,11 @@ test_expect_success 'log --graph --no-walk is forbidden' ' test_must_fail git log --graph --no-walk ' +test_expect_success 'log --count' ' + git log --count HEAD actual + git rev-list --count HEAD expect The weird space is still there. Also, we write actual, not actual in the Git coding style. That is actually a rather weak test. rev-list --count interacts with --left-right, so I guess you want to test --count --left-right. Also, some revision-limiting options can reduce the count like git log --grep whatever and you should check that you actually count the right number here. (I don't know this part of the code enough, but I'm not sure you actually deal with this properly) -- Matthieu Moy http://www-verimag.imag.fr/~moy/ -- About Me: http://about.me/lawrencesiebert Constantly Coding: http://constantcoding.blogspot.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] log: add --count option to git log
Thanks. I've modified my vim config to avoid this happening again, and i'll submit a fixed version of these patches. I'd love if there was a precommit hook to test for this. Lawrence On Thu, Jul 2, 2015 at 2:14 AM, Remi Galan Alfonso remi.galan-alfo...@ensimag.grenoble-inp.fr wrote: Lawrence Siebert lawrencesieb...@gmail.com writes: +prepare_revision_walk(rev); There's trailing whitespace here. (See my message in 3/4) RĂ©mi -- About Me: http://about.me/lawrencesiebert Constantly Coding: http://constantcoding.blogspot.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 4/4] git-log: update man documentation for --count
I'm not altogether sure the best way to update the internal usage from git-log -h, but this at least updates the man page. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- Documentation/git-log.txt | 2 ++ Documentation/rev-list-options.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 5692945..0e10e44 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -90,6 +90,8 @@ include::line-range-format.txt[] Paths may need to be prefixed with ``\-- '' to separate them from options or the revision range, when confusion arises. + +:git-log: 1 include::rev-list-options.txt[] include::pretty-formats.txt[] diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 77ac439..f4e15fb 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -797,7 +797,7 @@ This implies the `--topo-order` option by default, but the in between them in that case. If `barrier` is specified, it is the string that will be shown instead of the default one. -ifdef::git-rev-list[] +ifdef::git-log,git-rev-list[] --count:: Print a number stating how many commits would have been listed, and suppress all other output. When used together -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/4] git log --count
This should fix the whitespace issues this had previously. Lawrence Siebert (4): list-object: add get_commit_count function log: add --count option to git log log --count: added test git-log: update man documentation for --count Documentation/git-log.txt | 2 ++ Documentation/rev-list-options.txt | 2 +- builtin/log.c | 29 + builtin/rev-list.c | 12 ++-- list-objects.c | 14 ++ list-objects.h | 1 + t/t4202-log.sh | 7 +++ 7 files changed, 56 insertions(+), 11 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/4] log: add --count option to git log
adds --count from git rev-list to git log, without --use-bitmap-index for the moment. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- builtin/log.c | 29 + 1 file changed, 29 insertions(+) diff --git a/builtin/log.c b/builtin/log.c index 8781049..4aaff3a 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -25,6 +25,7 @@ #include version.h #include mailmap.h #include gpg-interface.h +#include list-objects.h /* Set a default date-time format for git log (log.date config variable) */ static const char *default_date_mode = NULL; @@ -317,12 +318,40 @@ static void finish_early_output(struct rev_info *rev) show_early_header(rev, done, n); } +static void show_object(struct object *obj, + const struct name_path *path, const char *component, + void *cb_data) +{ + return; +} + +static void show_commit(struct commit *commit, void *data) +{ + struct rev_info *revs = (struct rev_info *)data; + if (commit-object.flags PATCHSAME) + revs-count_same++; + else if (commit-object.flags SYMMETRIC_LEFT) + revs-count_left++; + else + revs-count_right++; + if (commit-parents) { + free_commit_list(commit-parents); + commit-parents = NULL; + } + free_commit_buffer(commit); +} + static int cmd_log_walk(struct rev_info *rev) { struct commit *commit; int saved_nrl = 0; int saved_dcctc = 0; + if (rev-count) { + prepare_revision_walk(rev); + traverse_commit_list(rev, show_commit, show_object, rev); + get_commit_count(rev); + } if (rev-early_output) setup_early_output(rev); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/4] log --count: added test
added test comparing output between git log --count HEAD and git rev-list --count HEAD Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- t/t4202-log.sh | 7 +++ 1 file changed, 7 insertions(+) diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 1b2e981..35f8d82 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -871,4 +871,11 @@ test_expect_success 'log --graph --no-walk is forbidden' ' test_must_fail git log --graph --no-walk ' +test_expect_success 'log --count' ' + git log --count HEAD actual + git rev-list --count HEAD expect + test_cmp expect actual +' + + test_done -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/4] list-object: add get_commit_count function
Moving commit counting from rev-list into list-object which is a step toward letting git log do counting as well. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- builtin/rev-list.c | 12 ++-- list-objects.c | 14 ++ list-objects.h | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/builtin/rev-list.c b/builtin/rev-list.c index ff84a82..07f522b 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -388,16 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) traverse_commit_list(revs, show_commit, show_object, info); - if (revs.count) { - if (revs.left_right revs.cherry_mark) - printf(%d\t%d\t%d\n, revs.count_left, revs.count_right, revs.count_same); - else if (revs.left_right) - printf(%d\t%d\n, revs.count_left, revs.count_right); - else if (revs.cherry_mark) - printf(%d\t%d\n, revs.count_left + revs.count_right, revs.count_same); - else - printf(%d\n, revs.count_left + revs.count_right); - } + if (revs.count) + get_commit_count(revs); return 0; } diff --git a/list-objects.c b/list-objects.c index 41736d2..6f76301 100644 --- a/list-objects.c +++ b/list-objects.c @@ -234,3 +234,17 @@ void traverse_commit_list(struct rev_info *revs, object_array_clear(revs-pending); strbuf_release(base); } + +void get_commit_count(struct rev_info * revs) { + if (revs-count) { + if (revs-left_right revs-cherry_mark) + printf(%d\t%d\t%d\n, revs-count_left, revs-count_right, revs-count_same); + else if (revs-left_right) + printf(%d\t%d\n, revs-count_left, revs-count_right); + else if (revs-cherry_mark) + printf(%d\t%d\n, revs-count_left + revs-count_right, revs-count_same); + else + printf(%d\n, revs-count_left + revs-count_right); + } + return; +} diff --git a/list-objects.h b/list-objects.h index 136a1da..d28c1f3 100644 --- a/list-objects.h +++ b/list-objects.h @@ -7,5 +7,6 @@ void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, voi typedef void (*show_edge_fn)(struct commit *); void mark_edges_uninteresting(struct rev_info *, show_edge_fn); +void get_commit_count(struct rev_info * revs); #endif -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] rev-list: add --count to usage guide
--count should be mentioned in the usage guide, this updates code and documentation. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- Documentation/git-rev-list.txt | 1 + builtin/rev-list.c | 1 + 2 files changed, 2 insertions(+) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index b10ea60..7b49c85 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -56,6 +56,7 @@ SYNOPSIS [ --reverse ] [ --walk-reflogs ] [ --no-walk ] [ --do-walk ] +[ --count ] [ --use-bitmap-index ] commit... [ \-- paths... ] diff --git a/builtin/rev-list.c b/builtin/rev-list.c index ff84a82..ee9e872 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -42,6 +42,7 @@ static const char rev_list_usage[] = --abbrev=n | --no-abbrev\n --abbrev-commit\n --left-right\n +--count\n special purpose:\n --bisect\n --bisect-vars\n -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] list-object: add get_commit_count function
Moving commit counting from rev-list into list-object which is a step toward letting git log do counting as well. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- builtin/rev-list.c | 12 ++-- list-objects.c | 14 ++ list-objects.h | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/builtin/rev-list.c b/builtin/rev-list.c index ff84a82..7b091db 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -388,16 +388,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) traverse_commit_list(revs, show_commit, show_object, info); - if (revs.count) { - if (revs.left_right revs.cherry_mark) - printf(%d\t%d\t%d\n, revs.count_left, revs.count_right, revs.count_same); - else if (revs.left_right) - printf(%d\t%d\n, revs.count_left, revs.count_right); - else if (revs.cherry_mark) - printf(%d\t%d\n, revs.count_left + revs.count_right, revs.count_same); - else - printf(%d\n, revs.count_left + revs.count_right); - } + if (revs.count) + get_commit_count(revs); return 0; } diff --git a/list-objects.c b/list-objects.c index 41736d2..6f76301 100644 --- a/list-objects.c +++ b/list-objects.c @@ -234,3 +234,17 @@ void traverse_commit_list(struct rev_info *revs, object_array_clear(revs-pending); strbuf_release(base); } + +void get_commit_count(struct rev_info * revs) { + if (revs-count) { + if (revs-left_right revs-cherry_mark) + printf(%d\t%d\t%d\n, revs-count_left, revs-count_right, revs-count_same); + else if (revs-left_right) + printf(%d\t%d\n, revs-count_left, revs-count_right); + else if (revs-cherry_mark) + printf(%d\t%d\n, revs-count_left + revs-count_right, revs-count_same); + else + printf(%d\n, revs-count_left + revs-count_right); + } + return; +} diff --git a/list-objects.h b/list-objects.h index 136a1da..d28c1f3 100644 --- a/list-objects.h +++ b/list-objects.h @@ -7,5 +7,6 @@ void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, voi typedef void (*show_edge_fn)(struct commit *); void mark_edges_uninteresting(struct rev_info *, show_edge_fn); +void get_commit_count(struct rev_info * revs); #endif -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/4] log: add --count option to git log
adds --count from git rev-list to git log, without --use-bitmap-index for the moment. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- builtin/log.c | 29 + 1 file changed, 29 insertions(+) diff --git a/builtin/log.c b/builtin/log.c index 8781049..ce6df1e 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -25,6 +25,7 @@ #include version.h #include mailmap.h #include gpg-interface.h +#include list-objects.h /* Set a default date-time format for git log (log.date config variable) */ static const char *default_date_mode = NULL; @@ -317,12 +318,40 @@ static void finish_early_output(struct rev_info *rev) show_early_header(rev, done, n); } +static void show_object(struct object *obj, + const struct name_path *path, const char *component, + void *cb_data) +{ + return; +} + +static void show_commit(struct commit *commit, void *data) +{ + struct rev_info *revs = (struct rev_info *)data; + if (commit-object.flags PATCHSAME) + revs-count_same++; + else if (commit-object.flags SYMMETRIC_LEFT) + revs-count_left++; + else + revs-count_right++; + if (commit-parents) { + free_commit_list(commit-parents); + commit-parents = NULL; + } + free_commit_buffer(commit); +} + static int cmd_log_walk(struct rev_info *rev) { struct commit *commit; int saved_nrl = 0; int saved_dcctc = 0; + if (rev-count) { + prepare_revision_walk(rev); + traverse_commit_list(rev, show_commit, show_object, rev); + get_commit_count(rev); + } if (rev-early_output) setup_early_output(rev); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] git-log: update man documentation for --count
I'm not altogether sure the best way to update the internal usage from git-log -h, but this at least updates the man page. Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- Documentation/git-log.txt | 2 ++ Documentation/rev-list-options.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt index 5692945..0e10e44 100644 --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@ -90,6 +90,8 @@ include::line-range-format.txt[] Paths may need to be prefixed with ``\-- '' to separate them from options or the revision range, when confusion arises. + +:git-log: 1 include::rev-list-options.txt[] include::pretty-formats.txt[] diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 77ac439..f4e15fb 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -797,7 +797,7 @@ This implies the `--topo-order` option by default, but the in between them in that case. If `barrier` is specified, it is the string that will be shown instead of the default one. -ifdef::git-rev-list[] +ifdef::git-log,git-rev-list[] --count:: Print a number stating how many commits would have been listed, and suppress all other output. When used together -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] log --count: added test
added test comparing output between git log --count HEAD and git rev-list --count HEAD Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- t/t4202-log.sh | 7 +++ 1 file changed, 7 insertions(+) diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 1b2e981..077952b 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -871,4 +871,11 @@ test_expect_success 'log --graph --no-walk is forbidden' ' test_must_fail git log --graph --no-walk ' +test_expect_success 'log --count' ' + git log --count HEAD actual + git rev-list --count HEAD expect + test_cmp expect actual +' + + test_done -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] --count feature for git shortlog
Vincent, I'm ccing you because of --use-bitmap-index John, Johannes, I really appreciate both your thoughts. `git rev-list --count HEAD -- $FILENAME` runs noticeably faster then my patch code for `git shortlog --count`, git shortlog -s $FILENAME | cut -f 1 | paste -sd+ -|bc, and faster than any use of piping to wc -l mentioned so far. Anyway I think Junio is quite right that my code doesn't belong in shortlog, at least as it currently is. I have some ideas for future work for myself, both code and documentation changes. I can detail it and get comments first, or just submit patches and get comments after, whichever is the preferred practice. One in particular is worth mentioning. The following doesn't currently run: `git rev-list --count --use-bitmap-index HEAD` This is an optional parameter for rev-list from commit aa32939fea9c8934b41efce56015732fa12b8247 which can't currently be used because of changes in parameter parsing, but which modifies `--count` and which may be faster. I've gotten it working again, both by changing the current repo code to make it work, and also by building from that commit, and when I tested it on the whole repo, it seems like it's less variable in speed then `git rev-list --count HEAD`. but not necessarily consistently faster like tests suggested it was when it was committed. Obviously I'm not testing on the same system as the original committer, or with the same compiler, or even using the same version of the linux kernel repo, so those may be a factor. It may also work better in a circumstance that I haven't accounted for, like an older repo, on a per file basis when getting per file commit counts for all files, or something like that. I'm thinking I could submit a patch that makes it work again, and leave it to the user to decide whether to use it or not. There is also a --test-bitmap option which compares the regular count with the bitmap count. I'm not sure if the implication there was regression testing or that --use-bitmap-index might give the wrong results in certain circumstances. Vincent, could you clarify? Thanks, Lawrence Siebert http://www.github.com/gryftir On Tue, Jun 30, 2015 at 5:23 AM, John Keeping j...@keeping.me.uk wrote: On Tue, Jun 30, 2015 at 02:10:49PM +0200, Johannes Schindelin wrote: On 2015-06-29 18:46, Lawrence Siebert wrote: I appreciate your help. Okay, That all makes sense. I would note that something like: git shortlog -s $FILENAME: | cut -f 1 | paste -sd+ - | bc seems like it run much faster then: git log --oneline $FILENAME | wc -l How does it compare to `git rev-list -- $FILENAME | wc -l`? Or even `git rev-list --count HEAD -- $FILENAME`. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] --count feature for git shortlog
Junio, I appreciate your help. Okay, That all makes sense. I would note that something like: git shortlog -s $FILENAME: | cut -f 1 | paste -sd+ - | bc seems like it run much faster then: git log --oneline $FILENAME | wc -l Which was why I was looking at shortlog. I was using it to sort files by commit count when provided a list of files, which git rev-list doesn't really work for. Anyway I can try and put it in log proper, if you think that's the best place. Thank you, Lawrence Siebert -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] --count feature for git shortlog
My apologies, I misunderstood and thought rev-list didn't take filenames. Lawrence Siebert On Mon, Jun 29, 2015 at 10:04 AM, Junio C Hamano gits...@pobox.com wrote: Lawrence Siebert lawrencesieb...@gmail.com writes: I was using it to sort files by commit count when provided a list of files, which git rev-list doesn't really work for. What makes you say rev-list does not work (perhaps 'really' is the key word there?) git rev-list --no-merges maint..master -- Makefile git shortlog --no-merges maint..master -- Makefile git log --oneline --no-merges maint..master -- Makefile all gives me results that are consistent among them. -- About Me: http://about.me/lawrencesiebert Constantly Coding: http://constantcoding.blogspot.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] --count feature for git shortlog
Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- t/t4201-shortlog.sh | 5 + 1 file changed, 5 insertions(+) diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 7600a3e..33ecb4a 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -194,4 +194,9 @@ test_expect_success 'shortlog with revision pseudo options' ' git shortlog --exclude=refs/heads/m* --all ' +test_expect_success 'shortlog --count' ' + git shortlog --count HEAD actual + echo 4 expect + test_cmp expect actual' + test_done -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] --count feature for git shortlog
--summary is per author --count counts all Signed-off-by: Lawrence Siebert lawrencesieb...@gmail.com --- builtin/shortlog.c | 14 +- shortlog.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/builtin/shortlog.c b/builtin/shortlog.c index c0bab6a..4b79dc8 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -226,8 +226,10 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) int nongit = !startup_info-have_repository; static const struct option options[] = { +OPT_BOOL('N', count, log.show_count, + N_(display the total number of commits for all authors)), OPT_BOOL('n', numbered, log.sort_by_number, -N_(sort output according to the number of commits per author)), +N_(Sort output according to the number of commits per author)), OPT_BOOL('s', summary, log.summary, N_(Suppress commit descriptions, only provides commit count)), OPT_BOOL('e', email, log.email, @@ -290,8 +292,8 @@ static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s, void shortlog_output(struct shortlog *log) { int i, j; + unsigned int count = 0; struct strbuf sb = STRBUF_INIT; - if (log-sort_by_number) qsort(log-list.items, log-list.nr, sizeof(struct string_list_item), compare_by_number); @@ -300,7 +302,9 @@ void shortlog_output(struct shortlog *log) if (log-summary) { printf(%6d\t%s\n, onelines-nr, log-list.items[i].string); - } else { + } else if (log-show_count) { +count += onelines-nr; +} else { printf(%s (%d):\n, log-list.items[i].string, onelines-nr); for (j = onelines-nr - 1; j = 0; j--) { const char *msg = onelines-items[j].string; @@ -315,13 +319,13 @@ void shortlog_output(struct shortlog *log) } putchar('\n'); } - onelines-strdup_strings = 1; string_list_clear(onelines, 0); free(onelines); log-list.items[i].util = NULL; } - + if (log-show_count) +printf(%d\n, count); strbuf_release(sb); log-list.strdup_strings = 1; string_list_clear(log-list, 1); diff --git a/shortlog.h b/shortlog.h index de4f86f..57797b7 100644 --- a/shortlog.h +++ b/shortlog.h @@ -8,6 +8,7 @@ struct shortlog { int summary; int wrap_lines; int sort_by_number; + int show_count; int wrap; int in1; int in2; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] --count feature for git shortlog
This is a new feature for short log, which lets you count commits on a per file or repository basis easily. Currently if you want a total count of commits with shortlog, you would need to add up each authors commits after using --summary. This adds a -N / --count option to shortlog for this purpose. I also created a test. It's not a great test, but it works. I'm sure I've make a beginner mistake in some part of the process; I've done my best to follow documentation, so please be explicit when you tell me I've done something wrong. Thanks, Lawrence Siebert Lawrence Siebert (2): shortlog: -N/--count option shortlog: added --count test builtin/shortlog.c | 14 +- shortlog.h | 1 + t/t4201-shortlog.sh | 5 + 3 files changed, 15 insertions(+), 5 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html