From: git.mexon@spamgourmet.com
To: git@vger.kernel.org
Subject: [BUG] git add -A --dry-run adds files to .git directory
Date: Tue, 12 Oct 2021 16:55:59 +0200 [thread overview]
Message-ID: <a2c0deed-fff3-6c1c-633f-af9dffea1e02@exon.name> (raw)
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.
What did you do before the bug happened? (Steps to reproduce your issue)
mat@charly:~$ git init repo
mat@charly:~$ cat /dev/random | head -c 100000000 > repo/randomfile
mat@charly:~$ git -C repo add -A -n
mat@charly:~$ du -hs repo/.git
What did you expect to happen? (Expected behavior)
76K repo/.git
What happened instead? (Actual behavior)
97M repo/.git
What's different between what you expected and what actually happened?
Even though I specified -n on the command line to make a dry run, it
still added the large file as an object.
Anything else you want to add:
This is counter-intuitive behaviour. When the documentation says "Don't
actually add the file(s)", it's reasonable to expect that this command
will leave the repository state as it found it. If there's a good
reason why these files should be added to the .git directory, that
behaviour should be made clear in the documentation, probably including
the reason why that counter-intuitive behaviour is necessary.
This bit me due to a script that was using git add -A -n to detect if a
repository had been locally modified. While I do have alternative
(actually better) ways to get this information, it wasn't an
unreasonable command to use in the first place, and it caused a real
issue in a production system.
Please review the rest of the bug report below.
You can delete any lines you don't wish to share.
[System Info]
git version:
git version 2.30.1 (Apple Git-130)
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Darwin 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21
PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64
compiler info: clang: 13.0.0 (clang-1300.0.29.3)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/bash
[Enabled Hooks]
next reply other threads:[~2021-10-12 14:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 14:55 git.mexon [this message]
2021-10-12 19:15 ` [PATCH] add: don't write objects with --dry-run René Scharfe
2021-10-12 20:15 ` Junio C Hamano
2021-10-12 20:17 ` Ævar Arnfjörð Bjarmason
2021-10-12 20:37 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2c0deed-fff3-6c1c-633f-af9dffea1e02@exon.name \
--to=git.mexon@spamgourmet.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).