►
From YouTube: Using Strace to Understand GitLab - Part 2: Git
Description
Walkthrough on using Strace to understand how Git interacts with the filesystem.
0:00 Intro
1:00 Tracing 'git status'
10:20 Tracing 'git commit'
Part 1: https://www.youtube.com/watch?v=fcY5pPUq35U
Part 3: https://www.youtube.com/watch?v=J-GkU7Mmqy4
Part 4: https://www.youtube.com/watch?v=dgJH4wpR5OE
A
Hi,
everyone
welcome
to
episode
two
of
our
s
tracing
tutorial.
So
in
this
episode
we'll
go
through
s
tracing
a
couple
different
get
commands
just
to
see
some
more
c
programs
in
action
and
understand
a
little
bit
better.
How
git
works
under
the
hood
all
right,
so
let's
go
ahead
and
get
started.
A
A
Take
a
look
at
okay,
so,
like
last
time
we
can
see
we
exec
ve
this
time,
it's
kit
status
and
you
can
see
the
actual
binder
executed
is
user
local
bit
git.
A
Then
we
check
what
our
heap
is
using
brk.
We
once
again
access
ldso
to
preload,
and
then
we
start
opening
up
our
shared
library.
So
in
this
case
we're
going
to
lib
z
for
compression
and
if
we
look
at
what
libraries
are
just
able
to
get,
we've
got
the
z
liberty,
the
pthread
and
lib
c,
along
with
ld
linux
and
linux,
vdso
associated
shared
libraries,
okay,
so
we've
went
over
the
process
of
opening
a
shared
library
last
time,
so
we'll
just
skip
by
all
these
here.
A
The
p
thread
anything
else
we're
loading.
Let's
see
there.
Okay,
we
protect
our
memory,
start
setting
our
seek
actions
a
couple
of
times
all
right.
We
open
a
dev
null
for
some
reason
and
then
immediately
close
it
allocated
more
memory
to
the
heap.
We
start
checking
out
locale.
Now
we
saw
this
last
time
so
we'll
skip
by
locale
as
well.
Okay,
all
right!
A
So
now
we
are
trying
to
check
for
a
git
config
file,
so
you
can
see
we're
actually
going
to
a
number
of
different
places,
so
we
go
to
use
your
local
etsy,
git
config
and
that
doesn't
exist
user
or
myom
directory.config
that
get
config
that
doesn't
exist.
I
do
have
a
git
config
file,
though
so
it
confirms
adds
this.
Then
it
opens
that
and
then
it
stats
it
twice
for
some
reason
and
then
reads
it
in
so
there's
my
email
and
name
and
then
it
reaches
end
of
file
and
closes
it
out.
A
Then
it
gets
its
current
working
directory
with
get
cwd,
which
is
the
example
git
repo
it
stats
it
stats.getdirectory.
A
Then
it
tries
to
open
up
the
head
file
and
succeeds
reads
that
our
current
branch
is
master
closes
that
out
checks.
If
there's
a
commander
checks,
if
there's
an
object,
yep
that
exists,
ref
success,
it
opens
up
the
project.
A
Config
reads
that
in
that's
just
the
default
git
config
for
a
new
project
closes
that
up.
Okay,
then
it
starts
the
kit
directory
checks.
If
the
common
directory
exists,
it
does
not
looks
for
the
user.
Local
etsy,
git
config,
again
still
doesn't
exist,
looks
for
my.
My
home,
directory.config
getconfig
still
doesn't
exist,
finds
my
config
opens
it
again,
stats
it
twice
again.
Reads
it
again,
a
little
bit
of
duplication
here,
for
whatever
reason
we're
doing
it
again:
okay,
third
time's,
the
charm-
I
guess
okay,
so
we're
done
with
that.
A
We
get
a
working
directory
and
then
we
change
to
the
directory,
we're
already
in
all
right.
We
once
again
check
for
common
directory
there's
a
fair
amount
of
duplicated
work.
If
you
look
at
the
actual
timestamps,
though
we're
not
really
wasting
any
significant
amount
of
time,
we're
a
few
milliseconds
in
so
even
though
we've
done
the
same
thing
same
thing
three
times
in
a
row
for
some
reason,
we
have
not
actually
wasted
the
user's
time,
so
that's
something
anyway.
A
Okay,
we've
read
our
get
config,
for
I
think
the
fourth
time
at
that
point
all
right.
So
here's
where
we
start
getting
interesting.
So
here
we
are
locking
the
recheck
for
the
index
it
does
exist.
Then
we
read
it
in
the
map.
The
index
close
it,
oh
actually
not
quite
the
interesting
part.
Yet,
okay,
a
little
bit
more
locale,
we
set
a
timer.
A
And
then
here
we
know
we're
not
here
here
we
are
okay
and
then
here
we
create
index.lock,
and
so
this
this
o
exclusive
flag
here,
which
you
can
see
on
the
man
page
here
on
the
right,
well,
basically
says
that
if
this
file
already
exists,
then
where
the
open
a
command
will
fire
out.
So
this
way
we
can
be
sure
that
no
other
applications
have
or
git
processes
have
a
lock
on
this
repo.
A
A
We
get
our
process
so
get
pid
and
you
can
see
that
the
values
returned
is
the
actually
the
process
the
s3
says
well,
in
this
case,
okay,
we
check
for
head
re-open
head
or
read
head,
which
is
still
master
after
last
time
as
well.
Okay,
let
me
find
rest
heads
master,
there's
the
current
reference
for
that
we
check
for
there
any
pack,
reps
they're,
not
or
check
for
tags
and
check
for
any
other
heads.
None
of
these
files
are
just.
A
A
And
okay,
we're
checking
for
what
files
are
in
the
get
get
references
directory.
So
we
get
four
entries
back
from
that.
Let
me
check
for
what's
in
there
stack
those
files.
A
A
We
look
for
a
pac
file.
Looks
like
this
does
exist,
yep,
okay,
there
I'm
sorry!
This
is
a
directory,
but
it's
empty.
There's
nothing
in
there.
Okay,.
A
A
A
I
think
we're
almost
done.
Okay,
then
we
open
up
the
current
directory.
We
check
for
what
entries
are
within
that
we
look
for
other
common
files,
all
right.
So
at
this
point
we've
completed
searching
through
the
repo,
so
we
can
close
our
index.lock
and
then
use
unlink
to
delete
it
so
that
file
has
been
removed.
It's
no
longer
there,
so
we've
signaled
to
any
other
git
processes
that
might
be
in
here
that
they
are
free
to
go
ahead
and
modify
the
index.
A
So
we
have
one
file,
that's
not
changed
and
here's
all
the
text
that
we
saw-
and
you
can
see
here-
it's
just
the
ascii
color
code
that
we
see
in
the
terminal
itself,
okay
and
then
once
we've
done,
writing
it
out
we
exit
with
zero,
because
it's
successful
all
right.
So
that
is
what
get
status
does
so
you
can
see
that
kit
is
a
little
bit
duplicative,
not
in
a
way
that
is
like
important.
You
know
it's.
That
was
all
those
were
all
very
cheap
actions.
A
That's
not
a
big
deal
that
get
kept
reading
the
same
files
over
and
over
again
a
little
odd,
but
I'm
sure
there's
a
good
reason
for
it
that
I
don't
understand.
Okay.
So,
let's
now
we've
done
that
let's
go
ahead
and
commit
the.
B
A
A
A
So
the
current
path
is
here
and
here's
some
new
path,
so
we're
creating
the
actual
name
of
the
file
as
opposed
to
this
temporary
name
previously.
So
this
is
the
final
name
of
the
file,
one
with
the
hash
and
so
forth.
Now
that
we've
created
the
hard
link,
we
can
unlink
or
delete
the
original
temp
file,
and
we
just
have
that.
You
know
this
actual
get
object.
File
is
now
the
only
thing
left.
A
Okay,
we
seek
back
to
the
beginning
of
the
index
lock
file,
so
lseq
just
takes
your
your
position
within
a
file
to
an
arbitrary
location,
so
in
this
case
we're
seeking
the
zero
so
the
beginning
of
the
file.
So
if
we
wanted
to
go
back
to
the
beginning
of
it
and
read
okay
yeah
here
we
are
here,
we
actually
write
out
to
the
lock
file.
Something
compressed
looks
like
directory
tree,
but
I
don't
entirely
know
what's
being
written
there.
Okay,
we've
done
that.
A
We
close
that
and
then
here
we
can
rename
index.lock
to
the
new
index
file.
So
we
replace
the
index.
A
So,
as
you
recall,
and
when
we
did
the
git
status,
we
created
index.lock,
but
because
we
didn't
actually
change
the
index
at
all.
We
just
deleted
the
index
log
file.
In
this
case
we've
created
a
new
index.lock
and
then
by
using
rename
this
atomically
we'll
we'll
do
the
change.
So
you
don't
have
a
concern.
If
someone
else
changing
it
up
for
under
you,
you
don't
have
any
race
conditions.
So
this
way
we
can
make
sure
that
the
the
new
index
is
definitely
the
one
that
we
just
wrote.
A
Okay
and
then
we
see
if
there
are
any
git
hooks
in
this
case
we
haven't
created
any
so
that
just
we
continue
on.
We
check
the
time
get
our
time
zone
see
if
there
are
any
pre-commit
hooks
there
or
not.
A
We
see
if
there's
a
commit
edit
message
file.
There
is
not
we
just
passed
in
our
argument
from
the
command
line.
A
A
We
didn't
pass
yeah.
I
guess
that
already
existed
interesting,
okay,
unless
it
was
yeah
okay.
Here
we
are
here's
where
we
created
it
all
right,
so
we
created
a
commit
edit
message
over
there
all
right
here
we
open
that
file.
Up
again,
we
write
in
the
message
that
we
put
from
the
terminal
close
that
out.
A
A
B
A
A
So
yeah
git
cap
valve,
we
can
see
what
the
actual
contents
of
this
are,
although
when
we
look
in
the
s
trace,
this
is
all
been
z,
libbed
into
binary
format.
So
it's
not
even.
A
So
now
we
see
if
our
commit
object,
exists,
read
it
or
create
the
temp
file,
just
like
we
saw
with
the
blob
earlier
that
fails,
because
this
for
two
directory
doesn't
exist,
so
we
make
the
4-2
directory.
Then
we
try
creating
it
again
success.
A
A
A
Let's
see
have
we
already
written
the
head,
I
just
missed
that
somewhere
in
everybody
in
the
head.
Oh
yeah,
here
we
know
that's
her
reading
to
it.
A
Okay,
okay
and
then
okay,
now,
let's
rename
the
master
block
master.
Like
I
mentioned
earlier
that
works
atomically,
we
unlink
all
the
well.
If
these
files
had
existed
for
the
for
this
action,
we
don't
link
them.
So
we
just
do
that
to
be
safe.
A
A
If
you
see
a
clone
underscore
thread,
then
you
know
it's
a
thread.
Otherwise
it's
a
child.
It's
the
easy
way
to
tell
with
these
okay.
So
here
we
create
the
child,
and
then
you
can
see
that
immediately.
This
I
mentioned
earlier
that
we
start
doing
a
ton
of
rtc
actions
with
this
child
process.
We're
just,
I
think,
we're
just
inheriting
the
single
handlers
about
the
parent
process,
so
we
go
in
and
set
all
those
right
at
the
start.
A
A
Yeah
okay,
so
if
you
actually
look
at
this
file,
it's.
A
A
Okay,
so
we
call
git
gc.
A
A
It's
like
the
parent
directory,
okay,
yeah,
so
the
parent
process
you
can
see
we
didn't
actually
have
any
events
from
them
up
until
the
child
process
exits
and
that's
common
you'll,
also
see
it
where
the
parent
continues
to
work
and
is
not
waiting
on
the
child.
But
in
this
case
it
is
so
two
to
three
two
six
is
is
just
sitting
there
waiting
for
the
g
g
to
finish.
A
In
this
case,
I
don't
think
gc
really
has
anything
to
do
because
there's
do
we
even
have
like
a
pac
file.
Yet
no,
I
don't
think
we
do
yeah
and
there's
barely
any
objects,
so
there's
nothing
to
gc
at
this
point,
so
the
git
gc
exits
basically
immediately
having
done
almost
no
work
with
success,
and
then
here
we
can
see
that
it
was
waiting.
So
if
we
look
at
the
previous
event
for
22326.
A
A
It
looks
for
head,
it
opens
head,
it
reads:
it
closes.
It
reads,
master
again
having
just
written
to
that
a
minute
ago.
A
A
Tries
to
open
this
but
doesn't
exist,
I
guess
there's
nothing
dust
and
then
exit
was
here,
and
so
that
is
what
a
git
commit
looks
like,
and
I
get
to
see
it
doesn't
do
anything
okay,
great
well,
thanks
for
watching
next
time,
we'll
get
into
s,
tracing
unicorn
and
puma,
and
looking
at
what
you
know,
the
gitlab
rails.
Application
is
doing
when
the
typical
request
comes
in
all
right.
Thanks.