Skip to content

Commit 51ba601

Browse files
committed
Merge branch 'en/shallow-exclude-takes-a-ref-fix'
The "--shallow-exclude=<ref>" option to various history transfer commands takes a ref, not an arbitrary revision. * en/shallow-exclude-takes-a-ref-fix: doc: correct misleading descriptions for --shallow-exclude upload-pack: fix ambiguous error message
2 parents 110c8fe + 00e10e0 commit 51ba601

File tree

8 files changed

+21
-10
lines changed

8 files changed

+21
-10
lines changed

Documentation/fetch-options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
Deepen or shorten the history of a shallow repository to
3030
include all reachable commits after <date>.
3131

32-
--shallow-exclude=<revision>::
32+
--shallow-exclude=<ref>::
3333
Deepen or shorten the history of a shallow repository to
3434
exclude commits reachable from a specified remote branch or tag.
3535
This option can be specified multiple times.

Documentation/git-clone.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ corresponding `--mirror` and `--no-tags` options instead.
255255
`--shallow-since=<date>`::
256256
Create a shallow clone with a history after the specified time.
257257

258-
`--shallow-exclude=<revision>`::
258+
`--shallow-exclude=<ref>`::
259259
Create a shallow clone with a history, excluding commits
260260
reachable from a specified remote branch or tag. This option
261261
can be specified multiple times.

Documentation/git-fetch-pack.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ be in a separate packet, and the list must end with a flush packet.
9191
Deepen or shorten the history of a shallow repository to
9292
include all reachable commits after <date>.
9393

94-
--shallow-exclude=<revision>::
94+
--shallow-exclude=<ref>::
9595
Deepen or shorten the history of a shallow repository to
9696
exclude commits reachable from a specified remote branch or tag.
9797
This option can be specified multiple times.

builtin/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ static struct option builtin_clone_options[] = {
147147
N_("create a shallow clone of that depth")),
148148
OPT_STRING(0, "shallow-since", &option_since, N_("time"),
149149
N_("create a shallow clone since a specific time")),
150-
OPT_STRING_LIST(0, "shallow-exclude", &option_not, N_("revision"),
151-
N_("deepen history of shallow clone, excluding rev")),
150+
OPT_STRING_LIST(0, "shallow-exclude", &option_not, N_("ref"),
151+
N_("deepen history of shallow clone, excluding ref")),
152152
OPT_BOOL(0, "single-branch", &option_single_branch,
153153
N_("clone only one branch, HEAD or --branch")),
154154
OPT_BOOL(0, "no-tags", &option_no_tags,

builtin/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,8 +2216,8 @@ int cmd_fetch(int argc,
22162216
N_("deepen history of shallow clone")),
22172217
OPT_STRING(0, "shallow-since", &deepen_since, N_("time"),
22182218
N_("deepen history of shallow repository based on time")),
2219-
OPT_STRING_LIST(0, "shallow-exclude", &deepen_not, N_("revision"),
2220-
N_("deepen history of shallow clone, excluding rev")),
2219+
OPT_STRING_LIST(0, "shallow-exclude", &deepen_not, N_("ref"),
2220+
N_("deepen history of shallow clone, excluding ref")),
22212221
OPT_INTEGER(0, "deepen", &deepen_relative,
22222222
N_("deepen history of shallow clone")),
22232223
OPT_SET_INT_F(0, "unshallow", &unshallow,

builtin/pull.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ static struct option pull_options[] = {
218218
OPT_PASSTHRU_ARGV(0, "shallow-since", &opt_fetch, N_("time"),
219219
N_("deepen history of shallow repository based on time"),
220220
0),
221-
OPT_PASSTHRU_ARGV(0, "shallow-exclude", &opt_fetch, N_("revision"),
222-
N_("deepen history of shallow clone, excluding rev"),
221+
OPT_PASSTHRU_ARGV(0, "shallow-exclude", &opt_fetch, N_("ref"),
222+
N_("deepen history of shallow clone, excluding ref"),
223223
0),
224224
OPT_PASSTHRU_ARGV(0, "deepen", &opt_fetch, N_("n"),
225225
N_("deepen history of shallow clone"),

t/t5500-fetch-pack.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,13 @@ test_expect_success 'fetch exclude tag one' '
926926
test_cmp expected actual
927927
'
928928

929+
test_expect_success 'fetch exclude tag one as revision' '
930+
test_when_finished rm -f rev err &&
931+
git -C shallow-exclude rev-parse one >rev &&
932+
test_must_fail git -C shallow12 fetch --shallow-exclude $(cat rev) origin 2>err &&
933+
grep "deepen-not is not a ref:" err
934+
'
935+
929936
test_expect_success 'fetching deepen' '
930937
test_create_repo shallow-deepen &&
931938
(

upload-pack.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,10 +1026,14 @@ static int process_deepen_not(const char *line, struct oidset *deepen_not, int *
10261026
{
10271027
const char *arg;
10281028
if (skip_prefix(line, "deepen-not ", &arg)) {
1029+
int cnt;
10291030
char *ref = NULL;
10301031
struct object_id oid;
1031-
if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref) != 1)
1032+
cnt = expand_ref(the_repository, arg, strlen(arg), &oid, &ref);
1033+
if (cnt > 1)
10321034
die("git upload-pack: ambiguous deepen-not: %s", line);
1035+
if (cnt < 1)
1036+
die("git upload-pack: deepen-not is not a ref: %s", line);
10331037
oidset_insert(deepen_not, &oid);
10341038
free(ref);
10351039
*deepen_rev_list = 1;

0 commit comments

Comments
 (0)