Re: Consolidate SHA1 object file close
- From
Pierre Habouzit <madcoder@debian.org>
- Date
- Jun 11, 2008, 23:03 UTC
- Message-ID
- <20080611230355.GE16439@artemis.madism.org>
- In-Reply-To
- <20080611222534.GC16439@artemis.madism.org>
On Wed, Jun 11, 2008 at 10:25:34PM +0000, Pierre Habouzit wrote:
Show 11 quoted lines
> On Wed, Jun 11, 2008 at 05:34:53PM +0000, Linus Torvalds wrote: > > > > > > > > > Quite often, when people commit, they have corrupt repositories. The > > > > > symptom is a `cannot read <sha1>` error message (or many at times). > > > > Btw, do you have exact error messages? > > Well, like said I don't have had the problem myself, and it's hard to > reproduce, people have it like once a week average, for people that > perform around 50 to 100 commits a week.
I should say that the problem happens more often when people use the script I inlined in the end (this scripts does what git pull --rebase nowadays does, with a dirty workdir, roughly, I'm not its author, the goal isn't to discuss its lack of beauty or whatever, just to point out some possible things that leads to the NFS issue).
Next time something breaks, I'll be able to give you a log.
------------------------------------- #!/bin/bash
OPTIONS_SPEC= SUBDIRECTORY_OK=t . git-sh-setup require_work_tree
case $# in
0)
branch=origin/$(git symbolic-ref HEAD|sed -e 's!refs/heads/!!')
;;
1)
branch="$1"
;;
*)
echo 1>&2 "$(basename $0) [<branch>]"
exit 1
;;
esacif git rev-parse --verify HEAD > /dev/null &&
git update-index --refresh &&
git diff-files --quiet &&
git diff-index --cached --quiet HEAD --
then
NEED_TEMPO=
else
NEED_TEMPO=t
figit fetch test -z "$NEED_TEMPO" || git commit -a -s -m'tempo' git rebase "$branch"
if test -n "$NEED_TEMPO"; then
if test -d "$(dirname "$(git rev-parse --git-dir)")/.dotest"; then
echo ""
echo "run 'git reset HEAD~1' when rebase is finished"
else
git reset HEAD~1
fi
fi
-------------------------------------Also note that now people use an enhanced version of that script (the one in attachment). It still breaks, but less often. I'm not sure it's valuable information at all, but one never knows.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
#!/bin/sh
OPTIONS_SPEC="\
$(basename $0) [options] [<remote> [<branch>]]
--
k,gitk visualize unmerged differences
r,rebase perform a rebase
m,merge perform a merge
"
SUBDIRECTORY_OK=t
. git-sh-setup
require_work_tree
lbranch=$(git symbolic-ref HEAD | sed -e s~refs/heads/~~)
remote=$(git config --get "branch.$lbranch.remote" || echo origin)
branch=$(git config --get "branch.$lbranch.merge" || echo "refs/heads/$lbranch")
case "$(git config --bool --get madcoder.up-gitk)" in
true) gitk=gitk;;
*) gitk=:
esac
case "$(git config --bool --get "branch.$lbranch.rebase")" in
true) action=rebase;;
*) action=;;
esac
while test $# != 0; do
case "$1" in
-k|--gitk)
shift; gitk=gitk;;
--no-gitk)
shift; gitk=:;;
-r|--rebase)
shift; action=rebase;;
--no-rebase)
shift; rebase=${rebase#rebase};;
-m|--merge)
shift; action=merge;;
--no-merge)
shift; rebase=${rebase#merge};;
--)
shift; break;;
*)
usage;;
esac
done
case $# in
0) ;;
1) remote="$1";;
2) remote="$1"; branch="$2";;
*) usage;;
esac
git fetch "${remote}"
if test `git rev-list .."${remote}/${branch#refs/heads/}" -- | wc -l` = 0; then
echo "Current branch $lbranch is up to date."
exit 0
fi
$gitk .."${remote}/${branch#refs/heads/}" --
if test -z "$action"; then
echo -n "(r)ebase/(m)erge/(q)uit ? "
read ans
case "$ans" in
r*) action=rebase;;
m*) action=merge;;
*) exit 0;;
esac
fi
unclean=
git rev-parse --verify HEAD > /dev/null && \
git update-index --refresh && \
git diff-files --quiet && \
git diff-index --cached --quiet HEAD -- || unclean=t
case "$action" in
rebase)
test -z "$unclean" || git stash save "git-up stash"
git rebase "${remote}/${branch#refs/heads/}"
;;
merge)
test -z "$unclean" || git stash save "git-up stash"
git merge "${remote}/${branch#refs/heads/}"
;;
*)
echo 1>&2 "no action specified"
exit 1
;;
esac
if test -n "$unclean"; then
if test -d "$(git rev-parse --git-dir)/../.dotest"; then
echo ""
echo "run 'git stash apply' when rebase is finished"
else
git stash apply
fi
fi