Re: [RFC] Detached-HEAD reminder on commit?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> On Wed, Sep 03, 2008 at 12:49:43PM -0400, Daniel Barkalow wrote:
>
>> Good point. I think I confused myself with the new branch case. On the 
>> other hand, I think the "not starting a new branch" case should go as 
>> well. If you've got a detached HEAD, and you do:
>> 
>> $ git checkout -b foo origin/master
>> 
>> we probably ought to describe the old state. The reason that starting a 
>> new branch usually shouldn't give the message is that new->commit == 
>> old.commit (assuming that the defaults have gotten filled in by this 
>> point, which they should have).
>
> Right, I was thinking it was necessary for the starting a new branch
> case, but a better test is checking whether the commits are the same.
>
> So based on what you said and thinking a bit, I came up with:
>
>     if (!opts->quiet && !old.path && new->commit != old.commit)
>
> and then I had the brilliant idea of checking what git-checkout.sh did.
> And sure enough:
>
>     elif test -z "$oldbranch" && test "$new" != "$old"
>     then
>             describe_detached_head 'Previous HEAD position was' "$old"
>     fi
>
> Patch is below.

It was a good idea to keep the scripted ones in contrib/examples so that
they are readily accessible to find out what we used to do ;-).

Thanks.  Will apply to 'maint'.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux