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

Re: [PATCH] Teach read-tree the -n|--dry-run option

From
Junio C Hamano <gitster@pobox.com>
Date
May 11, 2011, 22:47 UTC
Message-ID
<7v8vucg8h3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4DCB04A1.3010202@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
> Using this option tells read-tree to not update the index. That makes it
> possible to check if updating the index would be successful without
> changing it.
Thanks for verifying the 3-way case as well.
> As using --dry-run is expected to have no side effects, this option makes
> no sense together with "-u".

I wondered if there be cases where "read-tree -m <1 to 3 trees>" will succeed but the same command with "-u" can fail. If there were such cases, we would need more than this patch does.

An obvious case is when you cannot write to your working tree, perhaps due to ENOSPC or incorrect permission settings in the working tree, but I am not worried about that. I am only worried about situations related to version control (i.e. you may lose local changes).

I _think_ the only difference "-u" makes is that check_updates() makes calls to checkout_entry(), and the only errors checkout_entry() would catch are filesystem related ones. Even though there is one conditional that says "if the cached stat does not match, you cannot checkout unless you set .force to the checkout state", but unpack_trees() does set that flag, so we should be safe.

Thanks.
Previous: Jens Lehmann
Message 9 of 9 in “Teach checkout the -n|--dry-run option”
  1. Teach checkout the -n|--dry-run optionJens Lehmann, May 6, 2011
  2. Junio C HamanoMay 6, 2011
  3. Junio C HamanoMay 7, 2011
  4. Jens LehmannMay 8, 2011
  5. Jens LehmannMay 8, 2011
  6. Junio C HamanoMay 8, 2011
  7. Jens LehmannMay 8, 2011
  8. Teach read-tree the -n|--dry-run optionJens Lehmann, May 11, 2011
  9. Junio C HamanoMay 11, 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.