git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* On the behavior of checkout <branch> with uncommitted local changes
@ 2013-09-19  9:23 r.ductor
  2013-09-19 17:43 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: r.ductor @ 2013-09-19  9:23 UTC (permalink / raw)
  To: git

Dear all

I'm not a power git user but I profit of git every day and I like to fully understand what I do.

The man section for git checkout is too vague for my taste. In particular it is not clearly (unambiguously) stated what happens to index and worktree whenever local uncommitted changes are around. I've already rised a similar problem in this mail list [1], but I understand that a man page must be concise.

On the other hand, I couldn't find any complete information on this behavior: tutorials and books seem to avoid the problem, user posts seems confused ... 

To grasp some more information,  I've spent some hours in trials (sorry I'm unable to grasp information browsing the code repository). That resulted in the algorithm below presented.

Could anybody authoritative on that subject confirm/correct/discharge my statement? That could be of help for me and may others.

Nonetheless to say having this kind of pseudocodes available somewhere (e.g. for stash [2] and other tools modifing index and working tree) would make my git experience  (and that of many more people) happier.

Thanks to all developers for their efforts.

Regards
ric


Notations: let us fix a file and denote
C0  = its version in the initial commit
I0   = its version in the initial index
W0 = its version in the working tree
C1 = its version in the target commit
W1= its version in working tree after checkout completed
I1  = its version in index after checkout completed


git checkout Branch

if C0=W0=I0,          then: W1=I1=C1;
if C1=I0,                 then: W1=W0 and I1=C1=I0;
if C1=C0,                then: W1=W0 and I1=I0;
otherwise: abort


Note: in particular, if W0=I0 !=C0 then (in general) abort

Note: in particular, if C0=I0 and C1=W0 then abort  (...actually why that? no information is lost)


REFS
[1]http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/782914/focus=164647
[2]http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=717088

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-24  9:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-19  9:23 On the behavior of checkout <branch> with uncommitted local changes r.ductor
2013-09-19 17:43 ` Junio C Hamano
2013-09-20 13:33   ` r.ductor
2013-09-20 22:58     ` Junio C Hamano
2013-09-24  9:25       ` r.ductor

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).