* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Junio C Hamano @ 2009-10-15 22:08 UTC (permalink / raw)
To: Junio C Hamano
Cc: Jeff King, Nicolas Pitre, James Pickens, Daniel Barkalow,
Jay Soffian, git
In-Reply-To: <7v1vl42uid.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> $ git checkout origin/next ;# ditto
> $ git symbolic-ref HEAD
> refs/remotes/origin/next
Ok, after reading Daniel's message to remind us that "git fetch" after
this will get us into trouble, I agree that detaching HEAD is inevitable.
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Junio C Hamano @ 2009-10-15 21:54 UTC (permalink / raw)
To: Jeff King
Cc: Junio C Hamano, Nicolas Pitre, James Pickens, Daniel Barkalow,
Jay Soffian, git
In-Reply-To: <20091015212632.GA13180@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> On Thu, Oct 15, 2009 at 12:52:55PM -0700, Junio C Hamano wrote:
>
>> I like James's suggestion to allow us to store refs other than refs/heads/
>> in HEAD to denote this state, and keep commit and reset from updating such
>> a ref through updating HEAD.
>
> Didn't we already consider and reject this the first time around? For
> example, this thread has a ton of stuff about how we shouldn't prevent
> people from making commits on the wandering state:
>
> http://thread.gmane.org/gmane.comp.version-control.git/35777/focus=35835
>
> And here's me even advocating this exact strategy (and I'm sure I didn't
> think of it; it's probably discussed elsewhere, too):
>
> http://thread.gmane.org/gmane.comp.version-control.git/35777/focus=35858
>
> Not that I am not necessarily complaining, but I just hope this decision
> is "with new-found knowledge we are revisiting this decision" and not
> "we totally forgot about what came before".
Maybe we are reading different messages in the same message.
My understanding of James's suggestion is:
(1) "git checkout $token" makes HEAD point at the refname dwim_ref()
expands $token to, iff dwim_ref() is happy, and otherwise detaches
HEAD;
(2) "git commit" (and other things like "git reset HEAD^" that updates
underlying ref thru updates to HEAD when HEAD is a symref) rejects
when HEAD points at a ref outside refs/heads/, but works when HEAD
points at a local branch, or when HEAD is detached.
As a consequence:
$ git checkout v1.6.5 ;# does not detach, cannot update
$ git symbolic-ref HEAD
refs/tags/v1.6.5
$ git checkout origin/next ;# ditto
$ git symbolic-ref HEAD
refs/remotes/origin/next
These are often done by sightseers, and we can add instructions to fork
and record upon an attempt to "git commit".
As a bonus, we get Daniel's extra information for detached HEAD for free,
as we can just read HEAD and learn what it points at. We need to design
what "git branch" should say in this case.
This is backward incompatible, and makes what experts are used to do
slightly cumbersome to spell, i.e.
$ git checkout v1.6.5^0 ;# detaches and can commit
$ git checkout origin/next^0 ;# ditto
$ git checkout $(git merge-base master sp/smart-http) ;# ditto
These detach, and I can apply the updates series to the same base as the
previous round on an unnamed branch.
So in other words, the semantics for detached HEAD case does not change at
all. We never forbid committing or resetting while on detached HEAD, as
it is meant to be an easy way to get an unnamed throw-away state that is
not even worth coming up with a unique temporary branch name, and I do not
think the above contradicts with what was said in 35835.
We used to have only two states on HEAD: either on a local branch or
detached. James is introducing another state: on a ref that is not a
local branch.
As that is useful for common sightseer tasks, we can afford to forbid
committing or updating for safety and we do not have to worry about
hurting the established usefulness of how detached HEAD works.
One drawback is that you cannot be in this sightseeing state without
having a ref. You can have "look-but-not-touch" checkout on origin/next
or origin/master, but you cannot sightsee the parent of origin/next the
same way (it would detach). I do not know if it is a big deal, though.
If it is very important to support:
$ git checkout --look-but-not-touch origin/next^
then James's approach would not be very useful, as we do have to detach
HEAD and implement the "do not touch" logic for detached HEAD state
anyway, so we might just use the same logic we would use for origin/next^
when checking out origin/next itself.
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-15 21:48 UTC (permalink / raw)
To: Daniel Barkalow
Cc: Junio C Hamano, James Pickens, Jeff King, Jay Soffian, git
In-Reply-To: <alpine.LNX.2.00.0910151653480.32515@iabervon.org>
On Thu, 15 Oct 2009, Daniel Barkalow wrote:
> On Thu, 15 Oct 2009, Junio C Hamano wrote:
>
> > Daniel Barkalow <barkalow@iabervon.org> writes:
> >
> > > $ git checkout origin/master
> > > $ git fetch
> > > $ git checkout origin/next
> > > Uncommited file '...' would be overwritten.
> > >
> > > If HEAD is a symref to refs/remotes/origin/master, and you update
> > > refs/remotes/origin/master, git will subsequently see that your index
> > > doesn't match HEAD, and when you switch branches, it will try to apply a
> > > revert to the branch you're switching to. It's the same issue as pushing
> > > into a non-bare repository.
> >
> > I think the idea here is to allow HEAD to point at outside refs/heads/,
> > e.g. refs/remotes/origin/master, but forbid commit and other commands from
> > updating HEAD and its underlying ref via update_ref() unless HEAD is
> > detached or points at a local branch.
>
> $ git checkout origin/master
> $ git fetch
> (Some error)
Right.
So we're back to your initial proposal I guess (storing some info/state
in .git/HEAD when detached).
Nicolas
^ permalink raw reply
* Re: My custom cccmd
From: Felipe Contreras @ 2009-10-15 21:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vk4yw4dy3.fsf@alter.siamese.dyndns.org>
On Thu, Oct 15, 2009 at 11:09 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> Hi,
>>
>> I love the new option to run a cccmd and how good it works on the
>> linux kernel, but I couldn't find a generic script. So I decided to
>> write my own.
>>
>> It's very simple, it just looks into the authors of the commits that
>> modified the lines being overridden (git blame). It's not checking for
>> s-o-b, or anything fancy.
>>
<snip/>
> Comments.
>
> #0. Gaahhh, my eyes, my eyes!! Can't you do this ugly run of infinite
> number of "end"s?
Hehe, sure. Will do.
> #1. You are not making sure that you start blaming from the commit the
> patch is based on, so your -La,b line numbers can be off. If you can
> assume that you are always reading format-patch output, you can learn
> which commit to start from by reading the first "magic" line.
The 'From' magic line points to the actual commit the patch was
generated from, so it would actually be @from^.
This of course would only work if the patches have the corresponding
commits in the current tree (which is the case most of the time).
And makes sense only for the first patch, the rest of the patches
would use a wrong commit as a base. See below.
> #2. If you have two patch series that updates one file twice, some
> changes in your second patch could even be an update to the changes
> you introduced in your first patch. After you fix issue #1, you
> would probably want to fix this by excluding the commits you have
> already sent the blames for.
How exactly? By looking at the commit from 'git blame' and discarding
it? That would be a bit tricky since each instance of 'cccmd' is not
aware of the previous ones.
> #3. Does the number of commits you keep per author have any significance?
> I know it doesn't in the implementation you posted, but should it,
> and if so how?
Not currently. Once I add support for s-o-b it might be useful.
Currently I left it in order to order the CC's by the count, but it
turned out to be a bit messier than I thought, and the advantage is
almost nothing.
I'll clean it up.
Taking in consideration the previous comments, here is v2:
#!/usr/bin/env ruby
@authors = {}
def parse_blame(line)
key, value = line.split(" ", 2)
case key
when "author"
@name = value
when "author-mail"
@mail = value
author = "\"#{@name}\" #{@mail}"
@authors[author] = true
end
end
ARGV.each do |filename|
patch_file = File.open(filename)
patch_file.each_line do |patch_line|
case patch_line
when /^---\s+(\S+)/
@source = $1[2..-1]
when /^@@\s-(\d+),(\d+)/
blame = `git blame -p -L #{$1},+#{$2} #{@source} | grep author`
blame.each_line { |l| parse_blame(l.chomp) }
end
end
end
@authors.each_key do |a|
puts a
end
--
Felipe Contreras
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Daniel Barkalow @ 2009-10-15 21:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: James Pickens, Jeff King, Nicolas Pitre, Jay Soffian, git
In-Reply-To: <7v3a5k4cri.fsf@alter.siamese.dyndns.org>
On Thu, 15 Oct 2009, Junio C Hamano wrote:
> Daniel Barkalow <barkalow@iabervon.org> writes:
>
> > $ git checkout origin/master
> > $ git fetch
> > $ git checkout origin/next
> > Uncommited file '...' would be overwritten.
> >
> > If HEAD is a symref to refs/remotes/origin/master, and you update
> > refs/remotes/origin/master, git will subsequently see that your index
> > doesn't match HEAD, and when you switch branches, it will try to apply a
> > revert to the branch you're switching to. It's the same issue as pushing
> > into a non-bare repository.
>
> I think the idea here is to allow HEAD to point at outside refs/heads/,
> e.g. refs/remotes/origin/master, but forbid commit and other commands from
> updating HEAD and its underlying ref via update_ref() unless HEAD is
> detached or points at a local branch.
$ git checkout origin/master
$ git fetch
(Some error)
I think it would be much more confusing for many users if you couldn't
do:
$ git checkout origin/master
(look at origin/master)
(wait a day)
$ git fetch
$ git checkout origin/next
(look at origin/next)
Part of the original point of detached HEAD was to support this pattern
without creating an undesired local branch (which falls out of date),
having problems with updating the tracking branches, or having problems
with direct changes to the ref that HEAD points to.
Currently, HEAD is never a symref to anything that will ever be updated
normally except though the symref. That's a really handy property that
avoids making us deal with lots of special cases in weird places. And
those special cases would not only be annoying to have to handle again,
but they'd be complexity that users would have to be exposed to.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Jeff King @ 2009-10-15 21:26 UTC (permalink / raw)
To: Junio C Hamano
Cc: Nicolas Pitre, James Pickens, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <7v1vl45t9k.fsf@alter.siamese.dyndns.org>
On Thu, Oct 15, 2009 at 12:52:55PM -0700, Junio C Hamano wrote:
> I like James's suggestion to allow us to store refs other than refs/heads/
> in HEAD to denote this state, and keep commit and reset from updating such
> a ref through updating HEAD.
Didn't we already consider and reject this the first time around? For
example, this thread has a ton of stuff about how we shouldn't prevent
people from making commits on the wandering state:
http://thread.gmane.org/gmane.comp.version-control.git/35777/focus=35835
And here's me even advocating this exact strategy (and I'm sure I didn't
think of it; it's probably discussed elsewhere, too):
http://thread.gmane.org/gmane.comp.version-control.git/35777/focus=35858
Not that I am not necessarily complaining, but I just hope this decision
is "with new-found knowledge we are revisiting this decision" and not
"we totally forgot about what came before".
-Peff
^ permalink raw reply
* Git gui and gitk documentation
From: chris miles @ 2009-10-15 20:51 UTC (permalink / raw)
To: git
Hi
I'm looking for documentation on gitk and the gui that is distributed with git.
Could anyone point me in the right direction?
Thanks
Chris Miles
_________________________________________________________________
Did you know you can get Messenger on your mobile?
http://clk.atdmt.com/UKM/go/174426567/direct/01/
^ permalink raw reply
* Re: [RFC PATCH v3 00/17] Return of smart HTTP
From: Shawn O. Pearce @ 2009-10-15 20:45 UTC (permalink / raw)
To: Junio C Hamano, Daniel Barkalow; +Cc: Johan Herland, Nanako Shiraishi, git
In-Reply-To: <7vfx9k4d33.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>
> > It does. It is caused by the disconnect_helper call inside of
> > fetch_with_import. You can't disconnect inside of the fetch method
> > of a transport, the caller is going to disconnect you a second time.
> > ...
> > This bug isn't due to the merge, its a bug in Johan's series that
> > needs to be fixed before it could merge down to next/master.
...
> I am a bit confused about your diagnosis, though. As far as I recall,
> Johan's topic itself nor 'pu' with Johan's topic but without v2 of
> sp/smart-http did not have the issue.
Sadly, sometimes double frees do not result in segfaults, other
times they do. The reason you are not seeing a problem with these
other variants is because of luck, not code correctness.
Actually, after some further research, the bug is not Johan's but is
actually Daniel's. Johan, I apologize for claiming it was your bug.
In:
commit 23a3380ee9c2d5164712c40f8821cb0fba24e80c
Author: Daniel Barkalow <barkalow@iabervon.org>
Date: Thu Sep 3 22:14:01 2009 -0400
Add support for "import" helper command
Daniel introduces the fetch_with_import() function to
transport-helper.c. This method calls disconnect_helper():
+static int fetch_with_import(struct transport *transport,
+ int nr_heads, struct ref **to_fetch)
+{
...
+ disconnect_helper(transport);
+ finish_command(&fastimport);
Unfortunately this is in the middle of the transport_fetch() call
stack; transport_fetch() called the static fetch() function in
transport-helper.c, which in turn called fetch_with_import().
Callers (e.g. builtin-fetch.c) invoke transport_close() when
they are done with the handle (see line 704). That in turn calls
disconnect_helper() a second time.
The disconnect_helper function is not prepared to be called twice:
static int disconnect_helper(struct transport *transport)
{
struct helper_data *data = transport->data;
if (data->helper) {
...
}
free(data);
return 0;
}
Because of that unexpected invocation inside of fetch_with_import
we have already free'd the memory block used by transport->data,
and the second invocation attempts to free it again. Worse, if the
block was reused by a subsequent malloc, data->helper might not be
NULL, and we'd enter into the if block and do its work again.
Long story short, transport_close() is what is supposed to perform
the work that disconnect_helper does, as its the final thing right
before we free the struct transport block. Free'ing the data block
inside of the fetch or push functions is wrong.
Its fine to close the helper and restart it within the single
lifespan of a struct transport, but dammit, don't free the
struct helper_data until transport_close().
--
Shawn.
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Junio C Hamano @ 2009-10-15 20:34 UTC (permalink / raw)
To: Daniel Barkalow
Cc: James Pickens, Jeff King, Junio C Hamano, Nicolas Pitre,
Jay Soffian, git
In-Reply-To: <alpine.LNX.2.00.0910151523020.32515@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
> $ git checkout origin/master
> $ git fetch
> $ git checkout origin/next
> Uncommited file '...' would be overwritten.
>
> If HEAD is a symref to refs/remotes/origin/master, and you update
> refs/remotes/origin/master, git will subsequently see that your index
> doesn't match HEAD, and when you switch branches, it will try to apply a
> revert to the branch you're switching to. It's the same issue as pushing
> into a non-bare repository.
I think the idea here is to allow HEAD to point at outside refs/heads/,
e.g. refs/remotes/origin/master, but forbid commit and other commands from
updating HEAD and its underlying ref via update_ref() unless HEAD is
detached or points at a local branch.
^ permalink raw reply
* Re: [RFC PATCH v3 00/17] Return of smart HTTP
From: Junio C Hamano @ 2009-10-15 20:27 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Johan Herland, Nanako Shiraishi, Junio C Hamano, git
In-Reply-To: <20091015154142.GL10505@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
> It does. It is caused by the disconnect_helper call inside of
> fetch_with_import. You can't disconnect inside of the fetch method
> of a transport, the caller is going to disconnect you a second time.
> ...
> This bug isn't due to the merge, its a bug in Johan's series that
> needs to be fixed before it could merge down to next/master.
Thanks; I pushed out 'pu' with your v3 this time.
Last night I did a trial fetch merge with FETCH_HEAD into 'pu', but then
after I queued some fixes to 'maint' and 'master' to prepare for 1.6.5.1,
I rebuilt 'pu' with the still-old sp/smart-http topic, and that is what
was sitting at k.org til this morning.
I am a bit confused about your diagnosis, though. As far as I recall,
Johan's topic itself nor 'pu' with Johan's topic but without v2 of
sp/smart-http did not have the issue. Does that indicate that the
behaviour expected from the fetch method is different between the two
topics, and this indeed is a semantic conflict as you suspected initially?
In other words, if Johan's series is updated not to disconnect inside the
fetch method of the transport, and if it is not merged with your series,
does the caller still disconnect it properly?
^ permalink raw reply
* Re: My custom cccmd
From: Junio C Hamano @ 2009-10-15 20:09 UTC (permalink / raw)
To: Felipe Contreras; +Cc: git
In-Reply-To: <94a0d4530910150620g733bdf0aq88660053f869b0a9@mail.gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
> Hi,
>
> I love the new option to run a cccmd and how good it works on the
> linux kernel, but I couldn't find a generic script. So I decided to
> write my own.
>
> It's very simple, it just looks into the authors of the commits that
> modified the lines being overridden (git blame). It's not checking for
> s-o-b, or anything fancy.
>
> Comments?
> #!/usr/bin/env ruby
>
> @commits = {} # keeps a count of commits per author
>
> ARGV.each do |filename|
> File.open(filename) do |patch_file|
> patch_file.each_line do |patch_line|
> case patch_line
> when /^---\s+(\S+)/
> @source = $1[2..-1]
> when /^@@\s-(\d+),(\d+)/
> blame = `git blame -p -L #{$1},+#{$2} #{@source} | grep author`
> blame.each_line do |al|
> key, value = al.chomp.split(" ", 2)
> case key
> when "author"
> @name = value
> when "author-mail"
> @mail = value
> author = "\"#{@name}\" #{@mail}"
> @commits[author] ||= 0
> @commits[author] += 1
> end
> end
> end
> end
> end
> end
Comments.
#0. Gaahhh, my eyes, my eyes!! Can't you do this ugly run of infinite
number of "end"s?
#1. You are not making sure that you start blaming from the commit the
patch is based on, so your -La,b line numbers can be off. If you can
assume that you are always reading format-patch output, you can learn
which commit to start from by reading the first "magic" line.
#2. If you have two patch series that updates one file twice, some
changes in your second patch could even be an update to the changes
you introduced in your first patch. After you fix issue #1, you
would probably want to fix this by excluding the commits you have
already sent the blames for.
#3. Does the number of commits you keep per author have any significance?
I know it doesn't in the implementation you posted, but should it,
and if so how?
> @commits.each_key do |a|
> puts a
> end
>
> --
> Felipe Contreras
> --
> 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
^ permalink raw reply
* Re: [PATCH v3] git-gui: adjust the minimum height of diff pane for shorter screen height
From: Junio C Hamano @ 2009-10-15 19:57 UTC (permalink / raw)
To: Vietor Liu; +Cc: Shawn O. Pearce, git, Johannes Schindelin
In-Reply-To: <1255583127-14893-1-git-send-email-vietor@vxwo.org>
Vietor Liu <vietor@vxwo.org> writes:
> When the screen height is shorter (e.g. Netbook screen 1024x600), both the
> partial commit pane and the status bar will hide. This patch adjust the
> minimum height of the diff pane, allowing the overall window to be shorter
> and still display both the entire commit pane and status bar.
Ah, I finally can parse and understand what this s/15/5/ change was about
;-). Perhaps with "s/will hide/are hidden/" it would be perfect?
>
> Signed-off-by: Vietor Liu <vietor@vxwo.org>
> ---
> git-gui.sh | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index 09b2720..037a1f2 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -3083,7 +3083,7 @@ frame .vpane.lower.diff.body
> set ui_diff .vpane.lower.diff.body.t
> text $ui_diff -background white -foreground black \
> -borderwidth 0 \
> - -width 80 -height 15 -wrap none \
> + -width 80 -height 5 -wrap none \
> -font font_diff \
> -xscrollcommand {.vpane.lower.diff.body.sbx set} \
> -yscrollcommand {.vpane.lower.diff.body.sby set} \
> --
> 1.6.5
>
> --
> 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
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Junio C Hamano @ 2009-10-15 19:52 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: James Pickens, Jeff King, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <alpine.LFD.2.00.0910151436180.20122@xanadu.home>
Nicolas Pitre <nico@fluxnic.net> writes:
> It is indeed simpler. It makes the checkout command less verbose as
> well. Only the commit command would need to warn the user and only if a
> forbidden operation is attempted (like committing on a non
> refs/heads/*). I think I like this.
I like James's suggestion to allow us to store refs other than refs/heads/
in HEAD to denote this state, and keep commit and reset from updating such
a ref through updating HEAD.
We have code to prevent HEAD from pointing at anywhere outside refs/heads/
and that may even be an isolated single codepath we need to tweak. But I
am reasonably sure that the layers above these core-level routines have
their own checks to make sure HEAD is either detached or points at
refs/heads/ somewhere; we would need to identify and change them as well.
Also things like "git branch" need to be told that HEAD may point outside
of refs/heads/ now to adjust their output style accordingly. They may
probably strip refs/heads/ (or 11 bytes) assuming that attached HEAD will
never point outside the local branch hierarchy.
So I expect there will be tons of tiny fallouts from a change like that,
but still it is conceptually simpler, and it would reduce the scope of
detached HEAD to a temporary state that is not even worth being named with
a branch name, which is exactly what it is.
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Daniel Barkalow @ 2009-10-15 19:31 UTC (permalink / raw)
To: James Pickens; +Cc: Jeff King, Junio C Hamano, Nicolas Pitre, Jay Soffian, git
In-Reply-To: <885649360910150036o72c3bd97ofad85d5316dc5b35@mail.gmail.com>
On Thu, 15 Oct 2009, James Pickens wrote:
> On Wed, Oct 14, 2009 at 4:09 PM, Jeff King <peff@peff.net> wrote:
> > That makes the most sense to me. If "git checkout" could write metadata
> > into HEAD (or into DETACH_HEAD, as in Daniel's patch), then checkout
> > could record an "ok to commit" bit. And could also be used to change it
> > after the fact. E.g.:
> >
> > $ git checkout --detach=commit origin/master
> > $ git commit ;# should be ok
> >
> > $ git checkout --detach=examine origin/master
> > $ git commit ;# complain
> > $ git checkout --detach=commit HEAD
> > $ git commit ;# ok
> >
> > I guess something like "rebase" should detach with "ok to commit", since
> > it is planning on attaching the commits later. I'm not sure about "git
> > bisect". I guess probably it should be "not ok to commit" to be on the
> > safe side, and then somebody can "git checkout --detach=commit" if they
> > want to.
>
> How about not detaching the head at all if the user checks out any ref, and
> reject commits if he checked out a tag or remote branch. For example:
>
> $ git checkout origin/master
> $ git status
> # On branch origin/master
> $ git commit ;# complain
$ git checkout origin/master
$ git fetch
$ git checkout origin/next
Uncommited file '...' would be overwritten.
If HEAD is a symref to refs/remotes/origin/master, and you update
refs/remotes/origin/master, git will subsequently see that your index
doesn't match HEAD, and when you switch branches, it will try to apply a
revert to the branch you're switching to. It's the same issue as pushing
into a non-bare repository.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Daniel Barkalow @ 2009-10-15 19:22 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: James Pickens, Jeff King, Junio C Hamano, Jay Soffian, git
In-Reply-To: <alpine.LFD.2.00.0910151504510.20122@xanadu.home>
On Thu, 15 Oct 2009, Nicolas Pitre wrote:
> On Thu, 15 Oct 2009, Daniel Barkalow wrote:
>
> > I think the description used in CVS and SVN (and, I think, others) is that
> > you're not at the HEAD revision. I think they both account for the state
> > where you've checked out the revision by number that's the latest
> > revision, but you still can't grow the branch because you can't
> > simultaneously stay on r1000 (as requested explicitly) and add a new
> > commit.
> >
> > So maybe the right explanation is:
> >
> > $ git checkout master; git branch
> > * master
> > $ git checkout origin/master; git branch
> > * origin/master (not at head)
> > $ git checkout 123cafe^5; git branch
> > * 123cafe^5 (not at head)
>
> I think this is wrong. Git has multiple heads, and insisting on "not at
> head" would be extremely confusing.
Maybe "(not at a head)"? Git does have multiple heads, but what's checked
out isn't one of them, and that's actually the point.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-15 19:07 UTC (permalink / raw)
To: Daniel Barkalow
Cc: James Pickens, Jeff King, Junio C Hamano, Jay Soffian, git
In-Reply-To: <alpine.LNX.2.00.0910151054190.32515@iabervon.org>
On Thu, 15 Oct 2009, Daniel Barkalow wrote:
> I think the description used in CVS and SVN (and, I think, others) is that
> you're not at the HEAD revision. I think they both account for the state
> where you've checked out the revision by number that's the latest
> revision, but you still can't grow the branch because you can't
> simultaneously stay on r1000 (as requested explicitly) and add a new
> commit.
>
> So maybe the right explanation is:
>
> $ git checkout master; git branch
> * master
> $ git checkout origin/master; git branch
> * origin/master (not at head)
> $ git checkout 123cafe^5; git branch
> * 123cafe^5 (not at head)
I think this is wrong. Git has multiple heads, and insisting on "not at
head" would be extremely confusing.
Nicolas
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-15 19:03 UTC (permalink / raw)
To: Jakub Narebski
Cc: James Pickens, Jeff King, Junio C Hamano, Daniel Barkalow,
Jay Soffian, git
In-Reply-To: <m3bpk8g6nj.fsf@localhost.localdomain>
On Thu, 15 Oct 2009, Jakub Narebski wrote:
> James Pickens <jepicken@gmail.com> writes:
>
> > I think this would help the newbies and wouldn't cost the experts too much.
> > Checking out anything other than a plain ref would still detach the head, and
> > commits on a detached head would still be allowed.
>
> I think it is a very good idea.
>
> This makes it easy to checkout remote-tracking branch or a tag for
> viewing, something that was (I think) one of problems (use cases) that
> lead to invention of detached HEAD... and then it turned out that
> detached HEAD (unnamed branch) is scary for newbie git users. (So the
> difficulty of having to create new branch or rewind some branch to
> view non-committable ref was replaced by scary detached HEAD concept.)
I don't think detached head is scary at all (unless viewed in another
context other than git) but if that encounter can be kept away from most
users without denying its use then all for the better.
> With this idea there are no problems with git commands that use
> detached HEAD such as git-bisect (which uses it in viewing mode, but
> then skips through history, so detached HEAD is a good solution here)
> or git-rebase (which does committing on detached HEAD for easier
> aborting and cleanup).
I do like and actively use manual committing on a detached HEAD as well,
so please let's not forget about that use case.
> Let me propose additional feature: "smart" (context sensitive)
> warnings, namely that in the following sequence
>
> $ git checkout origin/master
> $ git status
> # On remote-tracking branch origin/master of remote origin
> # ...
Sure.
> $ git commit
>
> 'git commit' would refuse committing on non-heads ref, and propose,
> beside _always_ proposing detaching HEAD and committing on such
> detached HEAD (unnamed branch) via "git checkout HEAD^0", or
> "git checkout --detach [HEAD]":
... or the current "this is not a local branch -- use checkout -b to
create one" warning, just like what we have today when checking out a
tag or remote branch, except that the warning is deferred to the commit
operation which in fact might even not take place.
> 1. If there is no local branch which follows 'origin/master'
> (which has 'origin/master' as upstream, which tracks 'origin/master')
> propose creating it before comitting:
>
> $ git checkout -t origin/master
>
> 2. If there is single local branch that follows 'origin/master',
> and it fast-forwards to 'origin/master' propose...
> errr, something that would mean fast-forwarding this branch
> and making a commit on local branch that has 'origin/master'
> as upstream.
>
> 3. If there is single local branch that follows 'origin/master', but
> it has changes / diverges from 'origin/master' we are viewing,
> propose... hmmm, what then?
>
> 4. If there are more than one local branch that has 'origin/master'
> as upstream, list all those branches in message.
I wouldn't go too far in that direction though. Too many suggestions
would simply bring back confusion to the new user who at that point
might not even understand yet what all the different concepts are.
Nicolas
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-15 18:51 UTC (permalink / raw)
To: James Pickens
Cc: Jeff King, Junio C Hamano, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <885649360910150036o72c3bd97ofad85d5316dc5b35@mail.gmail.com>
On Thu, 15 Oct 2009, James Pickens wrote:
> On Wed, Oct 14, 2009 at 4:09 PM, Jeff King <peff@peff.net> wrote:
> > That makes the most sense to me. If "git checkout" could write metadata
> > into HEAD (or into DETACH_HEAD, as in Daniel's patch), then checkout
> > could record an "ok to commit" bit. And could also be used to change it
> > after the fact. E.g.:
> >
> > $ git checkout --detach=commit origin/master
> > $ git commit ;# should be ok
> >
> > $ git checkout --detach=examine origin/master
> > $ git commit ;# complain
> > $ git checkout --detach=commit HEAD
> > $ git commit ;# ok
> >
> > I guess something like "rebase" should detach with "ok to commit", since
> > it is planning on attaching the commits later. I'm not sure about "git
> > bisect". I guess probably it should be "not ok to commit" to be on the
> > safe side, and then somebody can "git checkout --detach=commit" if they
> > want to.
>
> How about not detaching the head at all if the user checks out any ref, and
> reject commits if he checked out a tag or remote branch. For example:
>
> $ git checkout origin/master
> $ git status
> # On branch origin/master
> $ git commit ;# complain
>
> $ git checkout v1.0.1
> $ git status
> # On tag v1.0.1
> $ git commit ;# complain
>
> $ git checkout v1.0.1^0 ;# detach
> $ git commit ;# ok
>
> I think this would help the newbies and wouldn't cost the experts too much.
I agree.
> Checking out anything other than a plain ref would still detach the
> head, and commits on a detached head would still be allowed. Perhaps
> as an additional safety feature, Git could refuse to switch away from
> a detached head if the head isn't reachable from any ref, and require
> -f to override:
>
> $ git checkout $sha1
> $ git commit
> $ git checkout master ;# complain
> $ git checkout -f master ;# ok
Nah. This is obnoxious. The usual "this is not a local branch" warning
could be displayed at that point, and if one really ignores the warning
then any commit made that way is always reachable through the reflog.
You would have had to work a bit harder to detach HEAD already anyway,
so at that point you're not supposed to be such a newbie anymore.
> Maybe I'm missing something and this all can't be done, but it seems simpler
> than the other options I've seen in this thread.
It is indeed simpler. It makes the checkout command less verbose as
well. Only the commit command would need to warn the user and only if a
forbidden operation is attempted (like committing on a non
refs/heads/*). I think I like this.
Nicolas
^ permalink raw reply
* Re: [PATCH] gitweb: linkify author/committer names with search
From: Stephen Boyd @ 2009-10-15 18:30 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, Junio C Hamano, Giuseppe Bilotta
In-Reply-To: <200910151341.36520.jnareb@gmail.com>
Jakub Narebski wrote:
>
> I see that it can be useful. But is this discoverable, and does this
> do expected thing? Most of links in gitweb lead to some view (page)
> that is specific to link; other lead to anchor on same page. Leading
> to search results can be unexpected.
>
> Perhaps title explaining what does such link does would help? Or making
> style of this link distinct from other (dashed underline, dashed
> underline on mouseover, double underline, different mouse cursor on
> mouseover, etc.)?
A title sounds good. Something like "List commits by $author"? I'll try
to write something up by tonight.
^ permalink raw reply
* Re: How does format-patch determine the filename of the patch?
From: Robin Rosenberg @ 2009-10-15 17:59 UTC (permalink / raw)
To: Timur Tabi; +Cc: git
In-Reply-To: <ed82fe3e0910150917u72ef189epc74411e71a9cd2d4@mail.gmail.com>
torsdag 15 oktober 2009 18:17:09 skrev Timur Tabi:
> Hi. I'm not familiar with the git source code, so forgive me if this
> is a dumb question. I'm trying to determine the algorithm that
> git-format-patch uses to determine the name of the patch file it
> creates (e.g. "0001-this-is-my-patch-without-spaces-and-trunca.patch")
> I'm looking at the function cmd_format_patch(), and I just don't see
> where it creates any files. Can someone show me where this code is?
>
> The reason I ask is that I'm writing a script which calls
> git-format-patch to create some patches for post-processing. So I
> need the name of the file that git-format-patch creates so that I can
> open it and examine it. I'd liked to see if there's a way to get the
> name of the patch without actually creating the file.
It tells you the names on stdout.
-- robin
^ permalink raw reply
* git am can't import patches with the UTF8 BOM
From: Ondrej Certik @ 2009-10-15 17:51 UTC (permalink / raw)
To: Git Mailing List
Hi,
this happens to me very often when someone sends a patch using windows
(and I use linux):
$ git am ~/Desktop/0001-1664-nonsymbolic-systems-may-need-basis-recalculatio.patch
Patch format detection failed.
and the problem is that the patch contains the byte-order mark (BOM)
at the beginning:
$ hexdump -C ~/Desktop/0001-1664-nonsymbolic-systems-may-need-basis-recalculatio.patch
| less
00000000 ef bb bf 46 72 6f 6d 20 39 31 37 63 30 39 36 32 |...From 917c0962|
00000010 32 38 35 30 37 37 31 66 38 33 33 62 35 66 39 34 |2850771f833b5f94|
00000020 30 36 65 30 64 65 37 33 30 35 61 34 30 38 66 65 |06e0de7305a408fe|
00000030 20 4d 6f 6e 20 53 65 70 20 31 37 20 30 30 3a 30 | Mon Sep 17 00:0|
00000040 30 3a 30 30 20 32 30 30 31 0a 46 72 6f 6d 3a 20 |0:00 2001.From: |
e.g. it's the "ef bb bf" as can be checked on the wikipedia:
http://en.wikipedia.org/wiki/Byte-order_mark#Representations_of_byte_order_marks_by_encoding
for utf-8.
So either the windows version of git should not send the BOM in the
first place, or the linux version of git should be able to handle it.
Which of those should be fixed?
Thanks,
Ondrej
P.S. I currently use this simple python script to strip it:
------------------------
#!/usr/bin/python
"""
Fixes a bogus git patch.
Sometimes a patch that people submit to sympy contains the UTF-8 byte-order
mark (BOM), which are 3 character at the beginning, that cause "git am" to fail
when applying it. The solution is to remove them, which is the purpose of this
script. See this link for more info:
http://en.wikipedia.org/wiki/Byte-order_mark
Usage:
git-fix-patch some.patch > some_fixed.patch
you can also rewrite the original file with the fix (inplace) by:
git-fix-patch -s some.patch
"""
from textwrap import fill
import os
import re
from optparse import OptionParser
def main():
parser = OptionParser(usage="[options] args")
parser.add_option("-s", "--save", dest="save", action="store_true",
default=False,
help="Rewrite the original file with the fixed patch")
options, args = parser.parse_args()
if len(args) != 1:
parser.print_help()
return
filename = args[0]
s = open(filename).read()
start = s.find("From")
if start > 10:
raise Exception("Uknown format of the git patch")
# strip the bogus characters at the beginning of the file
s = s[start:]
# either save to a file or dump to stdout:
if options.save:
outfile = filename
open(outfile, "w").write(s)
else:
print s
if __name__ == '__main__':
main()
-----------------------
^ permalink raw reply
* Re: How does format-patch determine the filename of the patch?
From: Thomas Rast @ 2009-10-15 17:48 UTC (permalink / raw)
To: Timur Tabi; +Cc: git
In-Reply-To: <ed82fe3e0910150917u72ef189epc74411e71a9cd2d4@mail.gmail.com>
Timur Tabi wrote:
> Hi. I'm not familiar with the git source code, so forgive me if this
> is a dumb question. I'm trying to determine the algorithm that
> git-format-patch uses to determine the name of the patch file it
> creates (e.g. "0001-this-is-my-patch-without-spaces-and-trunca.patch")
> I'm looking at the function cmd_format_patch(), and I just don't see
> where it creates any files. Can someone show me where this code is?
get_patch_filename() in log-tree.c, but the bulk of the work is done
in the call out to format_commit_message() [pretty.c] with the "%f"
format, which is in turn handled by format_sanitized_subject()
[pretty.c].
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: [RFC PATCH 1/4] Document the HTTP transport protocol
From: Jeff King @ 2009-10-15 17:39 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20091015165228.GO10505@spearce.org>
On Thu, Oct 15, 2009 at 09:52:28AM -0700, Shawn O. Pearce wrote:
> > And I can see it being useful for sites like github
> > which already have a cookie-based login.
>
> What I'm concerned about is using the cookie jar. My Mac OS X
> laptop has 5 browsers installed, each with their own #@!*! cookie
> jar: Safari, Opera, Firefox, Camino, Google Chrome. How the hell
> is the git client going to be able to use those cookies in order
> to interact with a website that requires cookie authentication?
Sure, it is obviously something that an implementation will have to deal
with. Either through manual configuration by the user or some
auto-detection magic that tries to cover every case (and I suspect if we
really wanted to do this, a patch to libcurl to handle different cookie
jar formats would probably be the best way to go).
But my main point was that it is an implementation issue, not a protocol
issue. The lines are a little blurry for us because there really aren't
very many git implementations, but I think your document is an attempt
to document just the protocol to allow interoperability between clients.
But I think you got my point:
> Not technical, but I want to reduce the amount of complexity that
> a conforming client has to deal with to reduce support costs for
> everyone involved.
>
> I weakend the sections on cookies:
>
> + Authentication
> + --------------
> ....
> + Servers SHOULD NOT require HTTP cookies for the purposes of
> + authentication or access control.
>
> and that's all we say on the matter. I took out the Servers MUST
> NOT line under session state.
I think this is a good compromise. It's not recommended at this point,
but there is no reason to disallow it if both sides can handle the
non-protocol part (i.e., storing and managing cookies). Thanks.
-Peff
^ permalink raw reply
* Re: Efficient cloning from svn (with multiple branches/tags subdirs)
From: B Smith-Mannschott @ 2009-10-15 17:29 UTC (permalink / raw)
To: Bruno Harbulot; +Cc: git, Eric Wong
In-Reply-To: <4AD75A93.9050106@manchester.ac.uk>
On Thu, Oct 15, 2009 at 19:23, Bruno Harbulot
<Bruno.Harbulot@manchester.ac.uk> wrote:
> Hello,
>
> Avery Pennarun wrote:
>>
>> On Wed, Oct 14, 2009 at 2:00 PM, Eric Wong <normalperson@yhbt.net> wrote:
>>>
>>> Avery Pennarun <apenwarr@gmail.com> wrote:
>>>>
>>>> I've been thinking about this myself for some time. One option that
>>>> might be "interesting" would be to just grab the *entire* svn tree
>>>> (from the root), and then use git-subtree[1] to slice and dice it into
>>>> branches using your local copy of git (which is fast and uses no
>>>> bandwidth) instead of during the svn fetch (which is slow and uses
>>>> lots of bandwidth). I think it would also simplify the git-svn code
>>>> quite a lot, at least for fetching, since there would always be a
>>>> global view of the tree and SVN things like "copy branch A to tag B"
>>>> would just be exactly that.
>>>
>>> This was actually the original use case of git svn back when I started.
>>>
>>> git svn clone SVNREPO_ROOT (without --stdlayout)
>>>
>>> It's still an option if you have the disk space for the working copies,
>>> but I had to create the branches/tags support since the working copies
>>> would be become prohibitively large. If git-subtree could be
>>> taught to work on a bare repo (git svn has a --no-checkout option)
>>> it might be an option, too.
>
> Thank you for your suggestions. Unfortunately, I'm not really familiar with
> git-subtree and how it could work with git-svn, sorry.
>
> I've tried another workaround: using svnsync to pull the repository only
> once, and only then using git-svn fetch, locally, so as to avoid too much
> network traffic (I don't mind too much if it loops locally). I was hoping to
> be able to change the URL of the repository to the original one afterwards,
> but it doesn't seem to work so easily, because of the commit IDs. I'm
> assuming not having the same will cause problems for further fetches (this
> time directly from the original SVN repository) and for potential dcommits.
>
> When I do this:
> git init
> git svn init -s --prefix=svn/ file:///path/to/local/restlet-svnroot
> git svn fetch -r 1:2
>
> I get this ID, for example:
> r2 = c69a0b98d288a6e4e8779b50962b7fc65c4622e8
>
> If I do this using the original http://restlet.tigris.org/svn/restlet, I get
> this:
> r2 = ce3b82915e92fe1ccf6ddedacd9d74b30bd4de86
>
>
> I've even tried to install a Apache-based subversion server locally and make
> it believe it was restlet.tigris.org (by editing /etc/hosts and creating the
> appropriate VirtualHost), but this generates another SHA1 ID. (That's of
> course not a solution that would be generalisable.)
>
> I've had a quick look at the git-svn code to see how this ID was generated,
> but couldn't find anything obvious.
> I realise this isn't the cleanest approach possible, but any suggestion
> would be appreciated.
When I 'git svn clone' from a svnsync mirror I pass
--use-svnsync-props. Have you tried that?
// Ben
^ permalink raw reply
* Re: Efficient cloning from svn (with multiple branches/tags subdirs)
From: Bruno Harbulot @ 2009-10-15 17:23 UTC (permalink / raw)
To: git; +Cc: Eric Wong
In-Reply-To: <32541b130910141126u4df7f439i3d2926c2e1db9497@mail.gmail.com>
Hello,
Avery Pennarun wrote:
> On Wed, Oct 14, 2009 at 2:00 PM, Eric Wong <normalperson@yhbt.net> wrote:
>> Avery Pennarun <apenwarr@gmail.com> wrote:
>>> I've been thinking about this myself for some time. One option that
>>> might be "interesting" would be to just grab the *entire* svn tree
>>> (from the root), and then use git-subtree[1] to slice and dice it into
>>> branches using your local copy of git (which is fast and uses no
>>> bandwidth) instead of during the svn fetch (which is slow and uses
>>> lots of bandwidth). I think it would also simplify the git-svn code
>>> quite a lot, at least for fetching, since there would always be a
>>> global view of the tree and SVN things like "copy branch A to tag B"
>>> would just be exactly that.
>> This was actually the original use case of git svn back when I started.
>>
>> git svn clone SVNREPO_ROOT (without --stdlayout)
>>
>> It's still an option if you have the disk space for the working copies,
>> but I had to create the branches/tags support since the working copies
>> would be become prohibitively large. If git-subtree could be
>> taught to work on a bare repo (git svn has a --no-checkout option)
>> it might be an option, too.
Thank you for your suggestions. Unfortunately, I'm not really familiar
with git-subtree and how it could work with git-svn, sorry.
I've tried another workaround: using svnsync to pull the repository only
once, and only then using git-svn fetch, locally, so as to avoid too
much network traffic (I don't mind too much if it loops locally). I was
hoping to be able to change the URL of the repository to the original
one afterwards, but it doesn't seem to work so easily, because of the
commit IDs. I'm assuming not having the same will cause problems for
further fetches (this time directly from the original SVN repository)
and for potential dcommits.
When I do this:
git init
git svn init -s --prefix=svn/ file:///path/to/local/restlet-svnroot
git svn fetch -r 1:2
I get this ID, for example:
r2 = c69a0b98d288a6e4e8779b50962b7fc65c4622e8
If I do this using the original http://restlet.tigris.org/svn/restlet, I
get this:
r2 = ce3b82915e92fe1ccf6ddedacd9d74b30bd4de86
I've even tried to install a Apache-based subversion server locally and
make it believe it was restlet.tigris.org (by editing /etc/hosts and
creating the appropriate VirtualHost), but this generates another SHA1
ID. (That's of course not a solution that would be generalisable.)
I've had a quick look at the git-svn code to see how this ID was
generated, but couldn't find anything obvious.
I realise this isn't the cleanest approach possible, but any suggestion
would be appreciated.
Best wishes,
Bruno.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox