http-fetch: make `-a` standard behaviour

This is a follow-up to a6c786fce8 (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 <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Ågren committed Apr 22, 2018 at 20:12 UTC 2e85a0c8abe29f9adad2ec0a977629ba90723973
3 files changed +19 -23
Documentation/git-http-fetch.txt
+5 -8
@@ -15,8 +15,9 @@ DESCRIPTION
15 -----------
16 Downloads a remote Git repository via HTTP.
17
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.
21
22 OPTIONS
23 -------
@@ -24,12 +25,8 @@ commit-id::
25 Either the hash or the filename under [URL]/refs/ to
26 pull.
27
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.
30 -v::
31 Report what is downloaded.
32
http-fetch.c
+3 -15
@@ -17,21 +17,13 @@ int cmd_main(int argc, const char **argv)
17 char *url = NULL;
18 int arg = 1;
19 int rc = 0;
20 - int get_tree = 0;
21 - int get_history = 0;
22 - int get_all = 0;
20 int get_verbosely = 0;
21 int get_recover = 0;
22
23 while (arg < argc && argv[arg][0] == '-') {
24 if (argv[arg][1] == 't') {
28 - get_tree = 1;
25 } else if (argv[arg][1] == 'c') {
30 - get_history = 1;
26 } else if (argv[arg][1] == 'a') {
32 - get_all = 1;
33 - get_tree = 1;
34 - get_history = 1;
27 } else if (argv[arg][1] == 'v') {
28 get_verbosely = 1;
29 } else if (argv[arg][1] == 'w') {
@@ -55,10 +47,6 @@ int cmd_main(int argc, const char **argv)
47 commits = 1;
48 }
49
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 -
50 if (argv[arg])
51 str_end_url_with_slash(argv[arg], &url);
52
@@ -68,9 +56,9 @@ int cmd_main(int argc, const char **argv)
56
57 http_init(NULL, url, 0);
58 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;
62 walker->get_verbosely = get_verbosely;
63 walker->get_recover = get_recover;
64
t/t5550-http-fetch-dumb.sh
+11
@@ -169,6 +169,17 @@ test_expect_success 'fetch changes via manual http-fetch' '
169 test_cmp file clone2/file
170 '
171
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 +
183 test_expect_success 'http remote detects correct HEAD' '
184 git push public master:other &&
185 (cd clone &&