Browse Source

Merge branch 'ma/http-walker-no-partial'

"git http-fetch" (deprecated) had an optional and experimental
"feature" to fetch only commits and/or trees, which nobody used.
This has been removed.

* ma/http-walker-no-partial:
  walker: drop fields of `struct walker` which are always 1
  http-fetch: make `-a` standard behaviour
maint
Junio C Hamano 7 years ago
parent
commit
96f29521a3
  1. 13
      Documentation/git-http-fetch.txt
  2. 15
      http-fetch.c
  3. 3
      remote-curl.c
  4. 11
      t/t5550-http-fetch-dumb.sh
  5. 19
      walker.c
  6. 3
      walker.h

13
Documentation/git-http-fetch.txt

@ -15,8 +15,9 @@ DESCRIPTION @@ -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:: @@ -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.


15
http-fetch.c

@ -17,21 +17,13 @@ int cmd_main(int argc, const char **argv) @@ -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) @@ -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,6 @@ int cmd_main(int argc, const char **argv) @@ -68,9 +56,6 @@ 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_verbosely = get_verbosely;
walker->get_recover = get_recover;


3
remote-curl.c

@ -869,9 +869,6 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch) @@ -869,9 +869,6 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
targets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));

walker = get_http_walker(url.buf);
walker->get_all = 1;
walker->get_tree = 1;
walker->get_history = 1;
walker->get_verbosely = options.verbosity >= 3;
walker->get_recover = 0;
ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);

11
t/t5550-http-fetch-dumb.sh

@ -169,6 +169,17 @@ test_expect_success 'fetch changes via manual http-fetch' ' @@ -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 &&

19
walker.c

@ -72,6 +72,8 @@ static struct commit_list *complete = NULL; @@ -72,6 +72,8 @@ static struct commit_list *complete = NULL;

static int process_commit(struct walker *walker, struct commit *commit)
{
struct commit_list *parents;

if (parse_commit(commit))
return -1;

@ -86,19 +88,14 @@ static int process_commit(struct walker *walker, struct commit *commit) @@ -86,19 +88,14 @@ static int process_commit(struct walker *walker, struct commit *commit)

walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));

if (walker->get_tree) {
if (process(walker, &commit->tree->object))
if (process(walker, &commit->tree->object))
return -1;

for (parents = commit->parents; parents; parents = parents->next) {
if (process(walker, &parents->item->object))
return -1;
if (!walker->get_all)
walker->get_tree = 0;
}
if (walker->get_history) {
struct commit_list *parents = commit->parents;
for (; parents; parents = parents->next) {
if (process(walker, &parents->item->object))
return -1;
}
}

return 0;
}


3
walker.h

@ -9,9 +9,6 @@ struct walker { @@ -9,9 +9,6 @@ struct walker {
void (*prefetch)(struct walker *, unsigned char *sha1);
int (*fetch)(struct walker *, unsigned char *sha1);
void (*cleanup)(struct walker *);
int get_tree;
int get_history;
int get_all;
int get_verbosely;
int get_recover;


Loading…
Cancel
Save