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

how to produce an index with smudged entries

From
Christian Halstrick <christian.halstrick@gmail.com>
Date
Sep 30, 2011, 15:33 UTC
Message-ID
<CAENte7h-sbv7VTBdV7A+=TtONTpgOBBfVWz2Nejm1DqJJ9tFiQ@mail.gmail.com>

I am trying to find out how native git handles the racy git problem. I read https://raw.github.com/git/git/master/Documentation/technical/racy-git.txt. But I cannot reproduce the behaviour described in this text.

I want to create an index which contains entries where the length of the file was set to 0 to mark the entry as "racily clean". As I understood the text you have to modify a file and execute 'git update-index <file>' so fast that in the end the files modification time is the same as the modification time of the file .git/index. That should be sufficient that when persisting the index during the 'git update-index' call git should detect that the files mod-time is younger than the index mod time and should mark this entry "racily clean" with a length of 0.

Here is the script with which I try to produce it but it always fails to create an index with a smudged entry. Any ideas? (Btw: I would assume that the first entry in the index is smduged when I find 4 zeros beginning at position 48. That's what I deduced from https://github.com/gitster/git/blob/master/Documentation/technical/index-format.txt)

#!/bin/bash

git init echo "initial" > foo

# wait for the next tick on the filesystem clock
touch foo
lastTouch=$(stat -c %Y foo)
while [ $lastTouch = $(stat -c %Y foo) ] ;do
  touch foo
done
git add foo
# modify 'foo' and update the index
# (hopefully before the filesystem clock has increased)
# repeat this step until the filesystem timer increased and
# print the index everytime
lastTouch=$(stat -c %Y foo)
while [ $lastTouch = $(stat -c %Y foo) ] ;do
  echo "modification #$n" > foo
  git update-index foo
  let "n += 1"
  echo "after attempt $n:"
  # dump 4 bytes of index beginning from pos 48.
  # That should be the length of the first entry
  od -j 48 -N 4 -x -A d .git/index
done
Next: Robin Rosenberg
Message 1 of 2 in “how to produce an index with smudged entries”
  1. Christian HalstrickSep 30, 2011
  2. Robin RosenbergOct 2, 2011

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.