{"thread":{"id":"10798","subject":"[PATCH 2/5] git-fetch: Always fetch tags if the object they reference exists","startedAt":"2007-11-11T07:29:30Z","lastAt":"2007-11-11T07:29:30Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"59280","messageId":"20071111072930.GB19146@spearce.org","threadId":"10798","inReplyTo":null,"subject":"[PATCH 2/5] git-fetch: Always fetch tags if the object they reference exists","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-11-11T07:29:30Z","receivedAt":"2007-11-11T07:29:30Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Previously git-fetch.sh used `git cat-file -t` to determine if an\nobject referenced by a tag exists, and if so fetch that tag locally.\nThis was subtly broken during the port to C based builtin-fetch as\nlookup_object() only works to locate an object if it was previously\naccessed by the transport.  Not all transports will access all\nobjects in this way, so tags were not always being fetched.\n\nThe rsync transport never loads objects into the internal object\ntable so automated tag following didn't work if rsync was used.\nAutomated tag following also didn't work on the native transport\nif the new tag was behind the common point(s) negotiated between\nthe two ends of the connection as the tag's referrant would not\nbe loaded into the internal object table.  Further the automated\ntag following was broken with the HTTP commit walker if the new\ntag's referrant was behind an existing ref, as the walker would\nstop before loading the tag's referrant into the object table.\n\nSwitching to has_sha1_file() restores the original behavior from\nthe shell script by checking if the object exists in the ODB,\nwithout relying on the state left behind by a transport.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n builtin-fetch.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 847db73..a935b5a 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -389,7 +389,7 @@ static struct ref *find_non_local_tags(struct transport *transport,\n \n \t\tif (!path_list_has_path(&existing_refs, ref_name) &&\n \t\t    !path_list_has_path(&new_refs, ref_name) &&\n-\t\t    lookup_object(ref->old_sha1)) {\n+\t\t    has_sha1_file(ref->old_sha1)) {\n \t\t\tpath_list_insert(ref_name, &new_refs);\n \n \t\t\trm = alloc_ref(strlen(ref_name) + 1);\n-- \n1.5.3.5.1661.gcbf0\n"}]}