* [PATCH 1/5] git-prompt: do not look for refs/stash in $GIT_DIR
2014-08-23 5:23 [PATCH 0/5] fix pack-refs pruning of refs/foo Jeff King
@ 2014-08-23 5:26 ` Jeff King
0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2014-08-23 5:26 UTC (permalink / raw)
To: git; +Cc: SZEDER Gábor, Ronnie Sahlberg, Michael Haggerty
Since dd0b72c (bash prompt: use bash builtins to check stash
state, 2011-04-01), git-prompt checks whether we have a
stash by looking for $GIT_DIR/refs/stash. Generally external
programs should never do this, because they would miss
packed-refs.
That commit claims that packed-refs does not pack
refs/stash, but that is not quite true. It does pack the
ref, but due to a bug, fails to prune the ref. When we fix
that bug, we would want to be doing the right thing here.
Signed-off-by: Jeff King <peff@peff.net>
---
I know we are pretty sensitive to forks in the prompt code (after all,
that was the point of dd0b72c). This patch is essentially a reversion of
this hunk of dd0b72c, and is definitely safe.
I think we could probably get by with:
[ -r "$g/logs/ref/stash" ]
since reflogs are always in the filesystem. However, that seems somewhat
short-sighted, as the work Ronnie is doing is moving in the direction of
more abstraction here. I hope a day will come soon when reflogs do not
have to be stored in $GIT_DIR/logs, and then we would end up updating
this code again.
contrib/completion/git-prompt.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 9d684b1..c5473dc 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -468,7 +468,8 @@ __git_ps1 ()
fi
fi
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
- [ -r "$g/refs/stash" ]; then
+ git rev-parse --verify --quiet refs/stash >/dev/null
+ then
s="$"
fi
--
2.1.0.346.ga0367b9
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/5] git-prompt: do not look for refs/stash in $GIT_DIR
@ 2014-08-24 13:22 Gábor Szeder
2014-08-25 12:46 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Gábor Szeder @ 2014-08-24 13:22 UTC (permalink / raw)
To: Jeff King; +Cc: Michael Haggerty, git, Ronnie Sahlberg
Hi,
On Aug 23, 2014 12:26 PM, Jeff King <peff@peff.net> wrote:
> Since dd0b72c (bash prompt: use bash builtins to check stash
> state, 2011-04-01), git-prompt checks whether we have a
> stash by looking for $GIT_DIR/refs/stash. Generally external
> programs should never do this, because they would miss
> packed-refs.
Not sure whether the prompt script is external program or not, but doesn't matter, this is the right thing to do.
> That commit claims that packed-refs does not pack
> refs/stash, but that is not quite true. It does pack the
> ref, but due to a bug, fails to prune the ref. When we fix
> that bug, we would want to be doing the right thing here.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> I know we are pretty sensitive to forks in the prompt code (after all,
> that was the point of dd0b72c). This patch is essentially a reversion of
> this hunk of dd0b72c, and is definitely safe.
I'm not sure, but if I remember correctly (don't have the means to check it at the moment, sorry) in that commit I also added a 'git pack-ref' invocation to the relevant test(s?) to guard us against breakages due to changes in 'git pack-refs'. If that is so, then I think those invocations should be removed as well, as they'll become useless.
Best,
Gábor
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/5] git-prompt: do not look for refs/stash in $GIT_DIR
2014-08-24 13:22 [PATCH 1/5] git-prompt: do not look for refs/stash in $GIT_DIR Gábor Szeder
@ 2014-08-25 12:46 ` Jeff King
0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2014-08-25 12:46 UTC (permalink / raw)
To: Gábor Szeder; +Cc: Michael Haggerty, git, Ronnie Sahlberg
On Sun, Aug 24, 2014 at 08:22:41PM +0700, Gábor Szeder wrote:
> On Aug 23, 2014 12:26 PM, Jeff King <peff@peff.net> wrote:
> > Since dd0b72c (bash prompt: use bash builtins to check stash
> > state, 2011-04-01), git-prompt checks whether we have a
> > stash by looking for $GIT_DIR/refs/stash. Generally external
> > programs should never do this, because they would miss
> > packed-refs.
>
> Not sure whether the prompt script is external program or not, but
> doesn't matter, this is the right thing to do.
Yeah, by external I just meant "nothing outside of refs.c should make
this assumption".
> > That commit claims that packed-refs does not pack
> > refs/stash, but that is not quite true. It does pack the
> > ref, but due to a bug, fails to prune the ref. When we fix
> > that bug, we would want to be doing the right thing here.
> >
> > Signed-off-by: Jeff King <peff@peff.net>
> > ---
> > I know we are pretty sensitive to forks in the prompt code (after all,
> > that was the point of dd0b72c). This patch is essentially a reversion of
> > this hunk of dd0b72c, and is definitely safe.
>
> I'm not sure, but if I remember correctly (don't have the means to
> check it at the moment, sorry) in that commit I also added a 'git
> pack-ref' invocation to the relevant test(s?) to guard us against
> breakages due to changes in 'git pack-refs'. If that is so, then I
> think those invocations should be removed as well, as they'll become
> useless.
It did add that change (that's actually how I noticed the problem!
Thank you for being thorough in dd0b72c). My inclination is to leave the
pack-refs invocations, as they protect against a certain class of errors
(we are not doing the risky behavior now, but the purpose of the test
suite is to detect regressions; the next person to touch that code may
not be so careful as you were).
I don't feel too strongly, though, so if we want them gone, I'm OK with
that.
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-08-25 12:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-24 13:22 [PATCH 1/5] git-prompt: do not look for refs/stash in $GIT_DIR Gábor Szeder
2014-08-25 12:46 ` Jeff King
-- strict thread matches above, loose matches on Subject: below --
2014-08-23 5:23 [PATCH 0/5] fix pack-refs pruning of refs/foo Jeff King
2014-08-23 5:26 ` [PATCH 1/5] git-prompt: do not look for refs/stash in $GIT_DIR Jeff King
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).