* [PATCH v4] git-send-pack: fix --all option when used with directory
@ 2016-03-31 13:55 stanislav
2016-03-31 20:28 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: stanislav @ 2016-03-31 13:55 UTC (permalink / raw)
To: git; +Cc: peff, dborowitz, gitster, Stanislav Kolotinskiy
From: Stanislav Kolotinskiy <stanislav@assembla.com>
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 <stanislav@assembla.com>
---
builtin/send-pack.c | 2 +-
t/t5400-send-pack.sh | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
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/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 04cea97..305ca7a 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -128,6 +128,18 @@ test_expect_success 'denyNonFastforwards trumps --force' '
test "$victim_orig" = "$victim_head"
'
+test_expect_success 'send-pack --all sends all branches' '
+ # make sure we have at least 2 branches with different
+ # values, just to be thorough
+ git branch other-branch HEAD^ &&
+
+ git init --bare all.git &&
+ git send-pack --all all.git &&
+ git for-each-ref refs/heads >expect &&
+ git -C all.git for-each-ref refs/heads >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'push --all excludes remote-tracking hierarchy' '
mkdir parent &&
(
--
2.8.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4] git-send-pack: fix --all option when used with directory
2016-03-31 13:55 [PATCH v4] git-send-pack: fix --all option when used with directory stanislav
@ 2016-03-31 20:28 ` Junio C Hamano
2016-03-31 22:02 ` Junio C Hamano
2016-04-01 10:44 ` Stanislav Kolotinskiy
0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2016-03-31 20:28 UTC (permalink / raw)
To: stanislav; +Cc: git, peff, dborowitz
stanislav@assembla.com writes:
> From: Stanislav Kolotinskiy <stanislav@assembla.com>
>
> 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 <stanislav@assembla.com>
> ---
Thanks, will queue.
> builtin/send-pack.c | 2 +-
> t/t5400-send-pack.sh | 12 ++++++++++++
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> 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/t5400-send-pack.sh b/t/t5400-send-pack.sh
> index 04cea97..305ca7a 100755
> --- a/t/t5400-send-pack.sh
> +++ b/t/t5400-send-pack.sh
> @@ -128,6 +128,18 @@ test_expect_success 'denyNonFastforwards trumps --force' '
> test "$victim_orig" = "$victim_head"
> '
>
> +test_expect_success 'send-pack --all sends all branches' '
> + # make sure we have at least 2 branches with different
> + # values, just to be thorough
> + git branch other-branch HEAD^ &&
> +
> + git init --bare all.git &&
> + git send-pack --all all.git &&
> + git for-each-ref refs/heads >expect &&
> + git -C all.git for-each-ref refs/heads >actual &&
> + test_cmp expect actual
> +'
> +
> test_expect_success 'push --all excludes remote-tracking hierarchy' '
> mkdir parent &&
> (
> --
> 2.8.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] git-send-pack: fix --all option when used with directory
2016-03-31 20:28 ` Junio C Hamano
@ 2016-03-31 22:02 ` Junio C Hamano
2016-03-31 22:55 ` Eric Sunshine
2016-03-31 23:26 ` Jeff King
2016-04-01 10:44 ` Stanislav Kolotinskiy
1 sibling, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2016-03-31 22:02 UTC (permalink / raw)
To: git; +Cc: peff, dborowitz, stanislav
Junio C Hamano <gitster@pobox.com> writes:
> stanislav@assembla.com writes:
>
>> From: Stanislav Kolotinskiy <stanislav@assembla.com>
>>
>> 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 <stanislav@assembla.com>
>> ---
>
> Thanks, will queue.
By the way, for some reason it was unusually painful to find the
exact breakage by bisecting between maint-2.4 and maint-2.6. It
somehow ended up on fingering random places like v2.6.0 itself.
The true culprit is 068c77a5 (builtin/send-pack.c: use parse_options
API, 2015-08-19). I didn't dug deep enough to tell if we recently
broke "git bisect" or if there are something wrong in the shape of
my history.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] git-send-pack: fix --all option when used with directory
2016-03-31 22:02 ` Junio C Hamano
@ 2016-03-31 22:55 ` Eric Sunshine
2016-03-31 23:26 ` Jeff King
1 sibling, 0 replies; 6+ messages in thread
From: Eric Sunshine @ 2016-03-31 22:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List, Jeff King, dborowitz, stanislav
On Thu, Mar 31, 2016 at 6:02 PM, Junio C Hamano <gitster@pobox.com> wrote:
> By the way, for some reason it was unusually painful to find the
> exact breakage by bisecting between maint-2.4 and maint-2.6. It
> somehow ended up on fingering random places like v2.6.0 itself.
>
> The true culprit is 068c77a5 (builtin/send-pack.c: use parse_options
> API, 2015-08-19). I didn't dug deep enough to tell if we recently
> broke "git bisect" or if there are something wrong in the shape of
> my history.
I had a similar experience a couple months ago where I was bisecting
to find a fix (rather than breakage), and each time I ran bisect, it
seemed (randomly) to arrive at a different commit, often a merge,
rather than the real fix (which I eventually located by manually
examining commits near the commits bisect identified). At the time, I
thought I was doing something wrong (and perhaps I was), but your
descriptions sounds eerily similar to that experience.
Unfortunately, I no longer recall precisely for what I was searching
(other than that someone reported a Git bug which I recalled having
been already fixed, and wanted to use bisect to respond with the exact
commit which fixed the problem), and the bisect "run" script was
throwaway, so I can't consult that for further details.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] git-send-pack: fix --all option when used with directory
2016-03-31 22:02 ` Junio C Hamano
2016-03-31 22:55 ` Eric Sunshine
@ 2016-03-31 23:26 ` Jeff King
1 sibling, 0 replies; 6+ messages in thread
From: Jeff King @ 2016-03-31 23:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, dborowitz, stanislav
On Thu, Mar 31, 2016 at 03:02:43PM -0700, Junio C Hamano wrote:
> By the way, for some reason it was unusually painful to find the
> exact breakage by bisecting between maint-2.4 and maint-2.6. It
> somehow ended up on fingering random places like v2.6.0 itself.
>
> The true culprit is 068c77a5 (builtin/send-pack.c: use parse_options
> API, 2015-08-19). I didn't dug deep enough to tell if we recently
> broke "git bisect" or if there are something wrong in the shape of
> my history.
Weird. I bisected this when v1 was published, and didn't have any
trouble. I guess it's possible I just got lucky in where I landed,
though, if I started at different endpoints than you.
-Peff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4] git-send-pack: fix --all option when used with directory
2016-03-31 20:28 ` Junio C Hamano
2016-03-31 22:02 ` Junio C Hamano
@ 2016-04-01 10:44 ` Stanislav Kolotinskiy
1 sibling, 0 replies; 6+ messages in thread
From: Stanislav Kolotinskiy @ 2016-04-01 10:44 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, peff, dborowitz
On 31/03/16 23:28, Junio C Hamano wrote:
> Thanks, will queue.
Thanks a lot!
--
Regards,
Stanislav
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-04-01 10:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-31 13:55 [PATCH v4] git-send-pack: fix --all option when used with directory stanislav
2016-03-31 20:28 ` Junio C Hamano
2016-03-31 22:02 ` Junio C Hamano
2016-03-31 22:55 ` Eric Sunshine
2016-03-31 23:26 ` Jeff King
2016-04-01 10:44 ` Stanislav Kolotinskiy
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).