Git development
 help / color / mirror / Atom feed
* [PATCH] git fetch one tag only
@ 2012-06-07  1:40 cheng renquan
  2012-06-07  4:37 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: cheng renquan @ 2012-06-07  1:40 UTC (permalink / raw)
  To: git

Someone maybe like me is working in the way of following one central
git repository
while sometimes need to fetch some code or tags from a 3rd git repo,
but unfortunately the 3rd repo may contain a lot of tags not all I want
to fetch to mess up my local repo, at this time I want to fetch only one tag
from the 3rd repo, but the syntax of
  `git fetch 3rd-repo the-tag-name`

really fetched the code of the-tag-name from 3rd-repo, but forgot the
tag itself;
this patch enhanced the above syntax to create the tag itself;


 builtin/fetch.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index bb9a074..9a3ec4a 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -439,6 +439,14 @@ static int store_updated_refs(const char
*raw_url, const char *remote_name,
 			else if (!prefixcmp(rm->name, "refs/tags/")) {
 				kind = "tag";
 				what = rm->name + 10;
+				if (!ref) {
+					unsigned char sha1[20];
+					ref = alloc_ref(rm->name);
+					hashcpy(ref->new_sha1, rm->old_sha1);
+					if (!get_sha1(rm->name, sha1))
+						hashcpy(ref->old_sha1, sha1);
+				}
 			}
 			else if (!prefixcmp(rm->name, "refs/remotes/")) {
 				kind = "remote-tracking branch";

-- 
cheng renquan (程任全)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-06-08 22:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07  1:40 [PATCH] git fetch one tag only cheng renquan
2012-06-07  4:37 ` Junio C Hamano
2012-06-07  5:17   ` cheng renquan
2012-06-07  5:33     ` Junio C Hamano
2012-06-07  5:47       ` cheng renquan
2012-06-07 16:11         ` cheng renquan
2012-06-07 17:08       ` Junio C Hamano
2012-06-08 21:46         ` cheng renquan
2012-06-08 22:22           ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox