zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: vcs_info Mercurial backend branch name display
@ 2010-05-24 15:48 Seth House
  2010-05-24 16:45 ` PATCH: =?utf-8?b?dmNzX2luZm8=?= " Greg Klanderman
  0 siblings, 1 reply; 4+ messages in thread
From: Seth House @ 2010-05-24 15:48 UTC (permalink / raw)
  To: zsh-workers

This patch fixes a VCS_Info bug (introduced by me) that broke the branch display 
by always displaying as "default".

Sorry for the patch noise.
- Seth

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg 
b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -58,10 +58,11 @@
 # If the user doesn't opt to invoke hg we can still get the current branch
 if [[ -z ${r_branch} && -r ${branchfile} ]] ; then
     r_branch=$(< ${branchfile})
-else
-    r_branch="default"
 fi
 
+# If we still don't know the branch it's safe to assume default
+if [[ -n ${r_branch} ]] || r_branch="default"
+
 # The working dir has uncommitted-changes if the revision ends with a +
 if [[ $r_lrev[-1] == + ]] ; then
     hgchanges=1


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

* Re: PATCH: =?utf-8?b?dmNzX2luZm8=?= Mercurial backend branch name display
  2010-05-24 15:48 PATCH: vcs_info Mercurial backend branch name display Seth House
@ 2010-05-24 16:45 ` Greg Klanderman
  2010-05-24 17:55   ` PATCH: vcs_info " Seth House
  2010-05-24 18:30   ` Seth House
  0 siblings, 2 replies; 4+ messages in thread
From: Greg Klanderman @ 2010-05-24 16:45 UTC (permalink / raw)
  To: zsh-workers

>>>>> On May 24, 2010 Seth House <seth@eseth.com> wrote:

> This patch fixes a VCS_Info bug (introduced by me) that broke the branch display 
> by always displaying as "default".

> +if [[ -n ${r_branch} ]] || r_branch="default"

Looks like you have a spurious 'if' there..

Greg


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

* Re: PATCH: vcs_info Mercurial backend branch name display
  2010-05-24 16:45 ` PATCH: =?utf-8?b?dmNzX2luZm8=?= " Greg Klanderman
@ 2010-05-24 17:55   ` Seth House
  2010-05-24 18:30   ` Seth House
  1 sibling, 0 replies; 4+ messages in thread
From: Seth House @ 2010-05-24 17:55 UTC (permalink / raw)
  To: zsh-workers

Greg Klanderman <gak <at> klanderman.net> writes:
> Looks like you have a spurious 'if' there..

No, that is correct. It initially tries to obtain the branch name by
invoking hg (line 54) -- only if the user has opted to allow invoking
hg. If it still doesn't know the branch name and a file containing the
name is readable, it will pull it from the file (line 59). Finally, if
we still don't know the branch it defaults to "default" (line 64).

It could be refactored to the following if you feel this is more
readable:

# If the user doesn't opt to invoke hg we can still get the current branch
if [[ -z ${r_branch} ]] ; then
    if [[ -r ${branchfile} ]] ; then
        r_branch=$(< ${branchfile})
    else
        # If we still don't know the branch it's safe to assume default
        r_branch="default"
    fi
fi


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

* Re: PATCH: vcs_info Mercurial backend branch name display
  2010-05-24 16:45 ` PATCH: =?utf-8?b?dmNzX2luZm8=?= " Greg Klanderman
  2010-05-24 17:55   ` PATCH: vcs_info " Seth House
@ 2010-05-24 18:30   ` Seth House
  1 sibling, 0 replies; 4+ messages in thread
From: Seth House @ 2010-05-24 18:30 UTC (permalink / raw)
  To: zsh-workers

Greg Klanderman <gak <at> klanderman.net> writes:
> Looks like you have a spurious 'if' there..

<facepalm>

It took me ten minutes and an email from Bart (thanks Bart!) to see the mistake. 
Here's the fixed patch and now I'm gonna grab more coffee...

diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg 
b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -58,10 +58,11 @@
 # If the user doesn't opt to invoke hg we can still get the current branch
 if [[ -z ${r_branch} && -r ${branchfile} ]] ; then
     r_branch=$(< ${branchfile})
-else
-    r_branch="default"
 fi
 
+# If we still don't know the branch it's safe to assume default
+[[ -n ${r_branch} ]] || r_branch="default"
+
 # The working dir has uncommitted-changes if the revision ends with a +
 if [[ $r_lrev[-1] == + ]] ; then
     hgchanges=1



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

end of thread, other threads:[~2010-05-24 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-24 15:48 PATCH: vcs_info Mercurial backend branch name display Seth House
2010-05-24 16:45 ` PATCH: =?utf-8?b?dmNzX2luZm8=?= " Greg Klanderman
2010-05-24 17:55   ` PATCH: vcs_info " Seth House
2010-05-24 18:30   ` Seth House

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).