Skip to content

Commit c677756

Browse files
Stanislav Kolotinskiygitster
authored andcommitted
git-send-pack: fix --all option when used with directory
When using git send-pack with --all option and a target repository specification ([<host>:]<directory>), usage message is being displayed instead of performing the actual transmission. The reason for this issue is that destination and refspecs are being set in the same conditional and are populated from argv. When a target repository is passed, refspecs is being populated as well with its value. This makes the check for refspecs not being NULL to always return true, which, in conjunction with the check for --all or --mirror options, is always true as well and returns usage message instead of proceeding. This ensures that send-pack will stop execution only when --all or --mirror switch is used in conjunction with any refspecs passed. Signed-off-by: Stanislav Kolotinskiy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68c757f commit c677756

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

builtin/send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
225225
* --all and --mirror are incompatible; neither makes sense
226226
* with any refspecs.
227227
*/
228-
if ((refspecs && (send_all || args.send_mirror)) ||
228+
if ((nr_refspecs > 0 && (send_all || args.send_mirror)) ||
229229
(send_all && args.send_mirror))
230230
usage_with_options(send_pack_usage, options);
231231

t/t5400-send-pack.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ test_expect_success 'denyNonFastforwards trumps --force' '
128128
test "$victim_orig" = "$victim_head"
129129
'
130130

131+
test_expect_success 'send-pack --all sends all branches' '
132+
# make sure we have at least 2 branches with different
133+
# values, just to be thorough
134+
git branch other-branch HEAD^ &&
135+
136+
git init --bare all.git &&
137+
git send-pack --all all.git &&
138+
git for-each-ref refs/heads >expect &&
139+
git -C all.git for-each-ref refs/heads >actual &&
140+
test_cmp expect actual
141+
'
142+
131143
test_expect_success 'push --all excludes remote-tracking hierarchy' '
132144
mkdir parent &&
133145
(

0 commit comments

Comments
 (0)