git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Ericsson <ae@op5.se>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Junio C Hamano <junkio@cox.net>,
	Andy Whitcroft <apw@shadowen.org>,
	git@vger.kernel.org
Subject: Re: Pushing into a repository with working directory?
Date: Tue, 09 Jan 2007 10:15:28 +0100	[thread overview]
Message-ID: <45A35D30.3070305@op5.se> (raw)
In-Reply-To: <20070109033213.GC1904@spearce.org>

Shawn O. Pearce wrote:
> Junio C Hamano <junkio@cox.net> wrote:
>> However, I am not sure if that is easy to understand for the
>> users.  It would be sane to deny pushing into the current branch
>> for a non-bare repositories by default, and if we do allow it
>> (perhaps with 'git-push --force'), then detach the HEAD as you
>> suggest.  On the other hand, pushing into the current branch of
>> a bare repository should just work; the HEAD pointer in a bare
>> repository is not about the commit the index and the working
>> tree are based on, but which branch is the primary branch of the
>> repository.
> 
> But from the working directory management tools' perspective HEAD
> *is* about the current index and the current working directory.
> If HEAD doesn't match the index and working directory closely
> enough then the user is going to do something stupid, like commit
> a negative delta by accident.
> 
> Pushing into the current branch of a repository with a working
> directory probably shouldn't be allowed by default as users probably
> don't want to do that.


I do this all the time. I develop on my laptop and send changes to a 
testserver where I check out the revision I just pushed to the working 
directory attached to it. Doing it the other way around is cumbersome, 
as I've got ssh-authentication installed on the server but don't wish to 
have that on my laptop. I could ofcourse do this with the alternates 
mechanism and pull things from the alternate repo to the one I really 
use, but that seems like I have to work around a limitation in git that 
isn't really there (or at least shouldn't be there for any logical or 
technical reason).

>  But if --force is used then detaching the
> HEAD is probably the best idea.  The user could easily recover by
> doing `git checkout origbranch` (though they may need `git checkout
> -m origbranch` if their working directory was dirty).
> 

Since we can determine if there's a working directory or not, why not 
just allow the fast-forward case if the working directory is clean and 
update the working directory for the user? This can't lose any data and 
would also make it very easy to, fe, keep a website in git and just push 
it straight to the webserver  when there's been modifications in the 
users repo. --force should behave the same way, possibly with an extra 
check to see if the working directory is clean before checking it out.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

  reply	other threads:[~2007-01-09  9:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-02  4:51 Pushing into a repository with working directory? Shawn O. Pearce
2007-01-05  8:51 ` Andy Whitcroft
2007-01-05  8:54   ` Junio C Hamano
2007-01-05  9:32     ` Andy Whitcroft
2007-01-05  9:50       ` Junio C Hamano
2007-01-05 19:36     ` Shawn O. Pearce
2007-01-08 13:53       ` Andy Whitcroft
2007-01-09  0:57         ` Junio C Hamano
2007-01-09  3:32           ` Shawn O. Pearce
2007-01-09  9:15             ` Andreas Ericsson [this message]
2007-01-09 13:51               ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45A35D30.3070305@op5.se \
    --to=ae@op5.se \
    --cc=apw@shadowen.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).