git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] git prompt: Use toplevel to find untracked files.
@ 2015-03-13  2:24 Cody A Taylor
  2015-03-13  6:16 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Cody A Taylor @ 2015-03-13  2:24 UTC (permalink / raw
  To: Git Mailing List; +Cc: Duy Nguyen, SZEDER Gábor, Felipe Contreras

>From c861d5cb401110ce7d86b76c1eaa8e89e80f484e Mon Sep 17 00:00:00 2001
From: Cody A Taylor <codemister99@yahoo.com>
Date: Thu, 12 Mar 2015 20:36:44 -0400
Subject: [PATCH] git prompt: Use toplevel to find untracked files.

The __git_ps1() prompt function would not show an untracked
state when the current working directory was not a parent of
the untracked file.

Signed-off-by: Cody A Taylor <codemister99@yahoo.com>
---
 contrib/completion/git-prompt.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 214e859f99e7..f18aedc73be9 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -487,7 +487,7 @@ __git_ps1 ()
 
 		if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
 		   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
-		   git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
+		   git ls-files --others --exclude-standard --error-unmatch -- ':/*' >/dev/null 2>/dev/null
 		then
 			u="%${ZSH_VERSION+%}"
 		fi
-- 
2.3.2

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

* Re: [PATCH v2] git prompt: Use toplevel to find untracked files.
  2015-03-13  2:24 [PATCH v2] git prompt: Use toplevel to find untracked files Cody A Taylor
@ 2015-03-13  6:16 ` Junio C Hamano
  2015-03-15 11:49   ` SZEDER Gábor
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-03-13  6:16 UTC (permalink / raw
  To: Cody A Taylor
  Cc: Git Mailing List, Duy Nguyen, SZEDER Gábor, Felipe Contreras

Cody A Taylor <cody.taylor@maternityneighborhood.com> writes:

> From c861d5cb401110ce7d86b76c1eaa8e89e80f484e Mon Sep 17 00:00:00 2001
> From: Cody A Taylor <codemister99@yahoo.com>
> Date: Thu, 12 Mar 2015 20:36:44 -0400
> Subject: [PATCH] git prompt: Use toplevel to find untracked files.

All of the above four lines are unwanted in the e-mail body.

 * The first line is a separating line to make format-patch output
   look like a mbox file, and does not even belong to this patch.

 * From: line, when you are not relaying somebody else's patch,
   should not be necessary, as long as you set up your MUA correctly
   so that the e-mail shows a correct From: in its header.

 * Date: is the same; unless you are relaying somebody else's patch,
   in which case you might want to preserve the author timestamp,
   the first time _we_ the recipients see your patch matters more,
   which should be available from the e-mail header.

 * Subject: should be in the e-mail header.  Sometimes when sending
   a patch to an ongoing discussion that has its own subject, it is
   handy to be able to override the title with in-body Subject:, but
   this patch submission is not such a case.  The subjects are the
   same in the fourth line in the body (which should be dropped) and
   in the header anyway in this message, so please edit it out.

In short

 (1) If you cannot convince your mailer to show your @yahoo.com
     address on the e-mail header From: line, then having the
     in-body From: line above (i.e. the second line) is OK as a
     workaround.  We however would prefer if you didn't.

 (2) Edit the other three lines out.

> The __git_ps1() prompt function would not show an untracked
> state when the current working directory was not a parent of
> the untracked file.

Good find, and nicely explained.  I wonder if we can add a test
or two to t9903-bash-prompt.sh?

The patch itself makes sense.  Thanks.

> Signed-off-by: Cody A Taylor <codemister99@yahoo.com>
> ---
>  contrib/completion/git-prompt.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index 214e859f99e7..f18aedc73be9 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -487,7 +487,7 @@ __git_ps1 ()
>  
>  		if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
>  		   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
> -		   git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
> +		   git ls-files --others --exclude-standard --error-unmatch -- ':/*' >/dev/null 2>/dev/null
>  		then
>  			u="%${ZSH_VERSION+%}"
>  		fi

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

* Re: [PATCH v2] git prompt: Use toplevel to find untracked files.
  2015-03-13  6:16 ` Junio C Hamano
@ 2015-03-15 11:49   ` SZEDER Gábor
  2015-03-15 21:18     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: SZEDER Gábor @ 2015-03-15 11:49 UTC (permalink / raw
  To: Junio C Hamano
  Cc: SZEDER Gábor, Git Mailing List, Duy Nguyen, Felipe Contreras,
	Cody A Taylor

Hi,

Quoting Junio C Hamano <gitster@pobox.com>:

> Cody A Taylor <cody.taylor@maternityneighborhood.com> writes:
>> The __git_ps1() prompt function would not show an untracked
>> state when the current working directory was not a parent of
>> the untracked file.
>
> Good find, and nicely explained.

Somehow I had a hard time making sense out of "when the current working
directory was not a parent of the untracked file".  Perhaps "when the
untracked files are outside of the current working directory" would be
easier to grok?

> I wonder if we can add a test
> or two to t9903-bash-prompt.sh?

This test fails without the patch in question and succeeds with it.

-- 8< --

diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 51ecd3e..3d1a95f 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -397,6 +397,16 @@ test_expect_success 'prompt - untracked files status indicator - untracked files
 	test_cmp expected "$actual"
 '
 
+test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
+	printf " (master %%)" >expected &&
+	(
+		cd ignored_dir &&
+		GIT_PS1_SHOWUNTRACKEDFILES=y &&
+		__git_ps1 >"$actual"
+	) &&
+	test_cmp expected "$actual"
+'
+
 test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
 	printf " (master)" >expected &&
 	test_config bash.showUntrackedFiles false &&

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

* Re: [PATCH v2] git prompt: Use toplevel to find untracked files.
  2015-03-15 11:49   ` SZEDER Gábor
@ 2015-03-15 21:18     ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2015-03-15 21:18 UTC (permalink / raw
  To: SZEDER Gábor
  Cc: Git Mailing List, Duy Nguyen, Felipe Contreras, Cody A Taylor

SZEDER Gábor <szeder@ira.uka.de> writes:

> Hi,
>
> Quoting Junio C Hamano <gitster@pobox.com>:
>
>> Cody A Taylor <cody.taylor@maternityneighborhood.com> writes:
>>> The __git_ps1() prompt function would not show an untracked
>>> state when the current working directory was not a parent of
>>> the untracked file.
>>
>> Good find, and nicely explained.
>
> Somehow I had a hard time making sense out of "when the current working
> directory was not a parent of the untracked file".  Perhaps "when the
> untracked files are outside of the current working directory" would be
> easier to grok?

Sounds good; let me use that when squashing your test updates in.

Thanks, both.

>
>> I wonder if we can add a test
>> or two to t9903-bash-prompt.sh?
>
> This test fails without the patch in question and succeeds with it.
>
> -- 8< --
>
> diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
> index 51ecd3e..3d1a95f 100755
> --- a/t/t9903-bash-prompt.sh
> +++ b/t/t9903-bash-prompt.sh
> @@ -397,6 +397,16 @@ test_expect_success 'prompt - untracked files status indicator - untracked files
>  	test_cmp expected "$actual"
>  '
>  
> +test_expect_success 'prompt - untracked files status indicator - untracked files outside cwd' '
> +	printf " (master %%)" >expected &&
> +	(
> +		cd ignored_dir &&
> +		GIT_PS1_SHOWUNTRACKEDFILES=y &&
> +		__git_ps1 >"$actual"
> +	) &&
> +	test_cmp expected "$actual"
> +'
> +
>  test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
>  	printf " (master)" >expected &&
>  	test_config bash.showUntrackedFiles false &&

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

* Re: [PATCH v2] git prompt: Use toplevel to find untracked files.
@ 2015-03-16  0:54 Cody Taylor
  2015-03-21  8:46 ` SZEDER Gábor
  0 siblings, 1 reply; 6+ messages in thread
From: Cody Taylor @ 2015-03-16  0:54 UTC (permalink / raw
  To: Junio C Hamano
  Cc: SZEDER Gábor, Git Mailing List, Duy Nguyen, Felipe Contreras

SZEDER Gábor <szeder@ira.uka.de> writes:
> Somehow I had a hard time making sense out of "when the current working
> directory was not a parent of the untracked file".  Perhaps "when the
> untracked files are outside of the current working directory" would be
> easier to grok?

That description doesn't cover all cases.

Scenario #1: Let's say there is an untracked file at `$ROOT/file`.
When your CWD is `$ROOT/`, all is well. If you cd to `$ROOT/src/` the
ls-files command failed to find the untracked file.

Scenario #2: Let's say there is an untracked file at `$ROOT/src/file`.
The ls-files command would find the file if the CWD is `$ROOT/` or
`$ROOT/src/`, but not if the CWD is `$ROOT/bin/` or
`$ROOT/src/folder/`.

Your description may be easier to understand, but I don't agree it's accurate.

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

* Re: [PATCH v2] git prompt: Use toplevel to find untracked files.
  2015-03-16  0:54 Cody Taylor
@ 2015-03-21  8:46 ` SZEDER Gábor
  0 siblings, 0 replies; 6+ messages in thread
From: SZEDER Gábor @ 2015-03-21  8:46 UTC (permalink / raw
  To: Cody Taylor
  Cc: Junio C Hamano, Git Mailing List, Duy Nguyen, Felipe Contreras


Quoting Cody Taylor <cody.taylor@maternityneighborhood.com>:

> SZEDER Gábor <szeder@ira.uka.de> writes:
>> Somehow I had a hard time making sense out of "when the current working
>> directory was not a parent of the untracked file".  Perhaps "when the
>> untracked files are outside of the current working directory" would be
>> easier to grok?
>
> That description doesn't cover all cases.

I'm not sure I understand.
I think we both say the same, though from different views: you  
describe what cwd is not relative to the untracked file in the  
problematic case, while I describe where the untracked file is  
relative to cwd in the same case.

> Scenario #1: Let's say there is an untracked file at `$ROOT/file`.
> When your CWD is `$ROOT/`, all is well. If you cd to `$ROOT/src/` the
> ls-files command failed to find the untracked file.

After cd to '$ROOT/src' the untracked file '$ROOT/file' is outside  
cwd, which matches my description and is what your patch covers.

> Scenario #2: Let's say there is an untracked file at `$ROOT/src/file`.
> The ls-files command would find the file if the CWD is `$ROOT/` or
> `$ROOT/src/`, but not if the CWD is `$ROOT/bin/` or
> `$ROOT/src/folder/`.

Again, after cd to '$ROOT/bin' the untracked file '$ROOT/src/file' is  
outside cwd, so my description and your patch cover it.

> Your description may be easier to understand, but I don't agree it's  
> accurate.

Well, I think it's accurate, but now I doubt that it's easier to understand :)


Gábor

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

end of thread, other threads:[~2015-03-21  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-13  2:24 [PATCH v2] git prompt: Use toplevel to find untracked files Cody A Taylor
2015-03-13  6:16 ` Junio C Hamano
2015-03-15 11:49   ` SZEDER Gábor
2015-03-15 21:18     ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2015-03-16  0:54 Cody Taylor
2015-03-21  8:46 ` SZEDER Gábor

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

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).