{"thread":{"id":"40775","subject":"Suspected bug on `git -C <rp> rev-list --all` where <rp> has 0 commits","startedAt":"2015-11-11T18:26:34Z","lastAt":"2015-11-25T09:10:11Z","messageCount":5,"participants":["yac","Atousa Duprat","atousa.p@gmail.com","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"273202","messageId":"20151111192634.629102e6@linux-apw9.site","threadId":"40775","inReplyTo":null,"subject":"Suspected bug on `git -C <rp> rev-list --all` where <rp> has 0 commits","fromName":"yac","fromEmail":"yac@blesmrt.net","sentAt":"2015-11-11T18:26:34Z","receivedAt":"2015-11-11T18:26:34Z","isPatch":false,"sender":{"key":"yac@blesmrt.net","avatar":null},"body":"Hello\n\nbasics:\n\n% rpm -q git git-core\ngit-2.6.2-2.1.x86_64\ngit-core-2.6.2-2.1.x86_64\n\n~ % grep PRETTY_NAME /etc/os-release\nPRETTY_NAME=\"openSUSE Tumbleweed (20151030) (x86_64)\"\n\ncurrent behavior:\n\n~ % git init no-commits\nInitialized empty Git repository in /home/tester/no-commits/.git/\n~ % git -C no-commits rev-list --all\nusage: git rev-list [OPTION] <commit-id>... [ -- paths... ]\n  limiting output:\n    --max-count=<n>\n    --max-age=<epoch>\n    --min-age=<epoch>\n    --sparse\n    --no-merges\n    --min-parents=<n>\n    --no-min-parents\n    --max-parents=<n>\n    --no-max-parents\n    --remove-empty\n    --all\n    --branches\n    --tags\n    --remotes\n    --stdin\n    --quiet\n  ordering output:\n    --topo-order\n    --date-order\n    --reverse\n  formatting output:\n    --parents\n    --children\n    --objects | --objects-edge\n    --unpacked\n    --header | --pretty\n    --abbrev=<n> | --no-abbrev\n    --abbrev-commit\n    --left-right\n    --count\n  special purpose:\n    --bisect\n    --bisect-vars\n    --bisect-all\n~ % echo $?\n129\n\nexpected behavior:\n\n~ % git -C no-commits rev-list --all\n~ % echo $?\n0\n"},{"id":"273705","messageId":"CA+izobv6OuAAjnKH5A=vcmJh3yDhWi41WAD-OmVSN2d7P_5SGA@mail.gmail.com","threadId":"40775","inReplyTo":"20151111192634.629102e6@linux-apw9.site","subject":"Re: Suspected bug on `git -C <rp> rev-list --all` where <rp> has 0 commits","fromName":"Atousa Duprat","fromEmail":"atousa.p@gmail.com","sentAt":"2015-11-25T06:56:50Z","receivedAt":"2015-11-25T06:56:50Z","isPatch":false,"sender":{"key":"atousa.p@gmail.com","avatar":"https://gravatar.com/avatar/b5b7b70553497c4ce08a835c156ff3b245366eba956fbceff99553b1ccdc4e42?d=mp&s=160"},"body":"I agree with Yac that this error is unwarranted, though it's been like\nthat since forever.\nIf a repo is empty, git rev-list should probably just return without\nerroring out.\nThe fix is trivial, if the list agrees that this is in fact legit.\n\nAtousa\n\nOn Wed, Nov 11, 2015 at 10:26 AM, yac <yac@blesmrt.net> wrote:\n> Hello\n>\n> basics:\n>\n> % rpm -q git git-core\n> git-2.6.2-2.1.x86_64\n> git-core-2.6.2-2.1.x86_64\n>\n> ~ % grep PRETTY_NAME /etc/os-release\n> PRETTY_NAME=\"openSUSE Tumbleweed (20151030) (x86_64)\"\n>\n> current behavior:\n>\n> ~ % git init no-commits\n> Initialized empty Git repository in /home/tester/no-commits/.git/\n> ~ % git -C no-commits rev-list --all\n> usage: git rev-list [OPTION] <commit-id>... [ -- paths... ]\n>   limiting output:\n>     --max-count=<n>\n>     --max-age=<epoch>\n>     --min-age=<epoch>\n>     --sparse\n>     --no-merges\n>     --min-parents=<n>\n>     --no-min-parents\n>     --max-parents=<n>\n>     --no-max-parents\n>     --remove-empty\n>     --all\n>     --branches\n>     --tags\n>     --remotes\n>     --stdin\n>     --quiet\n>   ordering output:\n>     --topo-order\n>     --date-order\n>     --reverse\n>   formatting output:\n>     --parents\n>     --children\n>     --objects | --objects-edge\n>     --unpacked\n>     --header | --pretty\n>     --abbrev=<n> | --no-abbrev\n>     --abbrev-commit\n>     --left-right\n>     --count\n>   special purpose:\n>     --bisect\n>     --bisect-vars\n>     --bisect-all\n> ~ % echo $?\n> 129\n>\n> expected behavior:\n>\n> ~ % git -C no-commits rev-list --all\n> ~ % echo $?\n> 0\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"273706","messageId":"1448434853-7527-1-git-send-email-apahlevan@ieee.org","threadId":"40775","inReplyTo":"CA+izobv6OuAAjnKH5A=vcmJh3yDhWi41WAD-OmVSN2d7P_5SGA@mail.gmail.com","subject":"[PATCH v1] git rev-list doesn't complain when repo is empty","fromName":"","fromEmail":"atousa.p@gmail.com","sentAt":"2015-11-25T07:00:53Z","receivedAt":"2015-11-25T07:00:53Z","isPatch":true,"sender":{"key":"atousa.p@gmail.com","avatar":"https://gravatar.com/avatar/b5b7b70553497c4ce08a835c156ff3b245366eba956fbceff99553b1ccdc4e42?d=mp&s=160"},"body":"From: Atousa Pahlevan Duprat <apahlevan@ieee.org>\n\nSigned-off-by: Atousa Pahlevan Duprat <apahlevan@ieee.org>\n---\n builtin/rev-list.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex d80d1ed..f71b87f 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -348,7 +348,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t     (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&\n \t      !revs.pending.nr)) ||\n \t    revs.diff)\n-\t\tusage(rev_list_usage);\n+               return 0; // empty repo\n \n \tif (revs.show_notes)\n \t\tdie(_(\"rev-list does not support display of notes\"));\n-- \n2.4.9 (Apple Git-60)\n"},{"id":"273711","messageId":"20151125090746.GC4696@sigill.intra.peff.net","threadId":"40775","inReplyTo":"CA+izobv6OuAAjnKH5A=vcmJh3yDhWi41WAD-OmVSN2d7P_5SGA@mail.gmail.com","subject":"Re: Suspected bug on `git -C <rp> rev-list --all` where <rp> has 0 commits","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-11-25T09:07:47Z","receivedAt":"2015-11-25T09:07:47Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 24, 2015 at 10:56:50PM -0800, Atousa Duprat wrote:\n\n> I agree with Yac that this error is unwarranted, though it's been like\n> that since forever.\n> If a repo is empty, git rev-list should probably just return without\n> erroring out.\n> The fix is trivial, if the list agrees that this is in fact legit.\n\nI think we had a similar discussion for \"git log\" with an empty HEAD,\nand decided that it was better to keep the behavior the same for\ncompatibility reasons. I think that would apply doubly for rev-list,\nwhich is used by scripts.\n\nIn the \"log\" case, we did improve the error message:\n\n  $ git init\n  $ git.v2.5.0 log\n  fatal: bad default revision 'HEAD'\n  $ git.v2.6.3 log\n  fatal: your current branch 'master' does not have any commits yet\n\nMaybe a good first step would be improving the error message?\n\n-Peff\n"},{"id":"273712","messageId":"20151125091010.GD4696@sigill.intra.peff.net","threadId":"40775","inReplyTo":"1448434853-7527-1-git-send-email-apahlevan@ieee.org","subject":"Re: [PATCH v1] git rev-list doesn't complain when repo is empty","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-11-25T09:10:11Z","receivedAt":"2015-11-25T09:10:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 24, 2015 at 11:00:53PM -0800, atousa.p@gmail.com wrote:\n\n> From: Atousa Pahlevan Duprat <apahlevan@ieee.org>\n> \n> Signed-off-by: Atousa Pahlevan Duprat <apahlevan@ieee.org>\n> ---\n>  builtin/rev-list.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/builtin/rev-list.c b/builtin/rev-list.c\n> index d80d1ed..f71b87f 100644\n> --- a/builtin/rev-list.c\n> +++ b/builtin/rev-list.c\n> @@ -348,7 +348,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n>  \t     (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&\n>  \t      !revs.pending.nr)) ||\n>  \t    revs.diff)\n> -\t\tusage(rev_list_usage);\n> +               return 0; // empty repo\n\nEven if we were to agree that rev-list should exit with code 0 for \"git\nrev-list --all\" in an empty repo, I do not think this patch is the right\nway to do it. It also catches:\n\n  git rev-list\n\nwith no arguments in a non-empty repository, which should produce a\nusage() message.\n\n-Peff\n"}]}