Re: [PATCH v3] git checkout -b: unparent the new branch with -o

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

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

> Okay, fair enough.  From the point of view of plumbing, what is there
> left to do that
>
> 	git rm -f . &&
> 	git symbolic-ref HEAD refs/heads/new
>
> or
>
> 	git symbolic-ref HEAD refs/heads/new
>
> or
>
> 	git rm --cached . &&
> 	git symbolic-ref HEAD refs/heads/new
>
> does not take care of?

If we have the "just detach, don't touch index nor working tree", which
happens to be the cheapest one in the middle (except that it probably
wants to verify that "new" does not exist yet), the calling script of the
Porcelain suite can use it in conjunction with various forms of "git rm"
without incurring any additional overhead (other than a fork-and-exec),
and I think that would be sufficient.

You could add

	git ls-files |
        while read path
        do
        	case $(choose-keep-drop-nuke "$path") in
                keep) ;;
                drop) git rm --cached -f "$path" ;;
                nuke) git rm -f "$path" ;;
        	esac
	done
	git symbolic-ref HEAD refs/heads/new

and have the caller supply a callback that intelligently choose what to
keep and what to drop, if you want to be really fancy, but at that level
of complexity, I think it is something the Porcelain writer using the
plumbing would want to write himself as part of the Porcelain program.

We might want to add "git branch --switch <branchname>" that is roughly
like this:

    ref="refs/heads/$branch"
    git check-ref-format "$ref" || die "malformed"
    if git rev-parse -q --verify "$ref" >/dev/null
    then
    	# exists
        exec git checkout "$branch"
    else
	# create
	exec git symbolic-ref HEAD "$ref"
    fi
--
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]