Re: [PATCH 10/10] push: teach push to be quiet if local ref is strict subset of remote ref

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Steffen Prohaska
Date: Wednesday, October 31, 2007 - 12:53 am

On Oct 30, 2007, at 8:19 PM, Junio C Hamano wrote:


ok.

So, git push shall guarantee that all matching refs point
to the _same_ commit if a push was successful. Otherwise,
git push shall report an error.

Would it be acceptable if the error was less severe in the
case of local being a strict subset of remote?
Daniel proposed
"%s: nothing to push to %s, but you are not up-to-date and
may want to pull"
It would still be an error, but a less severe one.

It could also be a good idea to teach git push transactional
behaviour. It could check in advance ('--dry-run') if the
push will succeed. If not it should report the errors without
actually pushing. Then, _nothing_ would have been changed on
the remote. Only if everything is ok "git push" would modify
the remote. Well, I think it might be hard to avoid the race
condition when someone else pushes simultaneously to a shared
repo. But this hopefully rarely happens.



Yes, there are many ways you can mess up ;)



Ok and this is the root why I work only to completion between
pushes. I tried to figure out a "safe" workflow. If you
accidentally type "git push" nothing wrong should happen. I
am sure that people will sometimes type "git push" forgetting
to mention anything. At least, I am sure that _I_ will do this.

The only comfortable way to make "git push" safe with
the current behaviour is to work on local branches only to
completion. Then, you can push to any repository at any time
and nothing bad can happen.

Alternatives with existing git are

- never use "git push", but always tell git explicitly what you
   want. This is too dangerous for me because at some point I'll
   type "git push". The problem with "git push" is that it's
   really hard to undo. It's near to impossible if you pushed
   to a public remote. Therefore, I really want to avoid this danger.

- Configure specific push rules for remotes that switch off
   the "matching branches" default. You can for example 'switch'
   off the default by configuring
   "remote.$remote.push = nonexisting". But then I started
   to get annoyed by all the configuration work. I do not want
   to explain such details to people who get started with git.
   And you do not get reasonable messages either. And btw I'd
   prefer if git push just did the right thing.


Alternatives that require changing git push are

- git push would do _nothing_ by default. git push would ask
   "what do you mean? Need at least a remote, or better remote
    and branch."
   Options could be provided to push current branch (--current)
   or all matching branches (--matching).

- git push _by default_ would only push the current branch. This
   would at least be a "safer" default.

- git push would first run --dry-run and then ask for
   confirmation. Something like:
   "Do you really want to push this to that remote? Here is
   the URL and the branches. Did you really mean this?
   WARNING: you can't undo this operation. And btw if you say
   yes, I'll report errors anyway because some remotes are not
   strict subsets. So maybe you want to fix things first."

- git push can be configuration to push only the current
   branch, as outlined below. This would certainly work. What
   I do not like is that you first need to do some configuration
   before you get a safe working environment.



Yes, the current default behaviour of git push discourages me
to work that way.



In my view, that would be safer than what we have now.

	Steffen



-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 10/10] push: teach push to be quiet if local re ..., Steffen Prohaska, (Wed Oct 31, 12:53 am)
Re: [PATCH 10/10] push: teach push to be quiet if local re ..., Johannes Schindelin, (Fri Nov 2, 5:14 am)