{"thread":{"id":"41810","subject":"[PATCH v3] git-send-pack: Fix --all option when used with directory","startedAt":"2016-03-24T14:16:29Z","lastAt":"2016-03-24T14:16:29Z","messageCount":1,"participants":["Stanislav Kolotinskiy"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"281671","messageId":"1458828989-3799-1-git-send-email-stanislav@assembla.com","threadId":"41810","inReplyTo":null,"subject":"[PATCH v3] git-send-pack: Fix --all option when used with directory","fromName":"Stanislav Kolotinskiy","fromEmail":"stanislav@assembla.com","sentAt":"2016-03-24T14:16:29Z","receivedAt":"2016-03-24T14:16:29Z","isPatch":true,"sender":{"key":"stanislav@assembla.com","avatar":"https://gravatar.com/avatar/dca9d54f97b9c9bb1c41538bcc64a933d063c1f8fe3cac0936a4d4b09e4c45ff?d=mp&s=160"},"body":"When using git send-pack with --all option\nand a target directory, usage message is being\ndisplayed instead of performing the actual transmission.\n\nThe reason for this issue is that refspecs variable is being\ncalculated in a different way comparing to previous versions,\nand even though the number of refspecs (nr_refspecs) is 0,\nrefspecs contain all the arguments and switches passed to send-pack.\n\nThis ensures that send-pack will stop execution only when --all\nor --mirror switch is used in conjunction with any refs passed.\n\nSigned-off-by: Stanislav Kolotinskiy <stanislav@assembla.com>\n---\n builtin/send-pack.c  |  2 +-\n t/t5400-send-pack.sh | 12 ++++++++++++\n 2 files changed, 13 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex f6e5d64..19f0577 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -225,7 +225,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \t * --all and --mirror are incompatible; neither makes sense\n \t * with any refspecs.\n \t */\n-\tif ((refspecs && (send_all || args.send_mirror)) ||\n+\tif ((nr_refspecs > 0 && (send_all || args.send_mirror)) ||\n \t    (send_all && args.send_mirror))\n \t\tusage_with_options(send_pack_usage, options);\n \ndiff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh\nindex 04cea97..305ca7a 100755\n--- a/t/t5400-send-pack.sh\n+++ b/t/t5400-send-pack.sh\n@@ -128,6 +128,18 @@ test_expect_success 'denyNonFastforwards trumps --force' '\n \ttest \"$victim_orig\" = \"$victim_head\"\n '\n \n+test_expect_success 'send-pack --all sends all branches' '\n+\t# make sure we have at least 2 branches with different\n+\t# values, just to be thorough\n+\tgit branch other-branch HEAD^ &&\n+\n+\tgit init --bare all.git &&\n+\tgit send-pack --all all.git &&\n+\tgit for-each-ref refs/heads >expect &&\n+\tgit -C all.git for-each-ref refs/heads >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'push --all excludes remote-tracking hierarchy' '\n \tmkdir parent &&\n \t(\n-- \n2.7.4\n"}]}