This causes git-fetch to auto-follow notes in the same fashion that tags are auto-followed by default. Pretty much all the code in this patch is about doing the same thing for notes as what is already done for tags. Signed-off-by: Johan Herland <johan@xxxxxxxxxxx> --- builtin-fetch--tool.c | 11 +++++++++++ git-fetch.sh | 27 +++++++++++++++++++++++++++ git-parse-remote.sh | 4 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c index ed4d5de..71ddc6d 100644 --- a/builtin-fetch--tool.c +++ b/builtin-fetch--tool.c @@ -82,6 +82,8 @@ static int update_local_ref(const char *name, /* new ref */ if (!strncmp(name, "refs/tags/", 10)) msg = "storing tag"; + else if (!strncmp(name, "refs/notes/", 11)) + msg = "storing note"; else msg = "storing head"; fprintf(stderr, "* %s: storing %s\n", @@ -103,6 +105,11 @@ static int update_local_ref(const char *name, show_new(type, sha1_new); return update_ref("updating tag", name, sha1_new, NULL); } + else if (!strncmp(name, "refs/notes/", 11)) { + fprintf(stderr, "* %s: updating with %s\n", name, note); + show_new(type, sha1_new); + return update_ref("updating note", name, sha1_new, NULL); + } current = lookup_commit_reference(sha1_old); updated = lookup_commit_reference(sha1_new); @@ -163,6 +170,10 @@ static int append_fetch_head(FILE *fp, kind = "tag"; what = remote_name + 10; } + else if (!strncmp(remote_name, "refs/notes/", 11)) { + kind = "note"; + what = remote_name + 11; + } else if (!strncmp(remote_name, "refs/remotes/", 13)) { kind = "remote branch"; what = remote_name + 13; diff --git a/git-fetch.sh b/git-fetch.sh index 0e05cf1..a2a7874 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -353,6 +353,33 @@ case "$no_tags$tags" in esac esac +# automated note following +case "" in # --notes and --no-notes options? +'') + case "$reflist" in + *:refs/*) + # effective only when we are following remote branch + # using local tracking branch. + notelist=$(IFS=' ' && + echo "$ls_remote_result" | + git-show-ref --exclude-existing=refs/notes/ | + while read sha1 name + do + git-cat-file -t "$sha1" >/dev/null 2>&1 || continue + echo >&2 "Auto-following $name" + echo ".${name}:${name}" + done) + esac + case "$notelist" in + '') ;; + ?*) + # do not deepen a shallow tree when following notes + shallow_depth= + fetch_main "$notelist" || exit ;; + esac +esac + + # If the original head was empty (i.e. no "master" yet), or # if we were told not to worry, we do not have to check. case "$orig_head" in diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 0506b12..95dcc10 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -144,13 +144,13 @@ canon_refs_list_for_fetch () { case "$remote" in '' | HEAD ) remote=HEAD ;; refs/*) ;; - heads/* | tags/* | remotes/* ) remote="refs/$remote" ;; + heads/* | tags/* | notes/* | remotes/* ) remote="refs/$remote" ;; *) remote="refs/heads/$remote" ;; esac case "$local" in '') local= ;; refs/*) ;; - heads/* | tags/* | remotes/* ) local="refs/$local" ;; + heads/* | tags/* | notes/* | remotes/* ) local="refs/$local" ;; *) local="refs/heads/$local" ;; esac -- 1.5.2.101.gee49f - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html