From: Stanislav Kolotinskiy <stanislav@assembla.com>
To: git@vger.kernel.org
Cc: Stanislav Kolotinskiy <stanislav@assembla.com>
Subject: [PATCH] git-send-pack: Fix --all option when used with directory
Date: Wed, 23 Mar 2016 18:24:22 +0200 [thread overview]
Message-ID: <1458750262-25765-1-git-send-email-stanislav@assembla.com> (raw)
When using git send-pack with --all option
and a target directory, usage message is being
displayed instead of performing the actual transmission.
The reason for this issue is that refspecs variable is being
calculated in a different way comparing to previous versions,
and even though the number of refspecs (nr_refspecs) is 0,
refspecs contain all the arguments and switches passed to send-pack.
This ensures that send-pack will stop execution only when --all
or --mirror switch is used in conjunction with any refs passed.
Signed-off-by: Stanislav Kolotinskiy <stanislav@assembla.com>
---
builtin/send-pack.c | 2 +-
t/t9904-send-pack-all.sh | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
create mode 100755 t/t9904-send-pack-all.sh
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index f6e5d64..19f0577 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -225,7 +225,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
* --all and --mirror are incompatible; neither makes sense
* with any refspecs.
*/
- if ((refspecs && (send_all || args.send_mirror)) ||
+ if ((nr_refspecs > 0 && (send_all || args.send_mirror)) ||
(send_all && args.send_mirror))
usage_with_options(send_pack_usage, options);
diff --git a/t/t9904-send-pack-all.sh b/t/t9904-send-pack-all.sh
new file mode 100755
index 0000000..f68d004
--- /dev/null
+++ b/t/t9904-send-pack-all.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+test_description='Make sure that send-pack --all copies all refs'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ git init --bare bare_repo && git init repo && (
+ cd repo &&
+
+ git remote add origin ../bare_repo &&
+ date >file1 && git add file1 && test_tick &&
+ git commit -m Initial &&
+ git push origin master &&
+
+ git checkout -b other && date >file2 &&
+ git add file2 && test_tick &&
+ git commit -m Other &&
+ git push origin other
+ ) && git init another && (
+ cd another &&
+
+ git config receive.denyCurrentBranch ignore
+ )
+'
+
+test_expect_success 'send-pack --all should copy all refs' '
+ cd bare_repo && git send-pack --all ../another
+'
+
+test_done
--
2.7.4
next reply other threads:[~2016-03-23 16:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 16:24 Stanislav Kolotinskiy [this message]
2016-03-23 21:22 ` [PATCH] git-send-pack: Fix --all option when used with directory Jeff King
2016-03-23 21:30 ` Jeff King
2016-03-24 13:57 ` Stanislav Kolotinskiy
2016-03-24 17:37 ` Jeff King
2016-03-24 17:49 ` Stanislav Kolotinskiy
2016-03-24 16:11 ` Junio C Hamano
2016-03-24 17:47 ` Stanislav Kolotinskiy
2016-03-24 18:02 ` Jeff King
2016-04-01 10:42 ` Stanislav Kolotinskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458750262-25765-1-git-send-email-stanislav@assembla.com \
--to=stanislav@assembla.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).