* bug: update hook failure doesn't prevent local deletion of a branch
@ 2007-07-25 11:50 Andy Parkins
2007-07-27 4:13 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Andy Parkins @ 2007-07-25 11:50 UTC (permalink / raw)
To: Git Mailing List
Hello,
I wanted to delete a branch (let's call it "deleted-branch") from my public
repository. I ran this:
$ git push origin :deleted-branch
deleting 'refs/heads/deleted-branch'
Also local refs/remotes/up/deleted-branch
*** Update hook: aborting
error: hooks/update exited with error code 1
error: hook declined to update refs/heads/deleted-branch
ng refs/heads/deleted-branch hook declined
error: failed to push to '/path/to/git/repo.git'
Coincidentally, my update hook happened to have a bug in it that prevented me
from running the operation.
However, when I run the operation again...
$ git push origin :deleted-branch
deleting 'refs/heads/deleted-branch'
Also local refs/remotes/up/deleted-branch
error: unlink(.git/refs/remotes/up/deleted-branch) failed: No such file or
directory
error: Failed to delete
If the remote didn't get deleted, then it seems wrong that the local copy does
get deleted.
Summary: when using git-push to delete a remote branch, and that deletion is
disallowed by the update hook, the local tracking branch _is_ deleted.
Obviously, this isn't _that_ serious because it could be recovered again with
a git-fetch; but it does make some scary looking errors.
Andy
--
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug: update hook failure doesn't prevent local deletion of a branch
2007-07-25 11:50 bug: update hook failure doesn't prevent local deletion of a branch Andy Parkins
@ 2007-07-27 4:13 ` Junio C Hamano
2007-07-27 4:26 ` Shawn O. Pearce
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-07-27 4:13 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Andy Parkins, Git Mailing List
Andy Parkins <andyparkins@gmail.com> writes:
> I wanted to delete a branch (let's call it "deleted-branch") from my public
> repository. I ran this:
>
> $ git push origin :deleted-branch
> deleting 'refs/heads/deleted-branch'
> Also local refs/remotes/up/deleted-branch
> *** Update hook: aborting
> error: hooks/update exited with error code 1
> error: hook declined to update refs/heads/deleted-branch
> ng refs/heads/deleted-branch hook declined
> error: failed to push to '/path/to/git/repo.git'
> ...
> Summary: when using git-push to delete a remote branch, and that deletion is
> disallowed by the update hook, the local tracking branch _is_ deleted.
Yes, a few months ago with b516968f, "send-pack" started to
pretend that it turned around and fetched immediately after it
attempted to push.
There are two problems with it. One is this exact problem Andy
reported. Newer receive-pack reports the status (if an update
of the ref was successful), and the sender _could_ try to detect
a failure and refrain from making the local side update (but if
the receive-pack running on the other end is old enough there is
no indication of an error); the code does not bother to do this
correctly. I think this is correctable without major changes.
If the remote end refused to update only one of the refs, and
send-pack as a whole fails, we could refrain from updating
anything local.
But another more fundamental issue is that post-update hook on
the receiving end could do anything it pleases (for example, it
could try to rebase what was pushed), and at the protocol level
there is no way to say "you tried to push this SHA-1 but we
replaced it with this other SHA-1 instead".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug: update hook failure doesn't prevent local deletion of a branch
2007-07-27 4:13 ` Junio C Hamano
@ 2007-07-27 4:26 ` Shawn O. Pearce
2007-07-27 5:00 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Shawn O. Pearce @ 2007-07-27 4:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Daniel Barkalow, Andy Parkins, Git Mailing List
Junio C Hamano <gitster@pobox.com> wrote:
> Andy Parkins <andyparkins@gmail.com> writes:
> > Summary: when using git-push to delete a remote branch, and that deletion is
> > disallowed by the update hook, the local tracking branch _is_ deleted.
>
> Yes, a few months ago with b516968f, "send-pack" started to
> pretend that it turned around and fetched immediately after it
> attempted to push.
>
> There are two problems with it. One is this exact problem Andy
> reported.
...
> I think this is correctable without major changes.
> If the remote end refused to update only one of the refs, and
> send-pack as a whole fails, we could refrain from updating
> anything local.
Reasonable. Probably pretty simple too.
> But another more fundamental issue is that post-update hook on
> the receiving end could do anything it pleases (for example, it
> could try to rebase what was pushed), and at the protocol level
> there is no way to say "you tried to push this SHA-1 but we
> replaced it with this other SHA-1 instead".
You keep raising this argument against the "git-push updates local
refs" feature. Its not just the post-update hook that could alter
the ref. Another user could just push behind you (and I mean right
behind you) and either force an update, delete the ref entirely, or
just fast-forward it. (Its entirely possible that the other user
does have the commit you just pushed, because you had previously
supplied it to them.) So its actually possible for the ref to have
changed again before you even see the successful update message on
your console.
I don't think it really matters. Based on the output you see from
git-push on screen you have good reason to believe that the ref
you just pushed to is now at the commit SHA-1 displayed. For that
reason alone I think it is correct to update the corresponding
tracking branch, because an immediate git-fetch just wastes the
user's time and will (usually) fetch the SHA-1 just pushed.
We should make our repository state reflect the user's internal
mental view of what just happened, especially here, because the
user's mental view is probably correct.
--
Shawn.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug: update hook failure doesn't prevent local deletion of a branch
2007-07-27 4:26 ` Shawn O. Pearce
@ 2007-07-27 5:00 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-07-27 5:00 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Daniel Barkalow, Andy Parkins, Git Mailing List
"Shawn O. Pearce" <spearce@spearce.org> writes:
> We should make our repository state reflect the user's internal
> mental view of what just happened, especially here, because the
> user's mental view is probably correct.
Fair enough. At least if we correct git-push so that when it
exits with failure it would not touch the local refs, I would
think that would make what happens to match user's mental model
much better. The user would be _told_ that it failed, and then
can fetch back if he cares where the remote heads are too
deeply.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-27 5:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-25 11:50 bug: update hook failure doesn't prevent local deletion of a branch Andy Parkins
2007-07-27 4:13 ` Junio C Hamano
2007-07-27 4:26 ` Shawn O. Pearce
2007-07-27 5:00 ` Junio C Hamano
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).