From: Andy Parkins <hidden> Date: 2016-08-11 19:18:25
Instead of storing a list of refnames in append_ref, a list of structures is
created. Each of these stores the refname and a symbolic constant representing
its type.
The creation of the list is filtered based on a command line switch; no switch
means "local branches only", "-r" means "remote branches only" (as they always
did); but now "-a" means "local branches or remote branches".
As a side effect, the list is now not global, but allocated in print_ref_list()
where it used.
Also a memory leak is plugged, the memory allocated during the list creation
was never freed. This is now done in the new function, tidy_ref_list()
Signed-off-by: Andy Parkins <redacted>
---
builtin-branch.c | 95 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 77 insertions(+), 18 deletions(-)
From: Andy Parkins <hidden> Date: 2016-08-11 19:28:50
On Friday 2006 November 03 10:51, Andreas Ericsson wrote:
If you *need* to change something, change it. If you *want* to change
something just because it's not written the way you would write it, back
away. If you think some interface you're using needs clearing up
(codewise or with extra comments), send a separate patch for that so the
actual feature/bugfix you're sending in doesn't drown in cosmetic
changes to the interfaces the patch uses/touches.
Thank you for the excellent advice. What then would you suggest in the case
in point? I made as minimal a change as I could make; but that left the code
a little bit bitty - I had press-ganged a variable into taking on another
function and was using numeric literals that should really have been given
meaning with #define?
My question is perhaps different from simply git-etiquette; it's should I
prefer my patches to be minimal or neat? If there is a more appropriate way
of doing something should I do it or should I favour minimalism?
I've actually rewritten it now as per Junio's request, and while I'm happier
with the code, it was much bigger change, that didn't really lend itself to
being broken into smaller patches as did my first attempt.
I guess in the end it's a judgement call and the best thing to do is post it
and see who shoots it down :-)
Andy
--
Dr Andy Parkins, M Eng (hons), MIEE
From: Andy Parkins <hidden> Date: 2016-08-11 19:55:09
I wanted to have a visual indication of which branches are local and which are
remote in git-branch -a output; however Junio was concerned that someone might
be using the output in a script. This patch addresses the problem by colouring
the git-branch output - which in "auto" mode won't be activated.
I've based it off the colouring code for builtin-diff.c; which means there is a
branch.color configuration variable that needs setting to something before the
color will appear.
This patch chooses green for local, red for remote and bold green for current.
As yet, there is no support for changing the colors using the config file; but
it wouldn't be hard to add.
Signed-off-by: Andy Parkins <redacted>
---
builtin-branch.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 54 insertions(+), 3 deletions(-)
From: Andreas Ericsson <hidden> Date: 2016-08-11 20:08:32
Andy Parkins wrote:
On Friday 2006 November 03 10:51, Andreas Ericsson wrote:
quoted
If you *need* to change something, change it. If you *want* to change
something just because it's not written the way you would write it, back
away. If you think some interface you're using needs clearing up
(codewise or with extra comments), send a separate patch for that so the
actual feature/bugfix you're sending in doesn't drown in cosmetic
changes to the interfaces the patch uses/touches.
Thank you for the excellent advice. What then would you suggest in the case
in point? I made as minimal a change as I could make; but that left the code
a little bit bitty - I had press-ganged a variable into taking on another
function and was using numeric literals that should really have been given
meaning with #define?
My question is perhaps different from simply git-etiquette; it's should I
prefer my patches to be minimal or neat? If there is a more appropriate way
of doing something should I do it or should I favour minimalism?
Neat, imo. Re-using old variables might be appropriate if the name of
the variable still makes sense, but rename it if there's a better name
for it.
I've actually rewritten it now as per Junio's request, and while I'm happier
with the code, it was much bigger change, that didn't really lend itself to
being broken into smaller patches as did my first attempt.
I guess in the end it's a judgement call and the best thing to do is post it
and see who shoots it down :-)
Probably the most sensible approach. Even though the list is pretty
trigger-happy, the guns are more of the playful water-squirt type than
the high-powered big-calibre kind.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
From: Andy Parkins <hidden> Date: 2016-08-11 20:15:52
On Friday 2006 November 03 02:40, Junio C Hamano wrote:
If you make this a "mode", it probably is better to make 1 and 0
into symbolic constants. This patch taken alone is regression
in readability.
In my own code I would have done exactly that; however I've been trying to
keep my patches as minimal as possible.
Digressing a little: what is the polite form of patches for git? My strategy
with this set was to make each patch as small as possible to reach my end
point. If those patches were okayed on the list, I could then do a "make
more beautiful" patch, which is really nothing to do with the original
changes to functionality but would make the code prettier. Really I'm asking
what level of intrusiveness of patch is not considered rude? In making my
patches, should I ride rough-shod over current implementation and just do it
how I'd do it or should I try to fit in (as I did in this case)?
Something like this untested patch, that is...
I'm very much in favour; I shall make changes of this form soon.
Andy
--
Dr Andy Parkins, M Eng (hons), MIEE
From: Andreas Ericsson <hidden> Date: 2016-08-11 20:22:42
Andy Parkins wrote:
Digressing a little: what is the polite form of patches for git? My strategy
with this set was to make each patch as small as possible to reach my end
point. If those patches were okayed on the list, I could then do a "make
more beautiful" patch, which is really nothing to do with the original
changes to functionality but would make the code prettier.
I believe the order of preferrence goes: tested, concise, short.
Linus has a nasty habit of ending his mails with "totally untested
ofcourse", which is not a good strategy to adopt if you want your
patches included.
Really I'm asking
what level of intrusiveness of patch is not considered rude? In making my
patches, should I ride rough-shod over current implementation and just do it
how I'd do it or should I try to fit in (as I did in this case)?
If you *need* to change something, change it. If you *want* to change
something just because it's not written the way you would write it, back
away. If you think some interface you're using needs clearing up
(codewise or with extra comments), send a separate patch for that so the
actual feature/bugfix you're sending in doesn't drown in cosmetic
changes to the interfaces the patch uses/touches.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
From: Junio C Hamano <hidden> Date: 2016-08-11 20:35:48
Andy Parkins [off-list ref] writes:
-static void print_ref_list(int remote_only)
+static void print_ref_list(int display_mode)
{
int i;
char c;
- if (remote_only)
+ if (display_mode)
for_each_remote_ref(append_ref, NULL);
else
for_each_branch_ref(append_ref, NULL);
If you make this a "mode", it probably is better to make 1 and 0
into symbolic constants. This patch taken alone is regression
in readability.
By the way, it might make sense to make it bitfields; that would
allow you to show either one kind or both.
Something like this untested patch, that is...