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

Re: [PATCH 5/5] submodule: submodule_move_head omits old argument in forced case

From
Stefan Beller <sbeller@google.com>
Date
Dec 20, 2017, 19:36 UTC
Message-ID
<CAGZ79kZpY8iXhCUOB=KuwGPOr7zvV7z+Q-L43p28=7ydaTvutg@mail.gmail.com>
In-Reply-To
<20171220000148.GJ240141@aiede.mtv.corp.google.com>
On Tue, Dec 19, 2017 at 4:01 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 21 quoted lines
> Stefan Beller wrote:
>> On Tue, Dec 19, 2017 at 2:44 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>
>>>   checkout -f
>>>         I think I would expect this not to touch a submodule that
>>>         hasn't changed, since that would be consistent with its
>>>         behavior on files that haven't changed.
> [...]
>> I may have a different understanding of git commands than you do,
>> but a plain "checkout -f" with no further arguments is the same as
>> a hard reset IMHO, and could be used interchangeably?
>
> A kind person pointed out privately that you were talking about
> "git checkout -f" with no further arguments, not "git checkout -f
> <commit>".  In that context, the competing meanings I mentioned in
> https://crbug.com/git/5 don't exist: either a given entry in the
> worktree matches the index or it doesn't.
>
> So plain "git checkout -f" is similar to plain "git reset --hard"
> in that it means "make the worktree (and index, in the reset case)
> look just like this".

with "this" == the argument that was given, if the argument was omitted, HEAD is assumed.

>  checkout -f makes the worktree look like the index;
No, here is what my installation of git (recent master) does:
  $ git --version
git version 2.15.1.389.g52015aaf9d
  $ cat test.sh
  rm -rf tmp
  git init tmp
  cd tmp
  git commit --allow-empty -m initial
  echo commit >a
  echo commit >b
  echo commit >c
  git add .
  git commit -m commit
  echo index >a
  git add a
  echo worktree >a
  echo index >b
  git add b
  echo worktree>c
  $ sh test.sh
Initialized empty Git repository in /u/tmp/.git/
[master (root-commit) c109fb5] initial
[master fcc21ea] commit
 3 files changed, 3 insertions(+)
 create mode 100644 a
 create mode 100644 b
 create mode 100644 c
  $ cd tmp
  $ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

modified: a modified: b

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

modified: a modified: c

  $ git checkout -f
  $ git status
On branch master
nothing to commit, working tree clean
# Let's test the other commands as well:
  $ cd ..
  $ sh test.sh
   ...
  $ cd tmp
  $ git checkout -f HEAD
  $ git status
On branch master
nothing to commit, working tree clean
  # See, there is no difference between giving HEAD as an argument
  # or not! Try again with reset just for completeness:
  $ cd ..
  $ sh test.sh
   ...
  $ cd tmp
  $ git reset --hard
HEAD is now at b71ae70 commit
  $ git status
On branch master
nothing to commit, working tree clean
  # The only difference between reset and the checkout is that reset
  # tells me where we are.
> reset --hard makes the worktree and index look like HEAD.
I agree.
Show 5 quoted lines
> In that context, more aggressively making the submodule in the
> worktree get into the defined state sounds to me like a good change.
>
> Hopefully my confusion helps illustrate what a commit message focusing
> on the end user experience might want to mention.

I'll try to come up with a better commit message. Thanks for bearing with me here.

Stefan
>
> Thanks again,
> Jonathan
Previous: Jonathan NiederNext: Stefan Beller
Message 15 of 38 in “Fix --recurse-submodules for submodule worktree changes”
  1. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Dec 19, 2017
  2. 1/5 t/lib-submodule-update.sh: clarify testStefan Beller, Dec 19, 2017
  3. 3/5 t/lib-submodule-update.sh: add new test for submodule internal changeStefan Beller, Dec 19, 2017
  4. Jonathan NiederDec 19, 2017
  5. Stefan BellerDec 19, 2017
  6. 2/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Dec 19, 2017
  7. Junio C HamanoDec 22, 2017
  8. Stefan BellerDec 27, 2017
  9. 4/5 unpack-trees: Fix same() for submodulesStefan Beller, Dec 19, 2017
  10. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Dec 19, 2017
  11. Jonathan NiederDec 19, 2017
  12. Stefan BellerDec 19, 2017
  13. Jonathan NiederDec 19, 2017
  14. Jonathan NiederDec 20, 2017
  15. Stefan BellerDec 20, 2017
  16. Stefan BellerDec 20, 2017
  17. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Dec 27, 2017
  18. 1/5 t/helper/test-lazy-name-hash: fix compilationStefan Beller, Dec 27, 2017
  19. 2/5 t/lib-submodule-update.sh: clarify testStefan Beller, Dec 27, 2017
  20. 3/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Dec 27, 2017
  21. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Dec 27, 2017
  22. 4/5 unpack-trees: oneway_merge to update submodulesStefan Beller, Dec 27, 2017
  23. Junio C HamanoJan 2, 2018
  24. Stefan BellerJan 2, 2018
  25. 0/5 Fix --recurse-submodules for submodule worktree changesStefan Beller, Jan 3, 2018
  26. 1/5 t/helper/test-lazy-name-hash: fix compilationStefan Beller, Jan 3, 2018
  27. 2/5 t/lib-submodule-update.sh: clarify testStefan Beller, Jan 3, 2018
  28. 3/5 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Jan 3, 2018
  29. 5/5 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Jan 3, 2018
  30. 4/5 unpack-trees: oneway_merge to update submodulesStefan Beller, Jan 3, 2018
  31. Junio C HamanoJan 3, 2018
  32. Stefan BellerJan 3, 2018
  33. 0/4 Fix --recurse-submodules for submodule worktree changesStefan Beller, Jan 5, 2018
  34. 1/4 t/lib-submodule-update.sh: clarify testStefan Beller, Jan 5, 2018
  35. 2/4 t/lib-submodule-update.sh: Fix test ignoring ignored files in submodulesStefan Beller, Jan 5, 2018
  36. 3/4 unpack-trees: oneway_merge to update submodulesStefan Beller, Jan 5, 2018
  37. 4/4 submodule: submodule_move_head omits old argument in forced caseStefan Beller, Jan 5, 2018
  38. Junio C HamanoJan 9, 2018

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.