git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
        ;;
esac
if 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
fi

git 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
Previous: Pierre HabouzitNext: Linus Torvalds
Message 9 of 11 in “Consolidate SHA1 object file close”
  1. Linus TorvaldsJun 11, 2008
  2. Andreas EricssonJun 11, 2008
  3. Pierre HabouzitJun 11, 2008
  4. Linus TorvaldsJun 11, 2008
  5. Pierre HabouzitJun 11, 2008
  6. Linus TorvaldsJun 11, 2008
  7. Linus TorvaldsJun 11, 2008
  8. Pierre HabouzitJun 11, 2008
  9. Pierre HabouzitJun 11, 2008
  10. Linus TorvaldsJun 12, 2008
  11. Pierre HabouzitJun 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.