From: Tanga Joris <tangajoris@gmail.com>
To: git@vger.kernel.org
Cc: l.s.r@web.de, gitster@pobox.com, christian.couder@gmail.com,
siddharthasthana31@gmail.com, kaartic.sivaraam@gmail.com,
usmanakinyemi202@gmail.com, Tanga Joris <tangajoris@gmail.com>
Subject: [Outreachy PATCH v2 1/2] fast-import: handle --git-completion-helper before reading input
Date: Thu, 29 Oct 2026 04:26:15 +0300 [thread overview]
Message-ID: <20261029012616.139783-1-tangajoris@gmail.com> (raw)
In-Reply-To: <20261024052449.95869-1-tangajoris@gmail.com>
fast-import parses its options only after reading the "feature"
lines from its input, and it creates a temporary pack file before
that. So "git fast-import --git-completion-helper" waits for input,
and each run leaves a tmp_pack_* file behind.
bash completion runs the helper with the terminal as input, so
"git fast-import --<TAB>" would freeze once fast-import is no
longer marked with the NO_PARSEOPT flag.
Handle a lone --git-completion-helper or --git-completion-helper-all
right after the -h check, before creating the pack or reading input.
Reported-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Tanga Joris <tangajoris@gmail.com>
---
Changes since v1:
- New patch 1/2, addressing René's observation that completion would
block on fast-import
- 2/2 is unchanged
builtin/fast-import.c | 4 ++++
t/t9300-fast-import.sh | 8 ++++++++
2 files changed, 12 insertions(+)
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 9db3f83eea..f53113d5a5 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -4204,6 +4204,10 @@ int cmd_fast_import(int argc,
};
show_usage_with_options_if_asked(argc, argv, fast_import_usage, fast_import_options);
+ if (argc == 2 && (!strcmp(argv[1], "--git-completion-helper") ||
+ !strcmp(argv[1], "--git-completion-helper-all")))
+ parse_options(argc, argv, prefix, fast_import_options,
+ fast_import_usage, 0);
fast_import_state_init(&state, argc, argv, prefix, fast_import_options);
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 73c6e3d448..99d7843217 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2914,6 +2914,14 @@ test_expect_success 'R: blob appears only once' '
test 1 = $n
'
+test_expect_success 'R: --git-completion-helper does not read from stdin' '
+ find .git/objects/pack -name "tmp_pack_*" >before &&
+ echo garbage | git fast-import --git-completion-helper >out &&
+ test_grep -e "--date-format=" out &&
+ find .git/objects/pack -name "tmp_pack_*" >after &&
+ test_cmp before after
+'
+
###
### series S (mark and path parsing)
###
--
2.56.0.291.g0b48760bf4
next prev parent reply other threads:[~2026-10-29 1:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 5:24 [Outreachy PATCH] git.c: drop NO_PARSEOPT from builtins that use parse-options Tanga Joris
2026-10-25 7:59 ` René Scharfe
2026-10-26 2:59 ` Tanga Joris
2026-10-26 4:58 ` Junio C Hamano
2026-10-29 1:26 ` Tanga Joris [this message]
2026-10-29 1:26 ` [Outreachy PATCH v2 2/2] " Tanga Joris
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261029012616.139783-1-tangajoris@gmail.com \
--to=tangajoris@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kaartic.sivaraam@gmail.com \
--cc=l.s.r@web.de \
--cc=siddharthasthana31@gmail.com \
--cc=usmanakinyemi202@gmail.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox