* [PATCH 6/6] t: mark tests regarding git-pack-refs(1) to be backend specific
From: Patrick Steinhardt @ 2024-01-09 12:17 UTC (permalink / raw)
To: git
In-Reply-To: <cover.1704802213.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]
Both t1409 and t3210 exercise parts of git-pack-refs(1). Given that we
must check the on-disk files to verify whether the backend has indeed
packed refs as expected those test suites are deeply tied to the actual
backend that is in use.
Mark the test suites to depend on the REFFILES backend.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
t/t1409-avoid-packing-refs.sh | 6 ++++++
t/t3210-pack-refs.sh | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/t/t1409-avoid-packing-refs.sh b/t/t1409-avoid-packing-refs.sh
index f23c0152a8..7748973733 100755
--- a/t/t1409-avoid-packing-refs.sh
+++ b/t/t1409-avoid-packing-refs.sh
@@ -5,6 +5,12 @@ test_description='avoid rewriting packed-refs unnecessarily'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+if test_have_prereq !REFFILES
+then
+ skip_all='skipping files-backend specific pack-refs tests'
+ test_done
+fi
+
# Add an identifying mark to the packed-refs file header line. This
# shouldn't upset readers, and it should be omitted if the file is
# ever rewritten.
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 7f4e98db7d..c0f1f9cfb7 100755
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
@@ -15,6 +15,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+if test_have_prereq !REFFILES
+then
+ skip_all='skipping files-backend specific pack-refs tests'
+ test_done
+fi
+
test_expect_success 'enable reflogs' '
git config core.logallrefupdates true
'
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related
* [PATCH 5/6] t5526: break test submodule differently
From: Patrick Steinhardt @ 2024-01-09 12:17 UTC (permalink / raw)
To: git
In-Reply-To: <cover.1704802213.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 1873 bytes --]
In 10f5c52656 (submodule: avoid auto-discovery in
prepare_submodule_repo_env(), 2016-09-01) we fixed a bug when doing a
recursive fetch with submodule in the case where the submodule is broken
due to whatever reason. The test to exercise that the fix works breaks
the submodule by deleting its `HEAD` reference, which will cause us to
not detect the directory as a Git repository.
While this is perfectly fine in theory, this way of breaking the repo
becomes problematic with the current efforts to introduce another refdb
backend into Git. The new reftable backend has a stub HEAD file that
always contains "ref: refs/heads/.invalid" so that tools continue to be
able to detect such a repository. But as the reftable backend will never
delete this file even when asked to delete `HEAD` the current way to
delete the `HEAD` reference will stop working.
Adapt the code to instead delete the objects database. Going back with
this new way to cuase breakage confirms that it triggers the infinite
recursion just the same, and there are no equivalent ongoing efforts to
replace the object database with an alternate backend.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
t/t5526-fetch-submodules.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index 7ab220fa31..5e566205ba 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -771,7 +771,7 @@ test_expect_success 'fetching submodule into a broken repository' '
git -C dst fetch --recurse-submodules &&
# Break the receiving submodule
- test-tool -C dst/sub ref-store main delete-refs REF_NO_DEREF msg HEAD &&
+ rm -r dst/sub/.git/objects &&
# NOTE: without the fix the following tests will recurse forever!
# They should terminate with an error.
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related
* [PATCH 4/6] t1419: mark test suite as files-backend specific
From: Patrick Steinhardt @ 2024-01-09 12:17 UTC (permalink / raw)
To: git
In-Reply-To: <cover.1704802213.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]
With 59c35fac54 (refs/packed-backend.c: implement jump lists to avoid
excluded pattern(s), 2023-07-10) we have implemented logic to handle
excluded refs more efficiently in the "packed" ref backend. This logic
allows us to skip emitting refs completely which we know to not be of
any interest to the caller, which can avoid quite some allocaitons and
object lookups.
This was wired up via a new `exclude_patterns` parameter passed to the
backend's ref iterator. The backend only needs to handle them on a best
effort basis though, and in fact we only handle it for the "packed-refs"
file, but not for loose references. Consequentially, all callers must
still filter emitted refs with those exclude patterns.
The result is that handling exclude patterns is completely optional in
the ref backend, and any future backends may or may not implement it.
Let's thus mark the test for t1419 to depend on the REFFILES prereq.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
t/t1419-exclude-refs.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/t/t1419-exclude-refs.sh b/t/t1419-exclude-refs.sh
index 5d8c86b657..1359574419 100755
--- a/t/t1419-exclude-refs.sh
+++ b/t/t1419-exclude-refs.sh
@@ -8,6 +8,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+if test_have_prereq !REFFILES
+then
+ skip_all='skipping `git for-each-ref --exclude` tests; need files backend'
+ test_done
+fi
+
for_each_ref__exclude () {
GIT_TRACE2_PERF=1 test-tool ref-store main \
for-each-ref--exclude "$@" >actual.raw
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related
* [PATCH 3/6] t1302: make tests more robust with new extensions
From: Patrick Steinhardt @ 2024-01-09 12:17 UTC (permalink / raw)
To: git
In-Reply-To: <cover.1704802213.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]
In t1302 we exercise logic around "core.repositoryFormatVersion" and
extensions. These tests are not particularly robust against extensions
like the newly introduced "refStorage" extension.
Refactor the tests to be more robust:
- Check the DEFAULT_REPO_FORMAT prereq to determine the expected
repository format version. This helps to ensure that we only need to
update the prereq in a central place when new extensions are added.
- Use a separate repository to rewrite ".git/config" to test
combinations of the repository format version and extensions. This
ensures that we don't break the main test repository.
- Do not rewrite ".git/config" when exercising the "preciousObjects"
extension.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
t/t1302-repo-version.sh | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh
index 179474fa65..fb30c87e1b 100755
--- a/t/t1302-repo-version.sh
+++ b/t/t1302-repo-version.sh
@@ -28,7 +28,12 @@ test_expect_success 'setup' '
'
test_expect_success 'gitdir selection on normal repos' '
- test_oid version >expect &&
+ if test_have_prereq DEFAULT_REPO_FORMAT
+ then
+ echo 0
+ else
+ echo 1
+ fi >expect &&
git config core.repositoryformatversion >actual &&
git -C test config core.repositoryformatversion >actual2 &&
test_cmp expect actual &&
@@ -79,8 +84,13 @@ mkconfig () {
while read outcome version extensions; do
test_expect_success "$outcome version=$version $extensions" "
- mkconfig $version $extensions >.git/config &&
- check_${outcome}
+ test_when_finished 'rm -rf extensions' &&
+ git init extensions &&
+ (
+ cd extensions &&
+ mkconfig $version $extensions >.git/config &&
+ check_${outcome}
+ )
"
done <<\EOF
allow 0
@@ -94,7 +104,8 @@ allow 1 noop-v1
EOF
test_expect_success 'precious-objects allowed' '
- mkconfig 1 preciousObjects >.git/config &&
+ git config core.repositoryformatversion 1 &&
+ git config extensions.preciousObjects 1 &&
check_allow
'
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related
* [PATCH 2/6] t1301: mark test for `core.sharedRepository` as reffiles specific
From: Patrick Steinhardt @ 2024-01-09 12:17 UTC (permalink / raw)
To: git
In-Reply-To: <cover.1704802213.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]
In t1301 we verify whether reflog files written by the "files" ref
backend correctly honor permissions when "core.sharedRepository" is set.
The test logic is thus specific to the reffiles backend and will not
work with any other backends.
Mark the test accordingly with the REFFILES prereq.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
t/t1301-shared-repo.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
index e5a0d65caa..8e2c01e760 100755
--- a/t/t1301-shared-repo.sh
+++ b/t/t1301-shared-repo.sh
@@ -137,7 +137,7 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
test_cmp expect actual
'
-test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
+test_expect_success REFFILES,POSIXPERM 'git reflog expire honors core.sharedRepository' '
umask 077 &&
git config core.sharedRepository group &&
git reflog expire --all &&
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related
* [PATCH 1/6] t1300: mark tests to require default repo format
From: Patrick Steinhardt @ 2024-01-09 12:17 UTC (permalink / raw)
To: git
In-Reply-To: <cover.1704802213.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 2319 bytes --]
The t1300 test suite exercises the git-config(1) tool. To do so we
overwrite ".git/config" to contain custom contents. While this is easy
enough to do, it may create problems when using a non-default repository
format because we also overwrite the repository format version as well
as any potential extensions.
Mark these tests with the DEFAULT_REPO_FORMAT prerequisite to avoid the
problem. An alternative would be to carry over mandatory config keys
into the rewritten config file. But the effort does not seem worth it
given that the system under test is git-config(1), which is at a lower
level than the repository format.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
t/t1300-config.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index f4e2752134..1e953a0fc2 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1098,7 +1098,7 @@ test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
test_must_fail git config --file=linktolinktonada --list
'
-test_expect_success 'check split_cmdline return' "
+test_expect_success DEFAULT_REPO_FORMAT 'check split_cmdline return' "
git config alias.split-cmdline-fix 'echo \"' &&
test_must_fail git split-cmdline-fix &&
echo foo > foo &&
@@ -1156,7 +1156,7 @@ test_expect_success 'git -c works with aliases of builtins' '
test_cmp expect actual
'
-test_expect_success 'aliases can be CamelCased' '
+test_expect_success DEFAULT_REPO_FORMAT 'aliases can be CamelCased' '
test_config alias.CamelCased "rev-parse HEAD" &&
git CamelCased >out &&
git rev-parse HEAD >expect &&
@@ -2051,7 +2051,7 @@ test_expect_success '--show-origin stdin with file include' '
test_cmp expect output
'
-test_expect_success '--show-origin blob' '
+test_expect_success DEFAULT_REPO_FORMAT '--show-origin blob' '
blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
cat >expect <<-EOF &&
blob:$blob user.custom=true
@@ -2060,7 +2060,7 @@ test_expect_success '--show-origin blob' '
test_cmp expect output
'
-test_expect_success '--show-origin blob ref' '
+test_expect_success DEFAULT_REPO_FORMAT '--show-origin blob ref' '
cat >expect <<-\EOF &&
blob:main:custom.conf user.custom=true
EOF
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related
* [PATCH 0/6] t: mark "files"-backend specific tests
From: Patrick Steinhardt @ 2024-01-09 12:17 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 1141 bytes --]
Hi,
this patch series amends some of our tests that exercise "files"-backend
specific logic to have the respective prereqs. The patch series is quite
unexciting and part of our final preparations to get the new "reftable"
backend upstream.
The series depends on ps/refstorage-extension as it makes use of the new
DEFAULT_REPO_FORMAT prereq introduced by that branch.
Patrick
Patrick Steinhardt (6):
t1300: mark tests to require default repo format
t1301: mark test for `core.sharedRepository` as reffiles specific
t1302: make tests more robust with new extensions
t1419: mark test suite as files-backend specific
t5526: break test submodule differently
t: mark tests regarding git-pack-refs(1) to be backend specific
t/t1300-config.sh | 8 ++++----
t/t1301-shared-repo.sh | 2 +-
t/t1302-repo-version.sh | 19 +++++++++++++++----
t/t1409-avoid-packing-refs.sh | 6 ++++++
t/t1419-exclude-refs.sh | 6 ++++++
t/t3210-pack-refs.sh | 6 ++++++
t/t5526-fetch-submodules.sh | 2 +-
7 files changed, 39 insertions(+), 10 deletions(-)
--
2.43.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH 2/2] t7501: Add test for amending commit to add signoff.
From: Phillip Wood @ 2024-01-09 10:44 UTC (permalink / raw)
To: Ghanshyam Thakkar, git; +Cc: Christian Couder
In-Reply-To: <20240109060417.1144647-4-shyamthakkar001@gmail.com>
Hi Ghanshyam
On 09/01/2024 06:04, Ghanshyam Thakkar wrote:
> This commit adds test for amending the latest commit to add
> Signed-off-by trailer at the end of commit message.
If we're not already testing this then it seems like a useful addition,
thanks for working on it. It would also be helpful to check that "git
commit --amend --signoff" does not add a Signed-off-by: trailer if it
already exists.
> +test_expect_success 'amend commit to add signoff' '
> +
> + test_when_finished "rm -rf testdir" &&
> + git init testdir &&
As Christian said about the other patch in this series I don't think we
need a new repository here. In our test files we use the same repository
for the whole file unless there is a compelling reason not to.
> + echo content >testdir/file &&
> + git -C testdir add file &&
> + git -C testdir commit -m "file" &&
I think these three lines can be replaced by
test_commit --no-tag file file content
> + git -C testdir commit --amend --signoff &&
> + git -C testdir log -1 --pretty=format:%B >actual &&
> + (
> + echo file &&
> + echo &&
> + git -C testdir var GIT_COMMITTER_IDENT >ident &&
> + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
> + ) >expected &&
> + test_cmp expected actual
This section of the test can be improved by using test_commit_message
test_commit_message HEAD <<-EOF
file
Signed-off-by: $GIT_COMMITER_NAME <$GIT_COMMITTER_EMAIL>
EOF
Best Wishes
Phillip
^ permalink raw reply
* Re: [Outreachy][PATCH v4] Port helper/test-ctype.c to unit-tests/t-ctype.c
From: Phillip Wood @ 2024-01-09 10:35 UTC (permalink / raw)
To: Achu Luma, git
Cc: gitster, chriscool, christian.couder, l.s.r, phillip.wood,
steadmon, me
In-Reply-To: <20240105161413.10422-1-ach.lumap@gmail.com>
Hi Achu
On 05/01/2024 16:14, Achu Luma wrote:
> In the recent codebase update (8bf6fbd00d (Merge branch
> 'js/doc-unit-tests', 2023-12-09)), a new unit testing framework was
> merged, providing a standardized approach for testing C code. Prior to
> this update, some unit tests relied on the test helper mechanism,
> lacking a dedicated unit testing framework. It's more natural to perform
> these unit tests using the new unit test framework.
>
> This commit migrates the unit tests for C character classification
> functions (isdigit(), isspace(), etc) from the legacy approach
> using the test-tool command `test-tool ctype` in t/helper/test-ctype.c
> to the new unit testing framework (t/unit-tests/test-lib.h).
>
> The migration involves refactoring the tests to utilize the testing
> macros provided by the framework (TEST() and check_*()).
>
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Helped-by: René Scharfe <l.s.r@web.de>
> Helped-by: Phillip Wood <phillip.wood123@gmail.com>
> Helped-by: Taylor Blau <me@ttaylorr.com>
> Signed-off-by: Achu Luma <ach.lumap@gmail.com>
> ---
> The changes between version 3 and version 4 are the following:
>
> - Some duplication has been reduced using a new TEST_CHAR_CLASS() macro.
> - A "0x"prefix has been added to avoid confusion between decimal and
> hexadecimal codes printed by test_msg().
> - The "Mentored-by:..." trailer has been restored.
> - "works as expected" has been reduced to just "works" as suggested by Taylor.
> - Some "Helped-by: ..." trailers have been added.
> - Some whitespace fixes have been made.
Thanks for the re-roll, the changes look good, there is one issue that I
spotted below
> -#define TEST_CLASS(t,s) { \
> - int i; \
> - for (i = 0; i < 256; i++) { \
> - if (is_in(s, i) != t(i)) \
> - report_error(#t, i); \
> - } \
> - if (t(EOF)) \
> - report_error(#t, EOF); \
> -}
In the old version we test EOF in addition to each character between 0-255
> +/* Macro to test a character type */
> +#define TEST_CTYPE_FUNC(func, string) \
> +static void test_ctype_##func(void) { \
> + for (int i = 0; i < 256; i++) { \
> + if (!check_int(func(i), ==, is_in(string, i))) \
> + test_msg(" i: 0x%02x", i); \
> + } \
> +}
In the new version we only test the characters 0-255, not EOF. If there
is a good reason for removing the EOF tests then it should be explained
in the commit message. If not it would be good to add those tests back.
Best Wishes
Phillip
^ permalink raw reply
* Re: [GSoC][RFC] Replace use of atoi() with strtol_i(), as a microproject
From: Christian Couder @ 2024-01-09 9:56 UTC (permalink / raw)
To: mohitmarathe
Cc: git@vger.kernel.org, gitster@pobox.com, britton.kerin@gmail.com,
peff@peff.net
In-Reply-To: <OqD4xQ_p-jcftCbAw0ovvrBztfiuoMGcTonCc0i6x7Ziy-hx3uA-Hoz4-3tfRI39KMj-V5OZIGgOe66b1eyX3YrKZNThMYjjMkn6g4-Ww8c=@proton.me>
Hi,
On Mon, Jan 8, 2024 at 6:38 PM <mohitmarathe@proton.me> wrote:
>
> Hello,
>
> I'm Mohit, an undergrad from India, and I want to start contributing to the Git project. I have already built Git from source and finished `git psuh` tutorial. And I must say the "Hacking Git" documentation is great (very detailed and maybe exhaustive) and easy to follow. So I also read the topic on "microprojects", and while searching for one, I came across this message: https://public-inbox.org/git/xmqqjzpjsbjl.fsf@gitster.g/.
> I want to work on this task (if it is not taken up already) as a microproject for GSoC.
Thanks for your interest in Git and the GSoC!
> Approach:
> From what I understood, the idea is to *not* allow non-integer characters in the arguments by printing an error message. So we have to replace `atoi` with `strtol_i`, like it is done in this patch: https://public-inbox.org/git/xmqq5y181fx0.fsf_-_@gitster.g/.
> There are some places where we want to continue to parse after the end of the integer (where `strspn` is used as mentioned by Junio), and based on Junio's suggestion, a new helper can be created like this:
>
> > static inline int strtol_i2(char const *s, int base, int *result, char **endp)
> > {
> > long ul;
> > char *dummy = NULL;
> >
> > if (!endp)
> > endp = &dummy;
> > errno = 0;
> > ul = strtol(s, &endp, base);
> > if (errno ||
> > /*
> > * if we are told to parse to the end of the string by
> > * passing NULL to endp, it is an error to have any
> > * remaining character after the digits.
> > */
> > (dummy && *dummy) ||
> > endp == s || (int) ul != ul)
> > return -1;
> > *result = ul;
> > return 0;
> > }
>
>
> So I searched for all the occurrences of `atoi(` (as suggested by Junio), and I found only two instances (both in `builtin/patch-id.c`) where it is followed by `strspn`. Is it safe to assume that this is the only place where we cannot directly replace `atoi` with `strtol_i`, or should I keep digging?
In https://public-inbox.org/git/xmqqjzpjsbjl.fsf@gitster.g/ Junio says:
"Some places use atoi() immediately followed by strspn() to skip over
digits, which means they are parsing an integer and want to continue
reading after the integer, which is incompatible with what
strtol_i() wants to do. They need either a separate helper or an
updated strtol_i() that optionally allows you to parse the prefix
and report where the integer ended, e.g., something like:"
and then he suggests the above helper.
So it seems that the two instances you found look like good places
where Junio says the new helper could be useful.
Now if you want to continue further on this, I think you would need to
take a closer look at those two instances to see if replacing atoi()
there with the new helper would improve something there or not. If you
find it would improve something, be sure to explain what would be
improved in the commit message.
> Also, this seems like a large change due to the number of files involved, while the documentation about the microproject emphasizes keeping the change small. Does it mean a small change per commit or a small change per Pull Request?
I think that adding a new helper in one .c file and its declaration in
the corresponding .h file, and then using it in another .c file would
change around 3 files and would be Ok size wise for a microproject.
Thanks.
^ permalink raw reply
* Re: [PATCH 0/2][GSOC] t7501: Add tests for various index usages, -i and -o, of commit command and amending commit to add signoff.
From: Christian Couder @ 2024-01-09 9:32 UTC (permalink / raw)
To: Ghanshyam Thakkar; +Cc: git
In-Reply-To: <20240109060417.1144647-2-shyamthakkar001@gmail.com>
On Tue, Jan 9, 2024 at 7:10 AM Ghanshyam Thakkar
<shyamthakkar001@gmail.com> wrote:
>
> This patch series adds tests for various index usages, -i and -o, of commit
> command and amending commit to add Signed-of-by trailer. This is in
> reference to the comment added in commit 12ace0b2 which reads:
>
> # FIXME: Test the various index usages, -i and -o, test reflog,
> # signoff, hooks
It seems to me that the patch series should remove or change that
FIXME if it resolves it, or some parts of it.
For example I would expect the patch that adds -i and -o related tests
to remove at least "-i and -o, " from that FIXME comment.
> Ghanshyam Thakkar (2):
> t7501: Add tests for various index usages, -i and -o, of commit
> command.
> t7501: Add test for amending commit to add signoff.
I commented on the first patch, and I took a look at the second one.
It seems to me that a number of comments I made on the first one are
valid for the second one as well. For a micro-project I would suggest
focussing on only one patch though. As we say in
https://git.github.io/General-Microproject-Information/, we want
quality, not quantity! You can always work on other possible bigger
things after your micro-project is merged.
Thanks!
^ permalink raw reply
* Re: [PATCH 1/2] t7501: Add tests for various index usages, -i and -o, of commit command.
From: Christian Couder @ 2024-01-09 9:20 UTC (permalink / raw)
To: Ghanshyam Thakkar; +Cc: git
In-Reply-To: <20240109060417.1144647-3-shyamthakkar001@gmail.com>
First about the commit subject:
"t7501: Add tests for various index usages, -i and -o, of commit command."
it should be shorter, shouldn't end with a "." and "Add" should be "add".
On Tue, Jan 9, 2024 at 7:10 AM Ghanshyam Thakkar
<shyamthakkar001@gmail.com> wrote:
>
> This commit adds tests for -i and -o flags of the commit command. It
> includes testing -i with and without staged changes, testing -o with and
> without staged changes, and testing -i and -o together.
A few suggestions to make things a bit more clear:
- tell that -i is a synonymous for --include and -o for --only
- tell if there are already tests for these options
- tell why the tests you add are worth it if tests for an option already exist
> Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
> ---
> t/t7501-commit-basic-functionality.sh | 90 +++++++++++++++++++++++++++
> 1 file changed, 90 insertions(+)
>
> diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh
> index 3d8500a52e..71dc52ce3a 100755
> --- a/t/t7501-commit-basic-functionality.sh
> +++ b/t/t7501-commit-basic-functionality.sh
> @@ -76,6 +76,96 @@ test_expect_success 'nothing to commit' '
> test_must_fail git commit -m initial
> '
>
> +test_expect_success 'commit with -i fails with untracked files' '
> + test_when_finished "rm -rf testdir" &&
> + git init testdir &&
> + echo content >testdir/file.txt &&
> + test_must_fail git -C testdir commit -i file.txt -m initial
> +'
Existing tests didn't need a repo, so I am not sure it's worth
creating a testdir repo just for this test.
Also I am not sure this is the best place in the test script to add -i
and -o related tests. Here we are between a 'nothing to commit' test
and a '--dry-run fails with nothing to commit' and then more 'nothing
to commit' related tests. I think it would be better if all those
'nothing to commit' related tests could stay together.
> +test_expect_success 'commit with -i' '
> + echo content >bar &&
> + git add bar &&
> + git commit -m "bar" &&
Why is the above needed for this test?
> + echo content2 >bar &&
> + git commit -i bar -m "bar second"
> +'
> +
> +test_expect_success 'commit with -i multiple files' '
> + test_when_finished "git reset --hard" &&
> + echo content >bar &&
> + echo content >baz &&
> + echo content >saz &&
> + git add bar baz saz &&
> + git commit -m "bar baz saz" &&
Not sure why the above is needed here too.
> + echo content2 >bar &&
> + echo content2 >baz &&
> + echo content2 >saz &&
> + git commit -i bar saz -m "bar" &&
> + git diff --name-only >remaining &&
> + test_grep "baz" remaining
> +'
> +
> +test_expect_success 'commit with -i includes staged changes' '
> + test_when_finished "git reset --hard" &&
> + echo content >bar &&
> + git add bar &&
> + git commit -m "bar" &&
> +
> + echo content2 >bar &&
> + echo content2 >baz &&
> + git add baz &&
> + git commit -i bar -m "bar baz" &&
> + git diff --name-only >remaining &&
> + test_must_be_empty remaining &&
> + git diff --name-only --staged >remaining &&
> + test_must_be_empty remaining
> +'
> +
> +test_expect_success 'commit with -o' '
> + echo content >bar &&
> + git add bar &&
> + git commit -m "bar" &&
> + echo content2 >bar &&
> + git commit -o bar -m "bar again"
> +'
> +
> +test_expect_success 'commit with -o fails with untracked files' '
> + test_when_finished "rm -rf testdir" &&
> + git init testdir &&
> + echo content >testdir/bar &&
> + test_must_fail git -C testdir commit -o bar -m "bar"
> +'
> +
> +test_expect_success 'commit with -o exludes staged changes' '
s/exludes/excludes/
> + test_when_finished "git reset --hard" &&
> + echo content >bar &&
> + echo content >baz &&
> + git add . &&
> + git commit -m "bar baz" &&
> +
> + echo content2 >bar &&
> + echo content2 >baz &&
> + git add baz &&
> + git commit -o bar -m "bar" &&
> + git diff --name-only --staged >actual &&
> + test_grep "baz" actual
> +'
Thanks.
^ permalink raw reply
* [PATCH 2/2] t7501: Add test for amending commit to add signoff.
From: Ghanshyam Thakkar @ 2024-01-09 6:04 UTC (permalink / raw)
To: git; +Cc: Ghanshyam Thakkar
In-Reply-To: <20240109060417.1144647-2-shyamthakkar001@gmail.com>
This commit adds test for amending the latest commit to add
Signed-off-by trailer at the end of commit message.
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
---
t/t7501-commit-basic-functionality.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh
index 71dc52ce3a..35c69c3ddd 100755
--- a/t/t7501-commit-basic-functionality.sh
+++ b/t/t7501-commit-basic-functionality.sh
@@ -464,6 +464,24 @@ test_expect_success 'amend commit to fix author' '
'
+test_expect_success 'amend commit to add signoff' '
+
+ test_when_finished "rm -rf testdir" &&
+ git init testdir &&
+ echo content >testdir/file &&
+ git -C testdir add file &&
+ git -C testdir commit -m "file" &&
+ git -C testdir commit --amend --signoff &&
+ git -C testdir log -1 --pretty=format:%B >actual &&
+ (
+ echo file &&
+ echo &&
+ git -C testdir var GIT_COMMITTER_IDENT >ident &&
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident
+ ) >expected &&
+ test_cmp expected actual
+'
+
test_expect_success 'amend commit to fix date' '
test_tick &&
--
2.43.0
^ permalink raw reply related
* [PATCH 1/2] t7501: Add tests for various index usages, -i and -o, of commit command.
From: Ghanshyam Thakkar @ 2024-01-09 6:04 UTC (permalink / raw)
To: git; +Cc: Ghanshyam Thakkar
In-Reply-To: <20240109060417.1144647-2-shyamthakkar001@gmail.com>
This commit adds tests for -i and -o flags of the commit command. It
includes testing -i with and without staged changes, testing -o with and
without staged changes, and testing -i and -o together.
Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
---
t/t7501-commit-basic-functionality.sh | 90 +++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh
index 3d8500a52e..71dc52ce3a 100755
--- a/t/t7501-commit-basic-functionality.sh
+++ b/t/t7501-commit-basic-functionality.sh
@@ -76,6 +76,96 @@ test_expect_success 'nothing to commit' '
test_must_fail git commit -m initial
'
+test_expect_success 'commit with -i fails with untracked files' '
+ test_when_finished "rm -rf testdir" &&
+ git init testdir &&
+ echo content >testdir/file.txt &&
+ test_must_fail git -C testdir commit -i file.txt -m initial
+'
+
+test_expect_success 'commit with -i' '
+ echo content >bar &&
+ git add bar &&
+ git commit -m "bar" &&
+
+ echo content2 >bar &&
+ git commit -i bar -m "bar second"
+'
+
+test_expect_success 'commit with -i multiple files' '
+ test_when_finished "git reset --hard" &&
+ echo content >bar &&
+ echo content >baz &&
+ echo content >saz &&
+ git add bar baz saz &&
+ git commit -m "bar baz saz" &&
+
+ echo content2 >bar &&
+ echo content2 >baz &&
+ echo content2 >saz &&
+ git commit -i bar saz -m "bar" &&
+ git diff --name-only >remaining &&
+ test_grep "baz" remaining
+'
+
+test_expect_success 'commit with -i includes staged changes' '
+ test_when_finished "git reset --hard" &&
+ echo content >bar &&
+ git add bar &&
+ git commit -m "bar" &&
+
+ echo content2 >bar &&
+ echo content2 >baz &&
+ git add baz &&
+ git commit -i bar -m "bar baz" &&
+ git diff --name-only >remaining &&
+ test_must_be_empty remaining &&
+ git diff --name-only --staged >remaining &&
+ test_must_be_empty remaining
+'
+
+test_expect_success 'commit with -o' '
+ echo content >bar &&
+ git add bar &&
+ git commit -m "bar" &&
+ echo content2 >bar &&
+ git commit -o bar -m "bar again"
+'
+
+test_expect_success 'commit with -o fails with untracked files' '
+ test_when_finished "rm -rf testdir" &&
+ git init testdir &&
+ echo content >testdir/bar &&
+ test_must_fail git -C testdir commit -o bar -m "bar"
+'
+
+test_expect_success 'commit with -o exludes staged changes' '
+ test_when_finished "git reset --hard" &&
+ echo content >bar &&
+ echo content >baz &&
+ git add . &&
+ git commit -m "bar baz" &&
+
+ echo content2 >bar &&
+ echo content2 >baz &&
+ git add baz &&
+ git commit -o bar -m "bar" &&
+ git diff --name-only --staged >actual &&
+ test_grep "baz" actual
+'
+
+test_expect_success 'commit with both -i and -o fails' '
+ test_when_finished "git reset --hard" &&
+ echo content >bar &&
+ echo content >baz &&
+ git add . &&
+ git commit -m "bar baz" &&
+
+ echo content2 >bar &&
+ echo content2 >baz &&
+ test_must_fail git commit -i baz -o bar -m "bar"
+'
+
test_expect_success '--dry-run fails with nothing to commit' '
test_must_fail git commit -m initial --dry-run
'
--
2.43.0
^ permalink raw reply related
* [PATCH 0/2][GSOC] t7501: Add tests for various index usages, -i and -o, of commit command and amending commit to add signoff.
From: Ghanshyam Thakkar @ 2024-01-09 6:04 UTC (permalink / raw)
To: git; +Cc: Ghanshyam Thakkar
This patch series adds tests for various index usages, -i and -o, of commit
command and amending commit to add Signed-of-by trailer. This is in
reference to the comment added in commit 12ace0b2 which reads:
# FIXME: Test the various index usages, -i and -o, test reflog,
# signoff, hooks
Ghanshyam Thakkar (2):
t7501: Add tests for various index usages, -i and -o, of commit
command.
t7501: Add test for amending commit to add signoff.
t/t7501-commit-basic-functionality.sh | 108 ++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
--
2.43.0
^ permalink raw reply
* [PATCH v2 1/1] completion: don't complete revs when --no-format-patch
From: Britton Leo Kerin @ 2024-01-09 1:08 UTC (permalink / raw)
To: git; +Cc: Britton Leo Kerin
In-Reply-To: <20240109010830.458775-1-britton.kerin@gmail.com>
In this case the user has specifically said they don't want send-email
to run format-patch so revs aren't valid argument completions (and it's
likely revs and dirs do have some same names or prefixes as in
Documentation/MyFirstContribution.txt 'psuh').
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 185b47d802..c983f3b2ab 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1242,10 +1242,12 @@ __git_find_last_on_cmdline ()
while test $# -gt 1; do
case "$1" in
--show-idx) show_idx=y ;;
+ --) shift && break ;;
*) return 1 ;;
esac
shift
done
+ [ $# -eq 1 ] || return 1 # return 1 if we got wrong # of non-opts
local wordlist="$1"
while [ $c -gt "$__git_cmd_idx" ]; do
@@ -2429,7 +2431,9 @@ _git_send_email ()
return
;;
esac
- __git_complete_revlist
+ if [ "$(__git_find_last_on_cmdline -- "--format-patch --no-format-patch")" != "--no-format-patch" ]; then
+ __git_complete_revlist
+ fi
}
_git_stage ()
--
2.43.0
^ permalink raw reply related
* [PATCH v2 0/1] completion: don't complete revs when --no-format-patch
From: Britton Leo Kerin @ 2024-01-09 1:08 UTC (permalink / raw)
To: git; +Cc: Britton Leo Kerin
In-Reply-To: <9627364b-c0c9-4b85-a81a-ba1ef0735c9a@smtp-relay.sendinblue.com>
Improve commit message
Britton Leo Kerin (1):
completion: don't complete revs when --no-format-patch
contrib/completion/git-completion.bash | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Range-diff against v1:
1: ff4d2e55e3 ! 1: e56dbbacd9 completion: don't comp revs when --no-format-patch
@@ Metadata
Author: Britton Leo Kerin <britton.kerin@gmail.com>
## Commit message ##
- completion: don't comp revs when --no-format-patch
+ completion: don't complete revs when --no-format-patch
In this case the user has specifically said they don't want send-email
to run format-patch so revs aren't valid argument completions (and it's
--
2.43.0
^ permalink raw reply
* [PATCH v2 0/1] completion: complete dir-type option args to am, format_patch
From: Britton Leo Kerin @ 2024-01-09 0:53 UTC (permalink / raw)
To: git; +Cc: Britton Leo Kerin, Junio C Hamano
In-Reply-To: <4714b88d-df5b-4e37-a5d7-af5033cfb861@smtp-relay.sendinblue.com>
This revision adds missing double quotes to improve the completion
situation for paths with spaces in them, and adds some comments.
Britton Leo Kerin (1):
completion: dir-type optargs for am, format-patch
contrib/completion/git-completion.bash | 37 ++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
Range-diff against v1:
1: 2d788b0b18 ! 1: 5161304a92 completion: dir-type optargs for am, format-patch
@@ contrib/completion/git-completion.bash: __git_count_arguments ()
printf "%d" $c
}
-+
+# Complete actual dir (not pathspec), respecting any -C options.
+#
+# Usage: __git_complete_refs [<option>]...
@@ contrib/completion/git-completion.bash: __git_count_arguments ()
+ shift
+ done
+
++ # This rev-parse invocation amounts to a pwd which respects -C options
+ local context_dir=$(__git rev-parse --show-toplevel --show-prefix 2>/dev/null | paste -s -d '/' 2>/dev/null)
-+ [ -d "$context_dir" ] || return
++ [ -d "$context_dir" ] || return 1
+
-+ COMPREPLY=$(cd $context_dir 2>/dev/null && compgen -d -- "$cur_")
++ COMPREPLY=$(cd "$context_dir" 2>/dev/null && compgen -d -- "$cur_")
+}
-+
+
__git_whitespacelist="nowarn warn error error-all fix"
__git_patchformat="mbox stgit stgit-series hg mboxrd"
--
2.43.0
^ permalink raw reply
* [PATCH v2 1/1] completion: dir-type optargs for am, format-patch
From: Britton Leo Kerin @ 2024-01-09 0:53 UTC (permalink / raw)
To: git; +Cc: Britton Leo Kerin
In-Reply-To: <20240109005303.444932-1-britton.kerin@gmail.com>
Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
contrib/completion/git-completion.bash | 37 ++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 185b47d802..2b2b6c9738 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1356,6 +1356,29 @@ __git_count_arguments ()
printf "%d" $c
}
+# Complete actual dir (not pathspec), respecting any -C options.
+#
+# Usage: __git_complete_refs [<option>]...
+# --cur=<word>: The current dir to be completed. Defaults to the current word.
+__git_complete_dir ()
+{
+ local cur_="$cur"
+
+ while test $# != 0; do
+ case "$1" in
+ --cur=*) cur_="${1##--cur=}" ;;
+ *) return 1 ;;
+ esac
+ shift
+ done
+
+ # This rev-parse invocation amounts to a pwd which respects -C options
+ local context_dir=$(__git rev-parse --show-toplevel --show-prefix 2>/dev/null | paste -s -d '/' 2>/dev/null)
+ [ -d "$context_dir" ] || return 1
+
+ COMPREPLY=$(cd "$context_dir" 2>/dev/null && compgen -d -- "$cur_")
+}
+
__git_whitespacelist="nowarn warn error error-all fix"
__git_patchformat="mbox stgit stgit-series hg mboxrd"
__git_showcurrentpatch="diff raw"
@@ -1374,6 +1397,10 @@ _git_am ()
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
+ --directory=*)
+ __git_complete_dir --cur="${cur##--directory=}"
+ return
+ ;;
--patch-format=*)
__gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
return
@@ -1867,7 +1894,17 @@ __git_format_patch_extra_options="
_git_format_patch ()
{
+ case "$prev,$cur" in
+ -o,*)
+ __git_complete_dir
+ return
+ ;;
+ esac
case "$cur" in
+ --output-directory=*)
+ __git_complete_dir --cur="${cur##--output-directory=}"
+ return
+ ;;
--thread=*)
__gitcomp "
deep shallow
--
2.43.0
^ permalink raw reply related
* Re: [Outreachy][PATCH v4] Port helper/test-ctype.c to unit-tests/t-ctype.c
From: Junio C Hamano @ 2024-01-08 22:32 UTC (permalink / raw)
To: René Scharfe
Cc: Achu Luma, git, chriscool, christian.couder, phillip.wood,
steadmon, me, Phillip Wood
In-Reply-To: <a087f57c-ce72-45c7-8182-f38d0aca9030@web.de>
René Scharfe <l.s.r@web.de> writes:
> Quite an improvement over v3! Now you only need to repeat the class
> names once.
>
> Can we do any better?
;-)
^ permalink raw reply
* [PATCH] fetch: add new config option fetch.all
From: Tamino Bauknecht @ 2024-01-08 21:13 UTC (permalink / raw)
To: git; +Cc: Tamino Bauknecht
In-Reply-To: <xmqqwmsjlou7.fsf@gitster.g>
Introduce a boolean configuration option fetch.all which allows to
fetch all available remotes by default. The config option can be
overridden by explicitly specifying a remote or by using --no-all.
The behavior for --all is unchanged and calling git-fetch with --all
and a remote will still result in an error.
Additionally, describe the configuration variable in the config
documentation and implement new tests to cover the expected behavior.
Also add --no-all to the command-line documentation of git-fetch.
Signed-off-by: Tamino Bauknecht <dev@tb6.eu>
---
Thanks again for the amazing in-depth feedback, Junio and Eric.
I misread Documentation/technical/api-parse-options.txt and thought
OPT_BOOL will always change to 0 or 1, but looks like it also doesn't
touch the variable if no --[no-]all was given.
Your other suggestion also simplified the patch quite a bit, thanks.
I only added an additional line of comment to hopefully make it easier
to understand.
The unnecessary "|| return 1" was also removed.
Documentation/config/fetch.txt | 6 ++
Documentation/fetch-options.txt | 5 +-
builtin/fetch.c | 17 +++-
t/t5514-fetch-multiple.sh | 161 ++++++++++++++++++++++++++++++++
4 files changed, 186 insertions(+), 3 deletions(-)
diff --git a/Documentation/config/fetch.txt b/Documentation/config/fetch.txt
index aea5b97477..d7dc461bd1 100644
--- a/Documentation/config/fetch.txt
+++ b/Documentation/config/fetch.txt
@@ -50,6 +50,12 @@ fetch.pruneTags::
refs. See also `remote.<name>.pruneTags` and the PRUNING
section of linkgit:git-fetch[1].
+fetch.all::
+ If true, fetch will attempt to update all available remotes.
+ This behavior can be overridden by passing `--no-all` or by
+ explicitly specifying one or more remote(s) to fetch from.
+ Defaults to false.
+
fetch.output::
Control how ref update status is printed. Valid values are
`full` and `compact`. Default value is `full`. See the
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index a1d6633a4f..54ebb4452e 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -1,5 +1,6 @@
---all::
- Fetch all remotes.
+--[no-]all::
+ Fetch all remotes. This overrides the configuration variable
+ `fetch.all`.
-a::
--append::
diff --git a/builtin/fetch.c b/builtin/fetch.c
index a284b970ef..94bd12affd 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -102,6 +102,7 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
struct fetch_config {
enum display_format display_format;
+ int all;
int prune;
int prune_tags;
int show_forced_updates;
@@ -115,6 +116,11 @@ static int git_fetch_config(const char *k, const char *v,
{
struct fetch_config *fetch_config = cb;
+ if (!strcmp(k, "fetch.all")) {
+ fetch_config->all = git_config_bool(k, v);
+ return 0;
+ }
+
if (!strcmp(k, "fetch.prune")) {
fetch_config->prune = git_config_bool(k, v);
return 0;
@@ -2132,7 +2138,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
const char *bundle_uri;
struct string_list list = STRING_LIST_INIT_DUP;
struct remote *remote = NULL;
- int all = 0, multiple = 0;
+ int all = -1, multiple = 0;
int result = 0;
int prune_tags_ok = 1;
int enable_auto_gc = 1;
@@ -2337,11 +2343,20 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
fetch_bundle_uri(the_repository, bundle_uri, NULL))
warning(_("failed to fetch bundles from '%s'"), bundle_uri);
+ if (all < 0) {
+ /*
+ * no --[no-]all given;
+ * only use config option if no remote was explicitly specified
+ */
+ all = (!argc) ? config.all : 0;
+ }
+
if (all) {
if (argc == 1)
die(_("fetch --all does not take a repository argument"));
else if (argc > 1)
die(_("fetch --all does not make sense with refspecs"));
+
(void) for_each_remote(get_one_remote_for_fetch, &list);
/* do not do fetch_multiple() of one */
diff --git a/t/t5514-fetch-multiple.sh b/t/t5514-fetch-multiple.sh
index a95841dc36..25772c85c5 100755
--- a/t/t5514-fetch-multiple.sh
+++ b/t/t5514-fetch-multiple.sh
@@ -24,6 +24,15 @@ setup_repository () {
)
}
+setup_test_clone () {
+ test_dir="$1" &&
+ git clone one "$test_dir" &&
+ for r in one two three
+ do
+ git -C "$test_dir" remote add "$r" "../$r" || return 1
+ done
+}
+
test_expect_success setup '
setup_repository one &&
setup_repository two &&
@@ -209,4 +218,156 @@ test_expect_success 'git fetch --multiple --jobs=0 picks a default' '
git fetch --multiple --jobs=0)
'
+create_fetch_all_expect () {
+ cat >expect <<-\EOF
+ one/main
+ one/side
+ origin/HEAD -> origin/main
+ origin/main
+ origin/side
+ three/another
+ three/main
+ three/side
+ two/another
+ two/main
+ two/side
+ EOF
+}
+
+for fetch_all in true false
+do
+ test_expect_success "git fetch --all (works with fetch.all = $fetch_all)" '
+ test_dir="test_fetch_all_$fetch_all" &&
+ setup_test_clone "$test_dir" &&
+ (
+ cd "$test_dir" &&
+ git config fetch.all $fetch_all &&
+ git fetch --all &&
+ create_fetch_all_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+ '
+done
+
+test_expect_success 'git fetch (fetch all remotes with fetch.all = true)' '
+ setup_test_clone test9 &&
+ (
+ cd test9 &&
+ git config fetch.all true &&
+ git fetch &&
+ git branch -r >actual &&
+ create_fetch_all_expect &&
+ test_cmp expect actual
+ )
+'
+
+create_fetch_one_expect () {
+ cat >expect <<-\EOF
+ one/main
+ one/side
+ origin/HEAD -> origin/main
+ origin/main
+ origin/side
+ EOF
+}
+
+test_expect_success 'git fetch one (explicit remote overrides fetch.all)' '
+ setup_test_clone test10 &&
+ (
+ cd test10 &&
+ git config fetch.all true &&
+ git fetch one &&
+ create_fetch_one_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+'
+
+create_fetch_two_as_origin_expect () {
+ cat >expect <<-\EOF
+ origin/HEAD -> origin/main
+ origin/another
+ origin/main
+ origin/side
+ EOF
+}
+
+test_expect_success 'git config fetch.all false (fetch only default remote)' '
+ setup_test_clone test11 &&
+ (
+ cd test11 &&
+ git config fetch.all false &&
+ git remote set-url origin ../two &&
+ git fetch &&
+ create_fetch_two_as_origin_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+'
+
+for fetch_all in true false
+do
+ test_expect_success "git fetch --no-all (fetch only default remote with fetch.all = $fetch_all)" '
+ test_dir="test_no_all_fetch_all_$fetch_all" &&
+ setup_test_clone "$test_dir" &&
+ (
+ cd "$test_dir" &&
+ git config fetch.all $fetch_all &&
+ git remote set-url origin ../two &&
+ git fetch --no-all &&
+ create_fetch_two_as_origin_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+ '
+done
+
+test_expect_success 'git fetch --no-all (fetch only default remote without fetch.all)' '
+ setup_test_clone test12 &&
+ (
+ cd test12 &&
+ git config --unset-all fetch.all || true &&
+ git remote set-url origin ../two &&
+ git fetch --no-all &&
+ create_fetch_two_as_origin_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'git fetch --all --no-all (fetch only default remote)' '
+ setup_test_clone test13 &&
+ (
+ cd test13 &&
+ git remote set-url origin ../two &&
+ git fetch --all --no-all &&
+ create_fetch_two_as_origin_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'git fetch --no-all one (fetch only explicit remote)' '
+ setup_test_clone test14 &&
+ (
+ cd test14 &&
+ git fetch --no-all one &&
+ create_fetch_one_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'git fetch --no-all --all (fetch all remotes)' '
+ setup_test_clone test15 &&
+ (
+ cd test15 &&
+ git fetch --no-all --all &&
+ create_fetch_all_expect &&
+ git branch -r >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done
--
2.43.0
^ permalink raw reply related
* Re: Analyzing a corrupted index file
From: Junio C Hamano @ 2024-01-08 19:51 UTC (permalink / raw)
To: Nathan Manceaux-Panot; +Cc: git
In-Reply-To: <B38C5D82-33E3-4D10-8119-7E0D59DD3DA2@lemon.garden>
Nathan Manceaux-Panot <fresh.tree3651@lemon.garden> writes:
> I have a corrupted git index file, and am trying to read it by
> hand, to understand what's wrong with it. Are there any tools
> that'll let me parse the on-disk, binary version of the index
> file, to unpack it into a human-readable data structure?
"git ls-files" with its various options is probably the closest, but
even the command is not meant for "debugging the bits". It is more
about showing lower-level details of a working index file to help
diagnose the mismatch between end-user expectation and the reality
(e.g. the user says the conflicts were all resolved, an expert asks
to run "ls-files -u" and together they discover that there are paths
that are still unmerged).
^ permalink raw reply
* Re: Storing private config files in .git directory?
From: Marc Branchaud @ 2024-01-08 19:48 UTC (permalink / raw)
To: Stefan Haller, git
In-Reply-To: <8e344dee-f84e-4a2c-835a-406ee72d129b@haller-berlin.de>
On 2024-01-07 08:03, Stefan Haller wrote:
> Our git client (lazygit) has a need to store per-repo config files that
> override the global one, much like git itself. The easiest way to do
> that is to store those in a .git/lazygit.cfg file, and I'm wondering if
> there's any reason why this is a bad idea?
In a worktree (created by "git worktree"), .git is a file not a directory.
Worktrees are designed to each have their own .git directory, which you
can find with "git rev-parse --git-dir". If you just want a single,
repo-wide config file, not a per-worktree config, you probably want to
instead use "git rev-parse --git-common-dir" to find the "main" repo's
.git directory.
The problem of finding a worktree's .git directory goes away if you use
Git's own config system, though.
> Another alternative would be to store the config values in .git/config
> (that's the path taken by git gui, for example), but since our config
> file format is yaml, this would require translation. It would be trivial
> for scalar values such as int or string, but I'm not sure how well this
> would work for more complex settings like lists of objects.
>
> Any thoughts?
YAML is a horrid little format (hey, you asked for "thoughts"!), and
IIRC Git's config file format only supports multi-line values with
\-escaping and similar patterns, making it nearly impossible to directly
embed YAML in Git's config file. Ideally, if you do use Git's own
config then you really should just drop YAML altogether.
But you have a couple of options without going so far as translating all
the YAML constructs you use into git-config ones. For example, you
could replace all the newlines in a YAML blob with \n to make a
single-line value that you could store in Git's config file. That
complicates hand-editing the YAML though, if that's a use case you care
about.
But even if you replace all the newlines with \n, in my experience there
are always corner-case clashes when mixing file syntaxes (e.g. quoted
strings are often problematic, and maybe some of your YAML values are
themselves multi-line). If you want to use Git's own config file but
stick with YAML, and you really don't care about directly editing the
YAML, I suggest you encode the entire YAML blob in a robust single-line
format, like base64, and store/retrieve that using "git config".
You could still support hand-editing the YAML with a command like
"lazygit editconfig", too.
M.
^ permalink raw reply
* Re: [PATCH 0/1] completion: send-email: don't complete revs when --no-format-patch
From: Britton Kerin @ 2024-01-08 19:34 UTC (permalink / raw)
To: Dragan Simic; +Cc: git
In-Reply-To: <0e8a1572100faae72db54becefe19f6b@manjaro.org>
On Mon, Jan 8, 2024 at 12:40 AM Dragan Simic <dsimic@manjaro.org> wrote:
>
> On 2024-01-08 10:36, Britton Leo Kerin wrote:
> > Along the way I taught __git_find_last_on_cmdline to understand '--',
> > which
> > isn't stricly necessary but I think reads more clearly at the call
> > sites.
> > __git_find_on_cmdline could be changed to work the same, or this part
> > dropped
> > if people don't like it.
>
> If I may suggest, there's no need for a cover letter for a single patch.
> If you want to include some notes in the patch submission, which aren't
> supposed to be part of the commit summary, you can do that in the patch
> itself.
Ok thanks, I'll do it that way in future.
Britton
^ permalink raw reply
* Re: [PATCH v7 1/1] mingw: give more details about unsafe directory's ownership
From: Junio C Hamano @ 2024-01-08 19:18 UTC (permalink / raw)
To: Sören Krecker; +Cc: git, sunshine, j6t
In-Reply-To: <20240108173837.20480-2-soekkle@freenet.de>
Sören Krecker <soekkle@freenet.de> writes:
> Add domain/username in error message, if owner sid of repository and
> user sid are not equal on windows systems.
Will queue. "git am --whitespace=fix" noticed numerous whitespace
breakages in the patch, which has been corrected on the receiving
end. Please make sure your future patches will not have such
problems.
Thanks.
$ git am -s3c ./+sk-v7-mingw-ownership-report
Applying: mingw: give more details about unsafe directory's ownership
.git/rebase-apply/patch:23: trailing whitespace.
&pe_use);
.git/rebase-apply/patch:27: trailing whitespace.
ALLOC_ARRAY((*str), (size_t)len_domain + (size_t)len_user);
.git/rebase-apply/patch:45: trailing whitespace.
LPSTR str1, str2, str3, str4, to_free1 = NULL,
warning: 3 lines add whitespace errors.
.git/rebase-apply/patch:23: trailing whitespace.
&pe_use);
.git/rebase-apply/patch:27: trailing whitespace.
ALLOC_ARRAY((*str), (size_t)len_domain + (size_t)len_user);
.git/rebase-apply/patch:45: trailing whitespace.
LPSTR str1, str2, str3, str4, to_free1 = NULL,
warning: 3 lines applied after fixing whitespace errors.
Using index info to reconstruct a base tree...
M compat/mingw.c
Falling back to patching base and 3-way merge...
Auto-merging compat/mingw.c
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox