git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] http-fetch: make `-a` standard behaviour

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Apr 22, 2018, 18:12 UTC
Message-ID
<367243f0c8215f702fd38152952f47121ab337b1.1524420451.git.martin.agren@gmail.com>

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>
---
 Documentation/git-http-fetch.txt | 13 +++++--------
 t/t5550-http-fetch-dumb.sh       | 11 +++++++++++
 http-fetch.c                     | 18 +++---------------
 3 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/Documentation/git-http-fetch.txt b/Documentation/git-http-fetch.txt
index 21a33d2c41..666b042679 100644
--- a/Documentation/git-http-fetch.txt
+++ b/Documentation/git-http-fetch.txt
@@ -15,8 +15,9 @@ DESCRIPTION
 -----------
 Downloads a remote Git repository via HTTP.
 
-*NOTE*: use of this command without -a is deprecated.  The -a
-behaviour will become the default in a future release.
+This command always gets all objects. Historically, there were three options
+`-a`, `-c` and `-t` for choosing which objects to download. They are now
+silently ignored.
 
 OPTIONS
 -------
@@ -24,12 +25,8 @@ commit-id::
         Either the hash or the filename under [URL]/refs/ to
         pull.
 
--c::
-	Get the commit objects.
--t::
-	Get trees associated with the commit objects.
--a::
-	Get all the objects.
+-a, -c, -t::
+	These options are ignored for historical reasons.
 -v::
 	Report what is downloaded.
 
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 8552184e74..6d7d88ccc9 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -169,6 +169,17 @@ test_expect_success 'fetch changes via manual http-fetch' '
 	test_cmp file clone2/file
 '
 
+test_expect_success 'manual http-fetch without -a works just as well' '
+	cp -R clone-tmpl clone3 &&
+
+	HEAD=$(git rev-parse --verify HEAD) &&
+	(cd clone3 &&
+	 git http-fetch -w heads/master-new $HEAD $(git config remote.origin.url) &&
+	 git checkout master-new &&
+	 test $HEAD = $(git rev-parse --verify HEAD)) &&
+	test_cmp file clone3/file
+'
+
 test_expect_success 'http remote detects correct HEAD' '
 	git push public master:other &&
 	(cd clone &&
diff --git a/http-fetch.c b/http-fetch.c
index 8af380050c..a1564f5a41 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -17,21 +17,13 @@ int cmd_main(int argc, const char **argv)
 	char *url = NULL;
 	int arg = 1;
 	int rc = 0;
-	int get_tree = 0;
-	int get_history = 0;
-	int get_all = 0;
 	int get_verbosely = 0;
 	int get_recover = 0;
 
 	while (arg < argc && argv[arg][0] == '-') {
 		if (argv[arg][1] == 't') {
-			get_tree = 1;
 		} else if (argv[arg][1] == 'c') {
-			get_history = 1;
 		} else if (argv[arg][1] == 'a') {
-			get_all = 1;
-			get_tree = 1;
-			get_history = 1;
 		} else if (argv[arg][1] == 'v') {
 			get_verbosely = 1;
 		} else if (argv[arg][1] == 'w') {
@@ -55,10 +47,6 @@ int cmd_main(int argc, const char **argv)
 		commits = 1;
 	}
 
-	if (get_all == 0)
-		warning("http-fetch: use without -a is deprecated.\n"
-			"In a future release, -a will become the default.");
-
 	if (argv[arg])
 		str_end_url_with_slash(argv[arg], &url);
 
@@ -68,9 +56,9 @@ int cmd_main(int argc, const char **argv)
 
 	http_init(NULL, url, 0);
 	walker = get_http_walker(url);
-	walker->get_tree = get_tree;
-	walker->get_history = get_history;
-	walker->get_all = get_all;
+	walker->get_tree = 1;
+	walker->get_history = 1;
+	walker->get_all = 1;
 	walker->get_verbosely = get_verbosely;
 	walker->get_recover = get_recover;
 
-- 
2.17.0
Next: Martin Ågren
Message 1 of 2 in “http-fetch: make `-a` standard behaviour”
  1. 1/2 http-fetch: make `-a` standard behaviourMartin Ågren, Apr 22, 2018
  2. 2/2 walker: drop fields of `struct walker` which are always 1Martin Ågren, Apr 22, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.