Instead of prefixing the remote branches with "remotes/" suffix them with
"[read only]"
Signed-off-by: Andy Parkins <redacted>
---
builtin-branch.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index b88413a..6736882 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -105,6 +105,7 @@ static void print_ref_list(int display_m
int i;
char c;
char *p;
+ const char *suffix;
switch (display_mode) {
case 0:@@ -122,6 +123,7 @@ static void print_ref_list(int display_m
for (i = 0; i < ref_index; i++) {
p = ref_list[i];
+ suffix = "";
if (display_mode == 2) {
if (!strncmp( p, "refs/", 5 ))
p += 5;@@ -129,13 +131,17 @@ static void print_ref_list(int display_m
continue;
if (!strncmp( p, "heads/", 6 ))
p += 6;
+ if (!strncmp( p, "remotes/", 8 )) {
+ suffix = " [read only]";
+ p += 8;
+ }
}
c = ' ';
if (!strcmp(p, head))
c = '*';
- printf("%c %s\n", c, p);
+ printf("%c %s%s\n", c, p, suffix);
}
}
--
1.4.3.2
On Friday 2006 November 03 02:40, Junio C Hamano wrote:
Andy Parkins [off-list ref] writes:
quoted
Instead of prefixing the remote branches with "remotes/" suffix them with
"[read only]"
This is a change in UI and while I understand why you want to
say r/o instead of remotes/, I think this needs a bit more
thought and discussion. People should not be feeding the output
of "git branch" Porcelainish to their scripts, but you'll never
know...
I intentionally made this patch in such a way as to leave the original form
available. I haven't added a switch to show the original form, but it's
there if it's needed.
The reason I thought it would be acceptable is that the output changed fairly
significantly when git-branch went builtin.
Here's the original and my "git-branch -r" run on my git repository
$ git-branch -r
remotes/up/maint
remotes/up/master
remotes/up/next
remotes/up/pu
$ ./git-branch -r
momentum/master
up/maint
up/master
up/next
up/pu
I've not touched the "-r" path, so this is the same as the unpatched builtin
branch. The "remotes/" prefix is removed in refs.c by for_each_remote_ref()
with do_for_each_ref("refs/remotes/", fn, 13, cb_data); and the spaces are
added because print_ref_list() has only one printing path and that always
includes spaces.
For me personally, I find my git-branch output more useful because in it's
unswitched form it shows me all branches. However, I can easily put this
behaviour under a switch or, and this would get my vote, put the original
behaviour (i.e. show local branches only) under a switch.
Which would you like? If any.
By the way, does "git branch -r" (without any of your patches)
even say "remotes/"?
I haven't touched the "-r" path, so that output should be unaffected. As
mentioned above, git-branch.sh did include "remotes/", new builtin branch
does not, but does include " " at the beginning of every line.
Andy
--
Dr Andy Parkins, M Eng (hons), MIEE
Andy Parkins [off-list ref] writes:
Instead of prefixing the remote branches with "remotes/" suffix them with
"[read only]"
This is a change in UI and while I understand why you want to
say r/o instead of remotes/, I think this needs a bit more
thought and discussion. People should not be feeding the output
of "git branch" Porcelainish to their scripts, but you'll never
know...
By the way, does "git branch -r" (without any of your patches)
even say "remotes/"?