[PATCH] transport: Catch non positive --depth option value

Subsystems: the rest

STALE3751d

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] transport: Catch non positive --depth option value

From: Andrés G. Aragoneses <hidden>
Date: 2016-06-15 22:59:14

Instead of simply ignoring the value passed to --depth
option when it is zero or negative, now it is caught
and reported.

This will let people know that they were using the
option incorrectly (as depth<0 should be simply invalid,
and under the hood depth==0 didn't mean 'no depth' or
'no history' but 'full depth' instead).

Signed-off-by: Andres G. Aragoneses <redacted>
---
  transport.c | 2 ++
  1 file changed, 2 insertions(+)
diff --git a/transport.c b/transport.c
index 7202b77..edd63eb 100644
--- a/transport.c
+++ b/transport.c
@@ -483,6 +483,8 @@ static int set_git_option(struct 
git_transport_options *opts,
  			opts->depth = strtol(value, &end, 0);
  			if (*end)
  				die("transport: invalid depth option '%s'", value);
+			if (opts->depth < 1)
+				die("transport: invalid depth option '%s' (non positive)", value);
  		}
  		return 0;
  	}
-- 
1.8.1.2

Re: [PATCH] transport: Catch non positive --depth option value

From: Duy Nguyen <hidden>
Date: 2016-06-15 22:59:16

On Wed, Nov 13, 2013 at 11:06 PM, "Andrés G. Aragoneses"
[off-list ref] wrote:
Instead of simply ignoring the value passed to --depth
option when it is zero or negative, now it is caught
and reported.

This will let people know that they were using the
option incorrectly (as depth<0 should be simply invalid,
and under the hood depth==0 didn't mean 'no depth' or
'no history' but 'full depth' instead).
'full depth' may be confusing (is it --unshallow?). Other than that
the patch looks fine.
quoted hunk
Signed-off-by: Andres G. Aragoneses <redacted>
---
 transport.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/transport.c b/transport.c
index 7202b77..edd63eb 100644
--- a/transport.c
+++ b/transport.c
@@ -483,6 +483,8 @@ static int set_git_option(struct git_transport_options
*opts,
                        opts->depth = strtol(value, &end, 0);
                        if (*end)
                                die("transport: invalid depth option '%s'",
value);
+                       if (opts->depth < 1)
+                               die("transport: invalid depth option '%s'
(non positive)", value);
                }
                return 0;
        }
--
1.8.1.2


-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help