thanks for such a quick response!

weird.

here's what i get

$ git init a
Initialized empty Git repository in /home/ozzloy/delete-me/a/.git/
$ cd a
$ touch b
$ git add b

$ cp .git/index .git/index-after-stage-before-commit

$ git commit -m b
[master (root-commit) 3934d90] b
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 b

$ sha1sum .git/index-after-stage-before-commit
39df9ab5029deb5a4bc7e74c86e294b362521001
.git/index-after-stage-before-commit
$ sha1sum .git/index
39df9ab5029deb5a4bc7e74c86e294b362521001 .git/index
$ git --version
git version 2.1.4

so i tried again

$ git init a
$ cd a
$ touch b
$ git add b
$ git ls-files --stage
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 b
$ git commit -m b
[master (root-commit) cdb2bce] b
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 b
$ git ls-files --stage
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 b


still the same for me. but since yours is different, i have to figure out
why.
what version of git do you have?  why else might it be different?




On Sat, Oct 24, 2015 at 5:51 PM John McKown <john.archie.mck...@gmail.com>
wrote:

>From what I have observed, the answer to your question is "Yes." However, a
"git add" also changes the index.


A transcript (on a Fedora 22 x86_64 system) which may help:



$mkdir temp
joarmc@mckown5 2015-10-24T19:44:47 ~/junk
$cd temp
joarmc@mckown5 2015-10-24T19:44:51 ~/junk/temp
$git init
Initialized empty Git repository in /home/joarmc/junk/temp/.git/
joarmc@mckown5 2015-10-24T19:45:00 ~/junk/temp
$echo "a" >x
joarmc@mckown5 2015-10-24T19:45:09 ~/junk/temp
$ls -l .git/index
ls: cannot access .git/index: No such file or directory
joarmc@mckown5 2015-10-24T19:45:15 ~/junk/temp
$git add x
joarmc@mckown5 2015-10-24T19:45:20 ~/junk/temp
$ls -l .git/index
-rw-rw-r--. 1 joarmc joarmc 96 Oct 24 19:45 .git/index
joarmc@mckown5 2015-10-24T19:45:22 ~/junk/temp
$sha1sum .git/index
530c44247e959d548d5013d8ebc83991ed3e7057 .git/index
joarmc@mckown5 2015-10-24T19:45:30 ~/junk/temp
$echo "b">>x
joarmc@mckown5 2015-10-24T19:45:37 ~/junk/temp
$git add x
joarmc@mckown5 2015-10-24T19:45:42 ~/junk/temp
$ls -l .git/index
-rw-rw-r--. 1 joarmc joarmc 96 Oct 24 19:45 .git/index
joarmc@mckown5 2015-10-24T19:45:49 ~/junk/temp
$sha1sum .git/index
96388bdb4c2180bf32cd141dc5df6c81a33e8aec .git/index
joarmc@mckown5 2015-10-24T19:45:58 ~/junk/temp
$git commit -m 'some comment'
[master (root-commit) 4b1dfae] some comment
1 file changed, 2 insertions(+)
create mode 100644 x
joarmc@mckown5 2015-10-24T19:46:05 ~/junk/temp
$ls -l .git/index
-rw-rw-r--. 1 joarmc joarmc 129 Oct 24 19:46 .git/index
joarmc@mckown5 2015-10-24T19:50:31 ~/junk/temp
$sha1sum .git/index
6e853ffa930651333200dc55c1610bb5ae26db25 .git/index
joarmc@mckown5 2015-10-24T19:46:08 ~/junk/temp




Note that .git/index changes after the "git add x" each time. It also
changes after the "git commit"







On Sat, Oct 24, 2015 at 7:29 PM, ozzloy <ozz...@gmail.com> wrote:


does `git commit` modify $GIT_DIR/index?
i just diffed index from before and after a commit and found no
difference. i'm guessing this is reliable behavior, but i wanted to
make sure. it seems like the idea of index is that it's always ready
and waiting to be turned into the next commit. so commits wouldn't ever
modify it.

i'm writing a script that depends on this behavior and i want to make
sure i have the concepts right.

i searched online but found mostly posts telling me higher level stuff,
like that "you have to add to the staging area before committing". i also
searched the archives for this mailing list, but there's a _lot_ to go
through. sorry if this is a repeat.





-- 
You received this message because you are subscribed to the Google Groups
"Git for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to git-users+unsubscr...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.





-- 


Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.



He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

-- 
You received this message because you are subscribed to a topic in the
Google Groups "Git for human beings" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/git-users/ZXUOO5QDGMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- 

written via phone. please forgive terseness and typeos

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to