git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 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
* [PATCH 0/5] fix pack-refs pruning of refs/foo
@ 2014-08-23  5:23 Jeff King
  2014-08-23  5:26 ` [PATCH 1/5] git-prompt: do not look for refs/stash in $GIT_DIR Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2014-08-23  5:23 UTC (permalink / raw)
  To: git; +Cc: Ronnie Sahlberg, Michael Haggerty

I noticed that "git pack-refs --all" will pack a top-level ref like
"refs/foo", but will not actually prune "$GIT_DIR/refs/foo". I do not
see the point in having a policy not to pack "refs/foo" if "--all" is
given. But even if we did have such a policy, this seems broken; we
should either pack and prune, or leave them untouched. I don't see any
indication that the existing behavior was intentional.

The problem is that pack-refs's prune_ref calls lock_ref_sha1, which
enforces this "no toplevel" behavior. I am not sure there is any real
point to this, given that most callers use lock_any_ref_for_update,
which is exactly equivalent but without the toplevel check.

The first two patches deal with this by switching pack-refs to use
lock_any_ref_for_update. This will conflict slightly with Ronnie's
ref-transaction work, as he gets rid of lock_ref_sha1 entirely, and
moves the code directly into prune_ref. This can be trivially resolved
in favor of my patch, I think.

The third patch is a cleanup I noticed while looking around, and I think
should not conflict with anyone (and is a good thing to do).

The last two are trickier. I wondered if we could get rid of
lock_ref_sha1 entirely. After pack-refs, there are two callers:
fast-import.c and walker.c. After converting the first, it occurred to
me that Ronnie might be touching the same areas, and I see that yes,
indeed, there's quite a bit of conflict (and he reaches the same end
goal of dropping it entirely).

So in that sense I do not mind dropping the final two patches. Ronnie's
endpoint is much better, moving to a ref_transaction. However, there is
actually a buffer overflow in the existing code. Ronnie's series fixes
it in a similar way (moving to a strbuf), and I'm fine with that
endpoint. But given that the ref transaction code is not yet merged (and
would certainly never be maint-track), I think it is worth applying the
buffer overflow fix separately.

I think the final patch can probably be dropped, then. It is a clean-up,
but one that we can just get when Ronnie's series is merged.

  [1/5]: git-prompt: do not look for refs/stash in $GIT_DIR
  [2/5]: pack-refs: prune top-level refs like "refs/foo"
  [3/5]: fast-import: clean up pack_data pointer in end_packfile
  [4/5]: fast-import: fix buffer overflow in dump_tags
  [5/5]: fast-import: stop using lock_ref_sha1

-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).