Re: [PATCH v2 4/4] remote show: list tracked remote branches with -n

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Olivier Marin
Date: Tuesday, June 10, 2008 - 3:54 pm

From: Olivier Marin <dkr@freesurf.fr>

Signed-off-by: Olivier Marin <dkr@freesurf.fr>
---

Junio C Hamano a écrit :

You are right. This version should fix this.

 builtin-remote.c  |   22 ++++++++++++++++++++--
 t/t5505-remote.sh |    2 ++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/builtin-remote.c b/builtin-remote.c
index 851bdde..d55d320 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -444,6 +444,22 @@ static int get_remote_ref_states(const char *name,
 	return 0;
 }
 
+static int append_ref_to_tracked_list(const char *refname,
+	const unsigned char *sha1, int flags, void *cb_data)
+{
+	struct ref_states *states = cb_data;
+	struct refspec refspec;
+
+	memset(&refspec, 0, sizeof(refspec));
+	refspec.dst = (char *)refname;
+	if (!remote_find_tracking(states->remote, &refspec)) {
+		path_list_append(skip_prefix(refspec.src, "refs/heads/"),
+			&states->tracked);
+	}
+
+	return 0;
+}
+
 static int show(int argc, const char **argv)
 {
 	int no_query = 0, result = 0;
@@ -494,10 +510,12 @@ static int show(int argc, const char **argv)
 			strbuf_release(&buf);
 			show_list("  Stale tracking branch%s (use 'git remote "
 				"prune')", &states.stale);
-			show_list("  Tracked remote branch%s",
-				&states.tracked);
 		}
 
+		if (no_query)
+			for_each_ref(append_ref_to_tracked_list, &states);
+		show_list("  Tracked remote branch%s", &states.tracked);
+
 		if (states.remote->push_refspec_nr) {
 			printf("  Local branch%s pushed with 'git push'\n   ",
 				states.remote->push_refspec_nr > 1 ?
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index c27cfad..fbf0d30 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -143,6 +143,8 @@ cat > test/expect << EOF
   URL: $(pwd)/one/.git
   Remote branch merged with 'git pull' while on branch master
     master
+  Tracked remote branches
+    master side
   Local branches pushed with 'git push'
     master:upstream +refs/tags/lastbackup
 EOF
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
remote show/prune: strange -n(--dry-run) option., Olivier Marin, (Sat Jun 7, 5:54 pm)
[PATCH] remote show: fix the -n option, Olivier Marin, (Sun Jun 8, 5:48 pm)
Re: [PATCH] remote show: fix the -n option, Johannes Schindelin, (Sun Jun 8, 6:16 pm)
Re: [PATCH] remote show: fix the -n option, Olivier Marin, (Sun Jun 8, 7:06 pm)
Re: [PATCH] remote show: fix the -n option, Johannes Schindelin, (Sun Jun 8, 7:35 pm)
Re: [PATCH] remote show: fix the -n option, Olivier Marin, (Sun Jun 8, 9:16 pm)
Re: [PATCH] remote show: fix the -n option, Johannes Schindelin, (Sun Jun 8, 9:53 pm)
Re: [PATCH] remote show: fix the -n option, Olivier Marin, (Mon Jun 9, 7:22 am)
Re: [PATCH] remote show: fix the -n option, Olivier Marin, (Mon Jun 9, 8:43 am)
[PATCH v2] remote show: fix the -n option, Olivier Marin, (Mon Jun 9, 8:58 am)
Re: [PATCH] remote show: fix the -n option, Johannes Schindelin, (Mon Jun 9, 9:31 am)
Re: [PATCH v2] remote show: fix the -n option, Johannes Schindelin, (Mon Jun 9, 9:35 am)
Re: [PATCH v2] remote show: fix the -n option, Olivier Marin, (Mon Jun 9, 9:58 am)
Re: [PATCH v2] remote show: fix the -n option, Johannes Schindelin, (Mon Jun 9, 10:56 am)
Re: [PATCH v2] remote show: fix the -n option, Olivier Marin, (Mon Jun 9, 11:37 am)
[PATCH] builtin-remote: make reuse of code easier by not d ..., Johannes Schindelin, (Mon Jun 9, 1:11 pm)
Re: [PATCH v2] remote show: fix the -n option, Junio C Hamano, (Mon Jun 9, 6:10 pm)
Re: [PATCH v2] remote show: fix the -n option, Shawn O. Pearce, (Mon Jun 9, 6:19 pm)
Re: [PATCH v2] remote show: fix the -n option, Johannes Schindelin, (Mon Jun 9, 7:39 pm)
[PATCH 0/4] remote show/prune improvement, Olivier Marin, (Tue Jun 10, 7:50 am)
[PATCH 1/4] remote show: fix the -n option, Olivier Marin, (Tue Jun 10, 7:51 am)
Re: [PATCH 0/4] remote show/prune improvement, Jakub Narebski, (Tue Jun 10, 8:09 am)
Re: [PATCH 0/4] remote show/prune improvement, Olivier Marin, (Tue Jun 10, 9:10 am)
Re: [PATCH 0/4] remote show/prune improvement, Jakub Narebski, (Tue Jun 10, 10:11 am)
Re: [PATCH v2 4/4] remote show: list tracked remote branch ..., Olivier Marin, (Tue Jun 10, 3:54 pm)