Re: [PATCH] checkout -f: do not leave untracked working tree files.

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

 



Junio C Hamano <junkio@xxxxxxx> writes:

> Earlier we did not consider untracked working tree files
> "precious", but we have always considered them fair game to
> clobber.  These days, branch switching by read-tree is more
> careful and tries to protect untracked working tree files.  This
> caused the following workflow to stop working:
>
> 	git checkout one-branch-with-file-F
> 	git checkout -f another-without-file-F
> 	git pull . one-branch-with-file-F
>
> Because the second checkout leaves F from the previous state as
> untracked file in the working tree, the merge would fail, trying
> to protect F from being clobbered.
>
> This changes "git checkout -f" to remove working tree files that
> are known to git in the switched-from state but do not exist in
> the switched-to state, borrowing the same logic from "reset --hard".
>

I agree with this patch (without testing).

Another thing to take into account is that, for this particular
case/sequence, the untracked file-F is exactly the same as the one from
the pull, so you are not overwritting that file and it could succeed.

    Santi
-
: 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]