(copying in Konstantin)
----- Original Message -----
From: vvs
To: Git for human beings
Cc: [email protected] ; [email protected]
Sent: Saturday, April 22, 2017 3:18 PM
Subject: Re: [git-users] Undocumented reset behavior
On Saturday, April 22, 2017 at 4:50:41 PM UTC+3, Philip Oakley wrote:
If i understood the initial statement your have two different seqences of
commands and their interaction isn't as expected. but I couldn't decide what
the specific sequence were.
Would you ab able to show a short test case, even just use a comment to
indcate initial state, and then the different commands and what you see as
different.
Yes, you are right. Here is a simple test case:
mkdir test
cd test
git init
touch xxx
git add xxx
git commit -m xxx
touch yyy
git add yyy
git commit -m yyy
git reset HEAD^
git reset @{1}
git reset --hard
This is different because yyy will be touched:
git reset HEAD^
git reset --hard @{1}
I believe these two cases should be no different at all. Anyway, that's
what the docs say, at least as I understand it.
--
I tried it locally but didn't get what I think you expected. I am on git
version 2.9.0.windows.1.323.g0305acf (~the last which supports my harware).
What I have / see is
[first, I slightly beef up the test case and the investigation/status commands
second, I run the two sets, but don't see the time stamp issue,
which is commonly the issue with make files vs git
(one thinks time stamps are important the other doesn't)
:-
mkdir test
cd test
git init
touch xxx
git add xxx
git commit -m xxx
touch yyy
git add yyy
git commit -m yyy
git status
sleep 2
git reset HEAD^
# move the branch back one commit implies --mixed.
# Resets the index but not the working tree
# (i.e., the changed files are preserved but not marked for commit)
git status
git reflog
stat yyy
# Option A
git reset @{1}
# Resets the index to yyy but no change to the working tree
stat yyy
git reset --hard
# Resets the index and working tree. but the yyy file is already up to date.
stat yyy
# Option B
git reset --hard @{1}
# Resets the index and working tree.
# Any changes to tracked files in the working tree since <commit> are discarded.
# brand new yyy file (in the commit) - overwrite whatever was there.
stat yyy
# Noticed difference (by vvs009) is: 'make' detetcting a timestamp difference
(in yyy?) that was not expected. ?
==
A.
Philip@PhilipOakley MINGW32 /usr/src
$ cd test
Philip@PhilipOakley MINGW32 /usr/src/test
$ git init
Initialized empty Git repository in C:/git-sdk-32/usr/src/test/.git/
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ touch xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git add xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git commit -m xxx
[master (root-commit) 83a861e] xxx
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ touch yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git add yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git commit -m yyy
[master 0db613e] yyy
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git status
On branch master
nothing to commit, working tree clean
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ sleep 2
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git reset HEAD^
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # move the branch back one commit implies --mixed.
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Resets the index but not the working tree
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # (i.e., the changed files are preserved but not marked for commit)
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
yyy
nothing added to commit but untracked files present (use "git add" to track)
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git reflog
83a861e HEAD@{0}: reset: moving to HEAD^
0db613e HEAD@{1}: commit: yyy
83a861e HEAD@{2}: commit (initial): xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ stat yyy
File: 'yyy'
Size: 0 Blocks: 0 IO Block: 65536 regular empty file
Device: 94555d4eh/2488622414d Inode: 63331869760117686 Links: 1
Access: (0644/-rw-r--r--) Uid: (197613/ Philip) Gid: (197121/ UNKNOWN)
Access: 2017-04-22 16:43:47.562500000 +0100
Modify: 2017-04-22 16:43:47.562500000 +0100
Change: 2017-04-22 16:43:47.562500000 +0100
Birth: 2017-04-22 16:43:47.562500000 +0100
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Option A
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git reset @{1}
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Resets the index to xxx but no change to the working tree
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ stat yyy
File: 'yyy'
Size: 0 Blocks: 0 IO Block: 65536 regular empty file
Device: 94555d4eh/2488622414d Inode: 63331869760117686 Links: 1
Access: (0644/-rw-r--r--) Uid: (197613/ Philip) Gid: (197121/ UNKNOWN)
Access: 2017-04-22 16:43:47.562500000 +0100
Modify: 2017-04-22 16:43:47.562500000 +0100
Change: 2017-04-22 16:43:47.562500000 +0100
Birth: 2017-04-22 16:43:47.562500000 +0100
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git reset --hard
HEAD is now at 0db613e yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Resets the index and working tree. but the yyy file is already up to date.
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ stat yyy
File: 'yyy'
Size: 0 Blocks: 0 IO Block: 65536 regular empty file
Device: 94555d4eh/2488622414d Inode: 63331869760117686 Links: 1
Access: (0644/-rw-r--r--) Uid: (197613/ Philip) Gid: (197121/ UNKNOWN)
Access: 2017-04-22 16:43:47.562500000 +0100
Modify: 2017-04-22 16:43:47.562500000 +0100
Change: 2017-04-22 16:43:47.562500000 +0100
Birth: 2017-04-22 16:43:47.562500000 +0100
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
====
B.
Philip@PhilipOakley MINGW32 /usr/src
$ cd test
Philip@PhilipOakley MINGW32 /usr/src/test
$ git init
Initialized empty Git repository in C:/git-sdk-32/usr/src/test/.git/
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ touch xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git add xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git commit -m xxx
[master (root-commit) 00e124e] xxx
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ touch yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git add yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git commit -m yyy
[master fe84b18] yyy
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git status
On branch master
nothing to commit, working tree clean
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ sleep 2
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git reset HEAD^
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # move the branch back one commit implies --mixed.
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Resets the index but not the working tree
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # (i.e., the changed files are preserved but not marked for commit)
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
yyy
nothing added to commit but untracked files present (use "git add" to track)
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git reflog
00e124e HEAD@{0}: reset: moving to HEAD^
fe84b18 HEAD@{1}: commit: yyy
00e124e HEAD@{2}: commit (initial): xxx
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ stat yyy
File: 'yyy'
Size: 0 Blocks: 0 IO Block: 65536 regular empty file
Device: 94555d4eh/2488622414d Inode: 17451448556419482 Links: 1
Access: (0644/-rw-r--r--) Uid: (197613/ Philip) Gid: (197121/ UNKNOWN)
Access: 2017-04-22 16:47:19.437500000 +0100
Modify: 2017-04-22 16:47:19.437500000 +0100
Change: 2017-04-22 16:47:19.437500000 +0100
Birth: 2017-04-22 16:47:19.437500000 +0100
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Option B
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ git reset --hard @{1}
HEAD is now at fe84b18 yyy
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Resets the index and working tree.
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Any changes to tracked files in the working tree since <commit> are
discarded.
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # brand new yyy file (in the commit) - overwrite whatever was there.
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ stat yyy
File: 'yyy'
Size: 0 Blocks: 0 IO Block: 65536 regular empty file
Device: 94555d4eh/2488622414d Inode: 17732923533130138 Links: 1
Access: (0644/-rw-r--r--) Uid: (197613/ Philip) Gid: (197121/ UNKNOWN)
Access: 2017-04-22 16:47:29.640625000 +0100
Modify: 2017-04-22 16:47:29.640625000 +0100
Change: 2017-04-22 16:47:29.640625000 +0100
Birth: 2017-04-22 16:47:19.437500000 +0100
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$ # Noticed difference is: 'make' detetcting a timestamp difference (in yyy?)
that was not expected.
Philip@PhilipOakley MINGW32 /usr/src/test (master)
$
===
So in both these cases, the test simplification appears to result in identical
output (unless I missed something - could easily happen)
--
Philip
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.