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

Re: [PATCH] add: don't write objects with --dry-run

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 12, 2021, 20:17 UTC
Message-ID
<871r4qj8mw.fsf@evledraar.gmail.com>
In-Reply-To
<0131d21f-dabd-3da5-34bd-a570e990f9e0@web.de>
On Tue, Oct 12 2021, René Scharfe wrote:
Show 12 quoted lines
> When the option --dry-run/-n is given, "git add" doesn't change the
> index, but still writes out new object files.  Only hash the latter
> without writing instead to make the run as dry as possible.
>
> Use this opportunity to also make the hash_flags variable unsigned,
> to match the index_path() parameter it is used as.
>
> Reported-by: git.mexon@spamgourmet.com
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> Am I missing something?  Do we sometimes rely on the written objects
> within the "git add --dry-run" command?

Probably not, here's a semi-related patch of mine that never got integrated. E.g. you'll probably find that even if you're not writing objects we're still doing things like zlib compression here too (or not, I haven't looked): https://lore.kernel.org/git/20190520222932.22843-1-avarab@gmail.com/

I think the "git fetch --dry-run" command behaves like this too, i.e. doesn't update refs, but fetches and writes objects.

For the patch I hacked up I think it's easy to argue that it shouldn't do compression etc.

For this sort of thing and "fetch" I'm not so sure. Do we really know that there aren't people who rely on this for say the performance of seeing what an operation would do, and then not pay as much for the "real one" that updates the index/refs/etc. later? Is that subsequent "fetch" cheaper because of the --dry-run?

Maybe not, but it seems like something to look into.
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 5 in “[BUG] git add -A --dry-run adds files to .git directory”
  1. git.mexon@spamgourmet.comOct 12, 2021
  2. add: don't write objects with --dry-runRené Scharfe, Oct 12, 2021
  3. Junio C HamanoOct 12, 2021
  4. Ævar Arnfjörð BjarmasonOct 12, 2021
  5. Junio C HamanoOct 12, 2021

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.