[PATCH] git-send-pack: Fix --all option when used with directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]