git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Stanislav Kolotinskiy <stanislav@assembla.com>
Date
Mar 23, 2016, 16:24 UTC
Message-ID
<1458750262-25765-1-git-send-email-stanislav@assembla.com>

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: Jeff King
Message 1 of 10 in “git-send-pack: Fix --all option when used with directory”
  1. git-send-pack: Fix --all option when used with directoryStanislav Kolotinskiy, Mar 23, 2016
  2. Jeff KingMar 23, 2016
  3. Jeff KingMar 23, 2016
  4. Stanislav KolotinskiyMar 24, 2016
  5. Jeff KingMar 24, 2016
  6. Stanislav KolotinskiyMar 24, 2016
  7. Junio C HamanoMar 24, 2016
  8. Stanislav KolotinskiyMar 24, 2016
  9. Jeff KingMar 24, 2016
  10. Stanislav KolotinskiyApr 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.