git-checkout sometimes silently fails
I've had this happen before and I don't know what to do to make it stop. Usually sufficient fiddling will prevent it from happening.
y:/usr/src/git26> cat .git/branches/linux-next git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git
y:/usr/src/git26> git-checkout master
Switched to branch "master"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git-checkout origin
Note: moving to "origin" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at 5717922... Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git --version
git version 1.5.5.rc1
help?
Andrew Morton, Tue, May 06, 2008 21:22:56 +0200:
Quoted 8 lines
I've had this happen before and I don't know what to do to make it stop. Usually sufficient fiddling will prevent it from happening.
y:/usr/src/git26> cat .git/branches/linux-next git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git
Quoted 8 lines
y:/usr/src/git26> git-checkout master
Switched to branch "master"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
This is not a good indication of a failed checkout (they could point to the same commit, for one). Try "gitk master...linux-next" (or "git log master..linux-next", "git diff master linux-next")
Quoted 6 lines
y:/usr/src/git26> git-checkout origin
Note: moving to "origin" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at 5717922... Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
This is not an error. The commit was checked out (and HEAD was "detached").
Quoted 2 lines
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
Again, it is no indication nothing happened. "gitk HEAD...linux-next"
Quoted 4 lines
y:/usr/src/git26> git --version
git version 1.5.5.rc1help?
Look at "git branch -av" (it shows both local and remote branches and commits they point to). Maybe it will give you a hint. "gitk --all" is interesting too, seldom though (it becomes very confusing very fast if you have many branches with complicated history each).
Quoted 18 lines · On Tue, 6 May 2008 23:50:49 +0200 Alex Riesen <[email protected]> wrote:
Andrew Morton, Tue, May 06, 2008 21:22:56 +0200:
Quoted 8 lines
I've had this happen before and I don't know what to do to make it stop. Usually sufficient fiddling will prevent it from happening.
y:/usr/src/git26> cat .git/branches/linux-next git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git
Quoted 8 lines
y:/usr/src/git26> git-checkout master
Switched to branch "master"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
Quoted 2 lines
This is not a good indication of a failed checkout (they could point to the same commit, for one).
How could they? linux-next includes a directory called ./Next and a file in that directory called ./Next/Trees, and that is not present after the `git-checkout linux-next'.
Quoted 2 lines
Try "gitk master...linux-next" (or "git
log master..linux-next", "git diff master linux-next")
These come up empty. But there is a 12.4MB diff between mainline and linux-next.
Quoted 15 lines
Quoted 6 lines
y:/usr/src/git26> git-checkout origin
Note: moving to "origin" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at 5717922... Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdbThis is not an error. The commit was checked out (and HEAD was "detached").
Quoted 2 lines
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057Again, it is no indication nothing happened. "gitk HEAD...linux-next"
Quoted 7 lines
Quoted 4 lines
y:/usr/src/git26> git --version
git version 1.5.5.rc1help?
Look at "git branch -av" (it shows both local and remote branches and commits they point to).
y:/usr/src/git26> git-branch -av | grep '^\*'
* master 5717922 Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> git-branch -av | grep '^\*'
* linux-next 5717922 Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
y:/usr/src/git26> ls -l Next
ls: cannot access Next: No such file or directory
Quoted 3 lines
Maybe it will give you a hint. "gitk --all" is
interesting too, seldom though (it becomes very confusing very fast if you have many branches with complicated history each).
hm, lots of stuff there.
Thing is, sometimes `git-checkout linux-next' works. Sometimes it inexplicably doesn't work and there is no indication from git that it didn't work.
Usually my git problems are root-caused down to my lack of a PhD in hermeneutic metaphysiology, but not this time, methinks
Quoted 9 lines · Andrew Morton
Quoted 9 lines
Quoted 8 lines
y:/usr/src/git26> git-checkout master
Switched to branch "master"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
Quoted 6 lines
Quoted 2 lines
This is not a good indication of a failed checkout (they could point to the same commit, for one).
How could they? linux-next includes a directory called ./Next and a file in that directory called ./Next/Trees, and that is not present after the `git-checkout linux-next'.
But you don't show us that in your example. There is nothing in your example to indicate that they are not simply pointing at the same commit...
Quoted 5 lines
Quoted 2 lines
Try "gitk master...linux-next" (or "git
log master..linux-next", "git diff master linux-next")These come up empty. But there is a 12.4MB diff between mainline and linux-next.
And if these all come up empty, then they _are_ pointing to the same commit. When you say "but there is a 12.4MB diff..." do you mean "there _should_ be such a diff?" In that case, it seems that your linux-next ref is pointing to an unexpected commit.
So the problem is not with git-checkout, but rather that you are not checking out what you think you are checking out. And so we need to figure out how you got into that state.
What command did you use to create the linux-next branch? Have you used git-reset to move the branch tip around?
-Peff
Quoted 28 lines · On Tue, 6 May 2008 20:19:19 -0400 Jeff King <[email protected]> wrote:
Quoted 9 lines · Andrew Morton
Quoted 9 lines
Quoted 8 lines
y:/usr/src/git26> git-checkout master
Switched to branch "master"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057Quoted 6 lines
Quoted 2 lines
This is not a good indication of a failed checkout (they could point to the same commit, for one).
How could they? linux-next includes a directory called ./Next and a file in that directory called ./Next/Trees, and that is not present after the `git-checkout linux-next'.
But you don't show us that in your example. There is nothing in your example to indicate that they are not simply pointing at the same commit...
Quoted 5 lines
Quoted 2 lines
Try "gitk master...linux-next" (or "git
log master..linux-next", "git diff master linux-next")These come up empty. But there is a 12.4MB diff between mainline and linux-next.
Quoted 7 lines
And if these all come up empty, then they _are_ pointing to the same commit. When you say "but there is a 12.4MB diff..." do you mean "there _should_ be such a diff?" In that case, it seems that your linux-next ref is pointing to an unexpected commit.
So the problem is not with git-checkout, but rather that you are not checking out what you think you are checking out.
That sounds a decent theory.
Quoted 2 lines
And so we need to
figure out how you got into that state.
Well it happens pretty regularly. I have now lost that state but I'll save it next time. I'm not able to pinpoint exactly what causes it to occur.
Quoted 1 line
What command did you use to create the linux-next branch?
I edited
y:/usr/src/git26> cat .git/branches/linux-next git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git
and did git-fetch once per day, approx.
Quoted 2 lines
Have you used
git-reset to move the branch tip around?
My git-fetching script does that:
doit()
{
tree=$1
upstream=$2
cd $GIT_TREE
git reset --hard "$upstream"
git fetch "$tree" || exit 1
git merge --no-commit 'test merge' HEAD FETCH_HEAD > /dev/null
{
git_header "$tree"
git log --no-merges ORIG_HEAD..FETCH_HEAD
git diff --patch-with-stat ORIG_HEAD
} >$PULL/$tree.patch
{
echo DESC
echo $tree.patch
echo EDESC
git_header "$tree"
git log --no-merges ORIG_HEAD..FETCH_HEAD
} >$PULL/$tree.txt
git reset --hard "$upstream"
}(Linus suggested an updated version of this but afaict that won't change anything)
But, as I say, usually this script leaves the tree in a sane state. But sometimes it leaves it in a i-cant-check-stuff-out state. It's not specific to linux-next, either: I've seen this for a long time, on and off. Prior to linux-next's existence.
Quoted 85 lines · Andrew Morton
Quoted 28 lines · On Tue, 6 May 2008 20:19:19 -0400 Jeff King <[email protected]> wrote:
Quoted 9 lines · Andrew Morton
Quoted 9 lines
Quoted 8 lines
y:/usr/src/git26> git-checkout master
Switched to branch "master"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> cat kernel/*.c|sum
34439 2057Quoted 6 lines
Quoted 2 lines
This is not a good indication of a failed checkout (they could point to the same commit, for one).
How could they? linux-next includes a directory called ./Next and a file in that directory called ./Next/Trees, and that is not present after the `git-checkout linux-next'.
But you don't show us that in your example. There is nothing in your example to indicate that they are not simply pointing at the same commit...
Quoted 5 lines
Quoted 2 lines
Try "gitk master...linux-next" (or "git
log master..linux-next", "git diff master linux-next")These come up empty. But there is a 12.4MB diff between mainline and linux-next.
Quoted 7 lines
And if these all come up empty, then they _are_ pointing to the same commit. When you say "but there is a 12.4MB diff..." do you mean "there _should_ be such a diff?" In that case, it seems that your linux-next ref is pointing to an unexpected commit.
So the problem is not with git-checkout, but rather that you are not checking out what you think you are checking out.
That sounds a decent theory.
Quoted 2 lines
And so we need to
figure out how you got into that state.Well it happens pretty regularly. I have now lost that state but I'll save it next time. I'm not able to pinpoint exactly what causes it to occur.
Quoted 1 line
What command did you use to create the linux-next branch?
I edited
y:/usr/src/git26> cat .git/branches/linux-next git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sfr/linux-next.git
and did git-fetch once per day, approx.
Quoted 2 lines
Have you used
git-reset to move the branch tip around?My git-fetching script does that:
doit(){ tree=$1 upstream=$2 cd $GIT_TREE git reset --hard "$upstream" git fetch "$tree" || exit 1 git merge --no-commit 'test merge' HEAD FETCH_HEAD > /dev/null { git_header "$tree" git log --no-merges ORIG_HEAD..FETCH_HEAD git diff --patch-with-stat ORIG_HEAD } >$PULL/$tree.patch { echo DESC echo $tree.patch echo EDESC git_header "$tree" git log --no-merges ORIG_HEAD..FETCH_HEAD } >$PULL/$tree.txt git reset --hard "$upstream" }
Quoted 7 lines
(Linus suggested an updated version of this but afaict that won't change anything)
But, as I say, usually this script leaves the tree in a sane state. But sometimes it leaves it in a i-cant-check-stuff-out state. It's not specific to linux-next, either: I've seen this for a long time, on and off. Prior to linux-next's existence.
Hm, that very much looks like it would mess things up whenever you're not on the upstream branch already.
While this should do no harm:
git checkout master
doit linux-next master
This will make your linux-next branch point to the same commit as master:
git checkout linux-next
doit linux-next master
Adding a '"git checkout "$upstream"' (maybe with -f?) before the first reset --hard should avoid that then.
Björn
Quoted 6 lines · Andrew Morton
y:/usr/src/git26> git-branch -av | grep '^\*'
* master 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> git-branch -av | grep '^\*'
* linux-next 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
You did not show us the output of 'git branch -av'. Do you happen to see something like this in the output:
* master 5717922 Merge branch 'for_linus' linux-next 5717922 Merge branch 'for_linus' linux-next/HEAD 1234567 Something completely different linux-next/master 1234567 Something completely different
In this case, your local branch 'linux-next' is probably a left-over from earlier experiments. The last two branches are actually what you want to refer to. Normally, the 'linux-next/HEAD' part allows you to refer to 'linux-next/master' by saying simply 'linux-next'. But unfortunately, your local branch name 'linux-next' takes precedence.
'git fetch' never updates your local branch, but only 'linux-next/master' (and its alias 'linux-next/HEAD' aka 'linux-next').
To return to a sane state, do 'git branch -D linux-next'.
-- Hannes
Quoted 6 lines · Andrew Morton
y:/usr/src/git26> git-branch -av | grep '^\*'
* master 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> git-branch -av | grep '^\*'
* linux-next 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
So your two local branches 'master' and 'linux-next' both point at the same commit, 5717922.
"git checkout <branchname>" is to check out the local branch name. You expect "git checkout master" and then "git checkout linux-next" to check out two different commits because linux-next _should_ have been updated to the latest from sfr repository. But it appears to me that that is not the case.
Perhaps "git fetch linux-next" hasn't been run, before "git checkout" was attempted?
Quoted 9 lines · On Tue, 06 May 2008 17:19:01 -0700 Junio C Hamano <[email protected]> wrote:
Quoted 6 lines · Andrew Morton
y:/usr/src/git26> git-branch -av | grep '^\*'
* master 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> git-branch -av | grep '^\*'
* linux-next 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
Quoted 8 lines
So your two local branches 'master' and 'linux-next' both point at the same commit, 5717922.
"git checkout <branchname>" is to check out the local branch name. You expect "git checkout master" and then "git checkout linux-next" to check out two different commits because linux-next _should_ have been updated to the latest from sfr repository. But it appears to me that that is not the case.
I did a git-fetch of linux-next yesterday.
Quoted 2 lines
Perhaps "git fetch linux-next" hasn't been run, before "git checkout" was attempted?
I reran git-fetch linux-next' and that downlaoded a heap of stuff (perhaps necause linux-next rebases every time?) and after this, git-checkout linux-next' gives me what I expect.
But how come I couldn't check out yesterday's linux-next?
Quoted 12 lines · Junio C Hamano
Quoted 6 lines · Andrew Morton
y:/usr/src/git26> git-branch -av | grep '^\*'
* master 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb
y:/usr/src/git26> git-checkout linux-next
Switched to branch "linux-next"
y:/usr/src/git26> git-branch -av | grep '^\*'
* linux-next 5717922 Merge branch 'for_linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdbSo your two local branches 'master' and 'linux-next' both point at the same commit, 5717922.
Quoted 8 lines
"git checkout <branchname>" is to check out the local branch name. You expect "git checkout master" and then "git checkout linux-next" to check out two different commits because linux-next _should_ have been updated to the latest from sfr repository. But it appears to me that that is not the case.
Perhaps "git fetch linux-next" hasn't been run, before "git checkout" was attempted?
Might also be worth checking whether there happens to be a tag (or something else?) named the same as one of the branches? I remember the public -mm git repo, for example, having a tag named "master". Yuch.
Grepping through git-for-each-ref output might shed some light.
--b.