From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Hansen Subject: Re: [PATCH] git-prompt.sh: Omit prompt for ignored directories Date: Thu, 09 Oct 2014 01:37:52 -0400 Message-ID: <54361F30.8020603@bbn.com> References: <1412795040-19267-1-git-send-email-jess.austin@gmail.com> <5435A8A7.2030008@bbn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Cc: git@vger.kernel.org, szeder@ira.uka.de To: Jess Austin X-From: git-owner@vger.kernel.org Thu Oct 09 07:38:06 2014 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xc6QL-0005tA-T3 for gcvg-git-2@plane.gmane.org; Thu, 09 Oct 2014 07:38:02 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751126AbaJIFh6 (ORCPT ); Thu, 9 Oct 2014 01:37:58 -0400 Received: from smtp.bbn.com ([128.33.0.80]:19278 "EHLO smtp.bbn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750705AbaJIFh5 convert rfc822-to-8bit (ORCPT ); Thu, 9 Oct 2014 01:37:57 -0400 Received: from socket.bbn.com ([192.1.120.102]:60693) by smtp.bbn.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1Xc6QE-000CLl-TB; Thu, 09 Oct 2014 01:37:54 -0400 X-Submitted: to socket.bbn.com (Postfix) with ESMTPSA id 87BD54089A User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On 2014-10-08 17:37, Jess Austin wrote: > On Wed, Oct 8, 2014 at 4:12 PM, Richard Hansen wrote: >> On 2014-10-08 15:04, Jess Austin wrote: >>> Introduce a new environmental variable, GIT_PS1_OMITIGNORED, which >>> tells __git_ps1 to display nothing when the current directory is >>> set (e.g. via .gitignore) to be ignored by git. In the absence of >>> GIT_PS1_OMITIGNORED this change has no effect. >>> >>> Many people manage e.g. dotfiles in their home directory with git. >>> This causes the prompt generated by __git_ps1 to refer to that "top >>> level" repo while working in any descendant directory. That can be >>> distracting, so this patch helps one shut off that noise. >> >> Interesting idea, though I would prefer this to be configurable on a >> per-repository basis. (I wouldn't want to hide the prompt in any >> repository besides my home repository.) > > Sorry my description was unclear. Let's say you have a repo in "~", > and another in "~/projects/foo". Also, the file "~/.gitignore" has the line > "projects/" in it. In this case, you'd see repo info in your prompt while > in "~" or in "~/projects/foo", but not if you were in "~/projects". In that > sense, the prompt is not distracting you with the status of the top-level > repo when you're not looking at anything in that repo. I understand; I was concerned about this case: $ PS1='\n\w$(__git_ps1 " (%s)")\n\$ ' /home/rhansen/projects (dotfiles) $ GIT_PS1_OMITIGNORED=y /home/rhansen/projects <-- Git prompt goes away as desired $ cd foo /home/rhansen/projects/foo (master) <-- Git prompt back as expected $ echo ignored/ >>.gitignore && mkdir -p ignored && cd ignored /home/rhansen/projects/foo/ignored <-- I want the Git prompt here $ In other words: If I were to use this feature, I'd want to be able to hide the prompt when I'm in an ignored directory in my dotfiles work tree, but show the prompt when I'm in an ignored directory in any other work tree. -Richard