Skip to content

Commit 2e85a0c

Browse files
Martin Ågrengitster
authored andcommitted
http-fetch: make -a standard behaviour
This is a follow-up to a6c786f (Mark http-fetch without -a as deprecated, 2011-08-23). For more than six years, we have been warning when `-a` is not provided, and the documentation has been saying that `-a` will become the default. It is a bit unclear what "default" means here. There is no such thing as `http-fetch --no-a`. But according to my searches, no-one has been asking on the mailing list how they should silence the warning and prepare for overriding the flipped default. So let's assume that everybody is happy with `-a`. They should be, since not using it may break the repo in such a way that Git itself is unable to fix it. Always behave as if `-a` was given. Since `-a` implies `-c` (get commit objects) and `-t` (get trees), all three options are now unnecessary. Document all of these as historical artefacts that have no effect. Leave no-op code for handling these options in http-fetch.c. The options-handling is currently rather loose. If someone tightens it, we will not want these ignored options to accidentally turn into hard errors. Since `-a` was the only safe and sane usage and we have been pushing people towards it for a long time, refrain from warning when it is used "unnecessarily" now. Similarly, do not add anything scary-looking to the man-page about how it will be removed in the future. We can always do so later. (It is not like we are in desperate need of freeing up one-letter arguments.) Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 468165c commit 2e85a0c

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

Documentation/git-http-fetch.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@ DESCRIPTION
1515
-----------
1616
Downloads a remote Git repository via HTTP.
1717

18-
*NOTE*: use of this command without -a is deprecated. The -a
19-
behaviour will become the default in a future release.
18+
This command always gets all objects. Historically, there were three options
19+
`-a`, `-c` and `-t` for choosing which objects to download. They are now
20+
silently ignored.
2021

2122
OPTIONS
2223
-------
2324
commit-id::
2425
Either the hash or the filename under [URL]/refs/ to
2526
pull.
2627

27-
-c::
28-
Get the commit objects.
29-
-t::
30-
Get trees associated with the commit objects.
31-
-a::
32-
Get all the objects.
28+
-a, -c, -t::
29+
These options are ignored for historical reasons.
3330
-v::
3431
Report what is downloaded.
3532

http-fetch.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@ int cmd_main(int argc, const char **argv)
1717
char *url = NULL;
1818
int arg = 1;
1919
int rc = 0;
20-
int get_tree = 0;
21-
int get_history = 0;
22-
int get_all = 0;
2320
int get_verbosely = 0;
2421
int get_recover = 0;
2522

2623
while (arg < argc && argv[arg][0] == '-') {
2724
if (argv[arg][1] == 't') {
28-
get_tree = 1;
2925
} else if (argv[arg][1] == 'c') {
30-
get_history = 1;
3126
} else if (argv[arg][1] == 'a') {
32-
get_all = 1;
33-
get_tree = 1;
34-
get_history = 1;
3527
} else if (argv[arg][1] == 'v') {
3628
get_verbosely = 1;
3729
} else if (argv[arg][1] == 'w') {
@@ -55,10 +47,6 @@ int cmd_main(int argc, const char **argv)
5547
commits = 1;
5648
}
5749

58-
if (get_all == 0)
59-
warning("http-fetch: use without -a is deprecated.\n"
60-
"In a future release, -a will become the default.");
61-
6250
if (argv[arg])
6351
str_end_url_with_slash(argv[arg], &url);
6452

@@ -68,9 +56,9 @@ int cmd_main(int argc, const char **argv)
6856

6957
http_init(NULL, url, 0);
7058
walker = get_http_walker(url);
71-
walker->get_tree = get_tree;
72-
walker->get_history = get_history;
73-
walker->get_all = get_all;
59+
walker->get_tree = 1;
60+
walker->get_history = 1;
61+
walker->get_all = 1;
7462
walker->get_verbosely = get_verbosely;
7563
walker->get_recover = get_recover;
7664

t/t5550-http-fetch-dumb.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ test_expect_success 'fetch changes via manual http-fetch' '
169169
test_cmp file clone2/file
170170
'
171171

172+
test_expect_success 'manual http-fetch without -a works just as well' '
173+
cp -R clone-tmpl clone3 &&
174+
175+
HEAD=$(git rev-parse --verify HEAD) &&
176+
(cd clone3 &&
177+
git http-fetch -w heads/master-new $HEAD $(git config remote.origin.url) &&
178+
git checkout master-new &&
179+
test $HEAD = $(git rev-parse --verify HEAD)) &&
180+
test_cmp file clone3/file
181+
'
182+
172183
test_expect_success 'http remote detects correct HEAD' '
173184
git push public master:other &&
174185
(cd clone &&

0 commit comments

Comments
 (0)